Skip to content

Commit

Permalink
Improve debug logging
Browse files Browse the repository at this point in the history
  • Loading branch information
dymanoid committed May 28, 2019
1 parent eff6d2f commit 1331eaf
Show file tree
Hide file tree
Showing 2 changed files with 15 additions and 3 deletions.
8 changes: 7 additions & 1 deletion src/RealTime/CustomAI/RealTimeResidentAI.Home.cs
Original file line number Diff line number Diff line change
Expand Up @@ -20,11 +20,17 @@ private void DoScheduledHome(ref CitizenSchedule schedule, TAI instance, uint ci
ushort currentBuilding = CitizenProxy.GetCurrentBuilding(ref citizen);
CitizenProxy.RemoveFlags(ref citizen, Citizen.Flags.Evacuating);

#if DEBUG
string logEntry = $"{GetCitizenDesc(citizenId, ref citizen)} is going from {currentBuilding} back home";
#else
const string logEntry = null;
#endif

if (residentAI.StartMoving(instance, citizenId, ref citizen, currentBuilding, homeBuilding))
{
CitizenProxy.SetVisitPlace(ref citizen, citizenId, 0);
schedule.Schedule(ResidentState.Unknown);
Log.Debug(LogCategory.Movement, TimeInfo.Now, $"{GetCitizenDesc(citizenId, ref citizen)} is going from {currentBuilding} back home");
Log.Debug(LogCategory.Movement, TimeInfo.Now, logEntry);
}
else
{
Expand Down
10 changes: 8 additions & 2 deletions src/RealTime/CustomAI/RealTimeResidentAI.SchoolWork.cs
Original file line number Diff line number Diff line change
Expand Up @@ -66,6 +66,12 @@ private void DoScheduledWork(ref CitizenSchedule schedule, TAI instance, uint ci
return;
}

#if DEBUG
string citizenDesc = GetCitizenDesc(citizenId, ref citizen);
#else
const string citizenDesc = null;
#endif

if (residentAI.StartMoving(instance, citizenId, ref citizen, currentBuilding, schedule.WorkBuilding))
{
if (schedule.CurrentState != ResidentState.AtHome)
Expand All @@ -78,12 +84,12 @@ private void DoScheduledWork(ref CitizenSchedule schedule, TAI instance, uint ci
Citizen.AgeGroup citizenAge = CitizenProxy.GetAge(ref citizen);
if (workBehavior.ScheduleLunch(ref schedule, citizenAge))
{
Log.Debug(LogCategory.Movement, TimeInfo.Now, $"{GetCitizenDesc(citizenId, ref citizen)} is going from {currentBuilding} to school/work {schedule.WorkBuilding} and will go to lunch at {schedule.ScheduledStateTime}");
Log.Debug(LogCategory.Movement, TimeInfo.Now, $"{citizenDesc} is going from {currentBuilding} to school/work {schedule.WorkBuilding} and will go to lunch at {schedule.ScheduledStateTime}");
}
else
{
workBehavior.ScheduleReturnFromWork(ref schedule, citizenAge);
Log.Debug(LogCategory.Movement, TimeInfo.Now, $"{GetCitizenDesc(citizenId, ref citizen)} is going from {currentBuilding} to school/work {schedule.WorkBuilding} and will leave work at {schedule.ScheduledStateTime}");
Log.Debug(LogCategory.Movement, TimeInfo.Now, $"{citizenDesc} is going from {currentBuilding} to school/work {schedule.WorkBuilding} and will leave work at {schedule.ScheduledStateTime}");
}
}
else
Expand Down

0 comments on commit 1331eaf

Please sign in to comment.