Skip to content

Commit

Permalink
Allow the citizens to buy goods in at leisure buildings
Browse files Browse the repository at this point in the history
  • Loading branch information
dymanoid committed Jun 26, 2018
1 parent bf3796b commit fa3e8ec
Showing 1 changed file with 11 additions and 1 deletion.
12 changes: 11 additions & 1 deletion src/RealTime/CustomResidentAI/RealTimeResidentAI.Visit.cs
Original file line number Diff line number Diff line change
Expand Up @@ -13,7 +13,8 @@ internal sealed partial class RealTimeResidentAI<TAI, TCitizen>
{
private void ProcessCitizenVisit(TAI instance, ResidentState citizenState, uint citizenId, ref TCitizen citizen)
{
if (CitizenProxy.GetVisitBuilding(ref citizen) == 0)
ushort currentBuilding = CitizenProxy.GetVisitBuilding(ref citizen);
if (currentBuilding == 0)
{
Log.Debug($"WARNING: {GetCitizenDesc(citizenId, ref citizen)} is in corrupt state: visiting with no visit building. Teleporting home.");
CitizenProxy.SetLocation(ref citizen, Citizen.Location.Home);
Expand All @@ -28,6 +29,15 @@ private void ProcessCitizenVisit(TAI instance, ResidentState citizenState, uint
return;

case ResidentState.AtLeisureArea:
if (CitizenProxy.HasFlags(ref citizen, Citizen.Flags.NeedGoods)
&& BuildingMgr.GetBuildingSubService(currentBuilding) == ItemClass.SubService.CommercialLeisure)
{
// No Citizen.Flags.NeedGoods flag reset here, because we only bought 'beer' or 'champagne' in a leisure building.
BuildingMgr.ModifyMaterialBuffer(CitizenProxy.GetVisitBuilding(ref citizen), TransferManager.TransferReason.Shopping, -ShoppingGoodsAmount);
}

goto case ResidentState.Visiting;

case ResidentState.Visiting:
if (!CitizenGoesWorking(instance, citizenId, ref citizen))
{
Expand Down

0 comments on commit fa3e8ec

Please sign in to comment.