@@ -22,7 +22,8 @@ internal sealed class CitizenProcessor<TAI, TCitizen>
22
22
private readonly RealTimeResidentAI < TAI , TCitizen > residentAI ;
23
23
private readonly SpareTimeBehavior spareTimeBehavior ;
24
24
private readonly ITimeInfo timeInfo ;
25
- private int dayStartFrame ;
25
+ private int cycleStartFrame ;
26
+ private int cycleHour ;
26
27
27
28
/// <summary>Initializes a new instance of the <see cref="CitizenProcessor{TAI, TCitizen}"/> class.</summary>
28
29
/// <param name="residentAI">The custom resident AI implementation.</param>
@@ -34,13 +35,18 @@ public CitizenProcessor(RealTimeResidentAI<TAI, TCitizen> residentAI, SpareTimeB
34
35
this . residentAI = residentAI ?? throw new ArgumentNullException ( nameof ( residentAI ) ) ;
35
36
this . spareTimeBehavior = spareTimeBehavior ?? throw new ArgumentNullException ( nameof ( spareTimeBehavior ) ) ;
36
37
this . timeInfo = timeInfo ?? throw new ArgumentNullException ( nameof ( timeInfo ) ) ;
37
- dayStartFrame = int . MinValue ;
38
+ cycleStartFrame = int . MinValue ;
38
39
}
39
40
40
- /// <summary>Notifies this simulation object that a new game day begins.</summary>
41
- public void StartNewDay ( )
41
+ /// <summary>Notifies this simulation object that a particular day hour begins.</summary>
42
+ /// <param name="hour">The day time hour.</param>
43
+ public void TriggerHour ( int hour )
42
44
{
43
- dayStartFrame = int . MinValue ;
45
+ if ( hour % 8 == 0 )
46
+ {
47
+ cycleHour = hour ;
48
+ cycleStartFrame = int . MinValue ;
49
+ }
44
50
}
45
51
46
52
/// <summary>Re-calculates the duration of a simulation frame.</summary>
@@ -61,21 +67,21 @@ public void ProcessTick()
61
67
/// <param name="frameIndex">The index of the simulation frame to process.</param>
62
68
public void ProcessFrame ( uint frameIndex )
63
69
{
64
- if ( dayStartFrame == - 1 )
70
+ if ( cycleStartFrame == - 1 )
65
71
{
66
72
return ;
67
73
}
68
74
69
75
uint step = frameIndex & StepMask ;
70
- if ( dayStartFrame == int . MinValue )
76
+ if ( cycleStartFrame == int . MinValue )
71
77
{
72
- residentAI . BeginNewDayProcessing ( ) ;
73
- dayStartFrame = ( int ) step ;
78
+ residentAI . BeginNewHourCycleProcessing ( cycleHour ) ;
79
+ cycleStartFrame = ( int ) step ;
74
80
}
75
- else if ( step == dayStartFrame )
81
+ else if ( step == cycleStartFrame )
76
82
{
77
- residentAI . EndNewDayProcessing ( ) ;
78
- dayStartFrame = - 1 ;
83
+ residentAI . EndHourCycleProcessing ( ) ;
84
+ cycleStartFrame = - 1 ;
79
85
return ;
80
86
}
81
87
0 commit comments