protected override void OnChangedGoal(NPCBase.NPCGoal oldGoal, NPCBase.NPCGoal newGoal) { if (oldGoal == NPCBase.NPCGoal.Job && wasCrafting) { OnStopCrafting(); } }
public virtual NPCBase.NPCGoal CalculateGoal(ref NPCBase.NPCState state) { NPCBase.NPCGoal newGoal; if (ToSleep) { if (!state.Inventory.IsEmpty) { newGoal = NPCBase.NPCGoal.Stockpile; } else { newGoal = NPCBase.NPCGoal.Bed; } } else { if (state.Inventory.Full || NeedsItems) { newGoal = NPCBase.NPCGoal.Stockpile; } else { newGoal = NPCBase.NPCGoal.Job; } } if (lastGoal != newGoal) { OnChangedGoal(lastGoal, newGoal); lastGoal = newGoal; } return(newGoal); }
public void OnGoalChanged(BlockJobInstance jobInstance, NPCBase.NPCGoal goalOld, NPCBase.NPCGoal goalNew) { MachineJobInstance instance = (MachineJobInstance)jobInstance; if (goalOld == NPCBase.NPCGoal.Job && instance.IsCrafting) { instance.IsCrafting = false; OnStopCrafting(instance); } }
public void OnGoalChanged(BlockJobInstance instanceBlock, NPCBase.NPCGoal goalOld, NPCBase.NPCGoal goalNew) { GeneratorJobInstance instance = (GeneratorJobInstance)instanceBlock; if (goalOld == NPCBase.NPCGoal.Job && instance.IsCrafting) { instance.IsCrafting = false; OnStopCrafting(instance); } }
static bool Prefix(NPCBase __instance, ref Vector3Int __result, NPCBase.NPCGoal goal) { if (__instance == null || __instance.Colony == null || __instance.Colony.BedTracker == null) { return(true); } switch (goal) { case NPCBase.NPCGoal.Bed: { if (__instance.UsedBed != null && __instance.UsedBed.IsValid) { return(true); } if (__instance.Job == null) { return(true); } Vector3Int jobLocation; BedTracker.Bed bed; if (__instance.Colony.BedTracker.TryGetClosestUnused(__instance.Job.GetJobLocation(), out jobLocation, out bed, 200)) { ClassUtility.Call(__instance, "ClearBed", new object[] { }); ClassUtility.SetProperty(__instance, "UsedBed", bed); ClassUtility.SetProperty(__instance, "UsedBedLocation", jobLocation); bed.SetUseState(jobLocation, true); __result = jobLocation; return(false); } break; } } return(true); }
protected virtual void OnChangedGoal(NPCBase.NPCGoal oldGoal, NPCBase.NPCGoal newGoal) { }
public void OnGoalChanged(BlockJobInstance instance, NPCBase.NPCGoal goalOld, NPCBase.NPCGoal goalNew) { }
public void OnGoalChanged(BlockJobInstance instanceBlock, NPCBase.NPCGoal oldGoal, NPCBase.NPCGoal newGoal) { }