/* * Faction help must be handled here, since it's independent of whether or not a caravan is here. * Make it with a delay of 1/50 s compared to the CaravanComp so both functions end up playing nicely along each other * Don't work at night ! */ public override void CompTick() { try { if (((RoadConstructionSite)parent).helpFromFaction == null || CaravanNightRestUtility.RestingNowAt(((RoadConstructionSite)parent).Tile) || Find.TickManager.TicksGame % 100 != 50) { return; } ((RoadConstructionSite)parent).TryToSkipBetterRoads(); // No need to work if there's a better road here var amountOfWork = ((RoadConstructionSite)parent).FactionHelp(); var percentOfWorkLeftToDoAfter = (GetLeft("Work") - amountOfWork) / GetCost("Work"); foreach (var resourceName in DefModExtension_RotR_RoadDef.allResources) { ReduceLeft(resourceName, (int)Math.Round(GetLeft(resourceName) - (percentOfWorkLeftToDoAfter * GetCost(resourceName)))); } UpdateProgress(amountOfWork); } catch (Exception e) { RoadsOfTheRim.DebugLog("Construction Site CompTick. parentsite = " + (RoadConstructionSite)parent, e); } }
/* * Faction help must be handled here, since it's independent of whether or not a caravan is here. * Make it with a delay of 1/50 s compared to the CaravanComp so both functions end up playing nicely along each other * Don't work at night ! */ public override void CompTick() { try { if ((((RoadConstructionSite)parent).helpFromFaction != null) && (!CaravanNightRestUtility.RestingNowAt(((RoadConstructionSite)parent).Tile)) && (Find.TickManager.TicksGame % 100 == 50)) { ((RoadConstructionSite)parent).TryToSkipBetterRoads(); // No need to work if there's a better road here float amountOfWork = ((RoadConstructionSite)parent).factionHelp(); float percentOfWorkLeftToDoAfter = ((float)GetLeft("Work") - amountOfWork) / (float)GetCost("Work"); foreach (string resourceName in DefModExtension_RotR_RoadDef.allResources) { ReduceLeft(resourceName, (int)Math.Round((float)GetLeft(resourceName) - (percentOfWorkLeftToDoAfter * (float)GetCost(resourceName)))); } UpdateProgress(amountOfWork); } } catch (Exception e) { RoadsOfTheRim.DebugLog("Construction Site CompTick. parentsite = " + ((RoadConstructionSite)parent), e); } }