change to seconds not ms
This commit is contained in:
@@ -376,7 +376,7 @@ public class PlayerScavGenerator(
|
||||
|
||||
if (scavData?.Info != null)
|
||||
{
|
||||
scavData.Info.SavageLockTime = Math.Round(_timeUtil.GetTimeStampFromEpoch() / 1000 + (scavLockDuration ?? 0));
|
||||
scavData.Info.SavageLockTime = Math.Round(_timeUtil.GetTimeStamp() + (scavLockDuration ?? 0));
|
||||
}
|
||||
|
||||
return scavData;
|
||||
|
||||
@@ -140,10 +140,10 @@ public class WeatherGenerator(
|
||||
var formattedDate = _timeUtil.FormatDate(timestamp.HasValue ? _timeUtil.GetDateTimeFromTimeStamp(timestamp.Value) : DateTime.UtcNow);
|
||||
var datetimeBsgFormat = $"{formattedDate} {normalTime}";
|
||||
|
||||
weather.Timestamp = timestamp ?? _timeUtil.GetTimeStampFromEpoch(inRaidTime) / 1000; // matches weather.date
|
||||
weather.Timestamp = timestamp ?? _timeUtil.GetTimeStamp(); // matches weather.date
|
||||
weather.Date = formattedDate; // matches weather.timestamp
|
||||
weather.Time = datetimeBsgFormat; // matches weather.timestamp
|
||||
weather.SptInRaidTimestamp = _timeUtil.GetTimeStampFromEpoch(inRaidTime);
|
||||
weather.SptInRaidTimestamp = weather.Timestamp;
|
||||
}
|
||||
|
||||
protected WindDirection GetWeightedWindDirection(SeasonalValues weather)
|
||||
|
||||
@@ -28,7 +28,7 @@ public class WeatherHelper(
|
||||
var twentyFourHoursMilliseconds = _timeUtil.GetHoursAsSeconds(24) * 1000;
|
||||
var currentTimestampMilliSeconds = timestamp.HasValue
|
||||
? timestamp ?? 0
|
||||
: _timeUtil.GetTimeStampFromEpoch();
|
||||
: _timeUtil.GetTimeStamp();
|
||||
|
||||
return _timeUtil.GetDateTimeFromTimeStamp(
|
||||
(long)
|
||||
|
||||
@@ -27,23 +27,23 @@ public class RaidWeatherService(
|
||||
public void GenerateWeather(Season currentSeason)
|
||||
{
|
||||
// When to start generating weather from in milliseconds
|
||||
var staringTimestampMs = _timeUtil.GetTodayMidnightTimeStamp();
|
||||
var staringTimestamp = _timeUtil.GetTodayMidnightTimeStamp();
|
||||
|
||||
// How far into future do we generate weather
|
||||
var futureTimestampToReachMs =
|
||||
staringTimestampMs + _timeUtil.GetHoursAsSeconds(_weatherConfig.Weather.GenerateWeatherAmountHours ?? 1) * 1000; // Convert to milliseconds
|
||||
var futureTimestampToReach =
|
||||
staringTimestamp + _timeUtil.GetHoursAsSeconds(_weatherConfig.Weather.GenerateWeatherAmountHours ?? 1);
|
||||
|
||||
// Keep adding new weather until we have reached desired future date
|
||||
var nextTimestampMs = staringTimestampMs;
|
||||
while (nextTimestampMs <= futureTimestampToReachMs)
|
||||
var nextTimestamp = staringTimestamp;
|
||||
while (nextTimestamp <= futureTimestampToReach)
|
||||
{
|
||||
var newWeatherToAddToCache = _weatherGenerator.GenerateWeather(currentSeason, nextTimestampMs);
|
||||
var newWeatherToAddToCache = _weatherGenerator.GenerateWeather(currentSeason, nextTimestamp);
|
||||
|
||||
// Add generated weather for time period to cache
|
||||
_weatherForecast.Add(newWeatherToAddToCache);
|
||||
|
||||
// Increment timestamp so next loop can begin at correct time
|
||||
nextTimestampMs += GetWeightedWeatherTimePeriodMs();
|
||||
nextTimestamp += GetWeightedWeatherTimePeriod();
|
||||
}
|
||||
}
|
||||
|
||||
@@ -51,7 +51,7 @@ public class RaidWeatherService(
|
||||
/// Get a time period to increment by, e.g. 15 or 30 minutes as milliseconds
|
||||
/// </summary>
|
||||
/// <returns>milliseconds</returns>
|
||||
protected long GetWeightedWeatherTimePeriodMs()
|
||||
protected long GetWeightedWeatherTimePeriod()
|
||||
{
|
||||
var chosenTimePeriodMinutes = _weightedRandomHelper.WeightedRandom(
|
||||
_weatherConfig.Weather.TimePeriod.Values,
|
||||
@@ -59,7 +59,7 @@ public class RaidWeatherService(
|
||||
)
|
||||
.Item;
|
||||
|
||||
return chosenTimePeriodMinutes * 60 * 1000; // Convert to milliseconds
|
||||
return chosenTimePeriodMinutes * 60;
|
||||
}
|
||||
|
||||
/// <summary>
|
||||
|
||||
@@ -167,7 +167,7 @@ public class TimeUtil
|
||||
// Create a new DateTime with the last full hour, 0 minutes, and 0 seconds
|
||||
var lastFullHour = new DateTime(now.Year, now.Month, now.Day, hours, 0, 0);
|
||||
|
||||
return ((DateTimeOffset) lastFullHour).ToUnixTimeMilliseconds();
|
||||
return ((DateTimeOffset) lastFullHour).ToUnixTimeSeconds();
|
||||
}
|
||||
|
||||
/// <summary>
|
||||
@@ -190,18 +190,6 @@ public class TimeUtil
|
||||
return DateTimeOffset.FromUnixTimeSeconds(timeStamp).DateTime;
|
||||
}
|
||||
|
||||
/// <summary>
|
||||
/// Takes a date and gets difference between Epoch time and time provided resulting in a timestamp (date defaults to utcnow)
|
||||
/// This attempts to mimic gettime() in js
|
||||
/// </summary>
|
||||
/// <param name="date"></param>
|
||||
/// <returns></returns>
|
||||
public long GetTimeStampFromEpoch(DateTime? date = null)
|
||||
{
|
||||
var dateToCompare = date ?? DateTime.UtcNow;
|
||||
return (long) (dateToCompare - DateTime.UnixEpoch).TotalMilliseconds;
|
||||
}
|
||||
|
||||
public int GetSecondsAsMilliseconds(int seconds)
|
||||
{
|
||||
return seconds * 60 * 1000;
|
||||
|
||||
Reference in New Issue
Block a user