Skip to content

Commit

Permalink
Use wakeup and go-to-sleep time for citizens
Browse files Browse the repository at this point in the history
  • Loading branch information
dymanoid committed Jul 12, 2018
1 parent e6a04a5 commit 8cc637c
Show file tree
Hide file tree
Showing 3 changed files with 14 additions and 3 deletions.
2 changes: 1 addition & 1 deletion src/RealTime/Core/RealTimeCore.cs
Original file line number Diff line number Diff line change
Expand Up @@ -94,7 +94,7 @@ public static RealTimeCore Run(RealTimeConfig config, string rootPath, ILocaliza
return null;
}

var timeInfo = new TimeInfo();
var timeInfo = new TimeInfo(config);
var buildingManager = new BuildingManagerConnection();
var randomizer = new GameRandomizer();

Expand Down
13 changes: 12 additions & 1 deletion src/RealTime/GameConnection/TimeInfo.cs
Original file line number Diff line number Diff line change
Expand Up @@ -5,6 +5,7 @@
namespace RealTime.GameConnection
{
using System;
using RealTime.Config;
using RealTime.Simulation;

/// <summary>
Expand All @@ -13,6 +14,16 @@ namespace RealTime.GameConnection
/// <seealso cref="ITimeInfo" />
internal sealed class TimeInfo : ITimeInfo
{
private readonly RealTimeConfig config;

/// <summary>Initializes a new instance of the <see cref="TimeInfo" /> class.</summary>
/// <param name="config">The configuration to run with.</param>
/// <exception cref="ArgumentNullException">Thrown when the argument is null.</exception>
public TimeInfo(RealTimeConfig config)
{
this.config = config ?? throw new ArgumentNullException(nameof(config));
}

/// <summary>Gets the current game date and time.</summary>
public DateTime Now => SimulationManager.instance.m_currentGameTime;

Expand All @@ -31,7 +42,7 @@ public bool IsNightTime
get
{
float currentHour = CurrentHour;
return currentHour >= SunsetHour || currentHour < SunriseHour;
return currentHour >= config.GoToSleepUpHour || currentHour < config.WakeupHour;
}
}

Expand Down
2 changes: 1 addition & 1 deletion src/RealTime/Simulation/AwakeSleepSimulation.cs
Original file line number Diff line number Diff line change
Expand Up @@ -114,7 +114,7 @@ void ISimulationManager.LateUpdateData(SimulationManager.UpdateMode mode)

void ISimulationManager.SimulationStep(int subStep)
{
if (subStep == 0)
if (subStep == 0 || !SimulationManager.instance.m_enableDayNight)
{
return;
}
Expand Down

0 comments on commit 8cc637c

Please sign in to comment.