public override void JobUpdate(NPC npc) { if (CurrentlyWorkingAt != null) { Vector3 workPos = CurrentlyWorkingAt.WorkPosition(); Vector3 pathTarget = npc.GetLoadedEntity().LEPathFinder.Target; //Currently targeted to the work position if (pathTarget.WithinDistance(workPos, 1)) { //If we are close to the current object if (workPos.WithinDistance(pathTarget, 0.2f)) { //Play working animation } //If we are not close, but our path finder target is set, we just wait till we arrive } else { npc.GetLoadedEntity().LEPathFinder.SetTarget(workPos); npc.GetLoadedEntity().SpeechBubble.PushMessage("Walking to work equiptment at " + workPos + " current target " + npc.GetLoadedEntity().LEPathFinder.Target); } } }
public override void JobTick(NPC npc) { //If we currently have no task if (SubTask == CurrentSubTask.None) { if (!HasEquiptment) { SetSubTask(npc, CurrentSubTask.GettingEquiptment); } } else if (SubTask == CurrentSubTask.GettingEquiptment) { //if we have sucesfully got our equiptment if (HasEquiptment) { if (GameManager.RNG.RandomBool()) { //TODO - uncomment this //SetSubTask(npc, CurrentSubTask.Patrolling); SetSubTask(npc, CurrentSubTask.Training); } else { SetSubTask(npc, CurrentSubTask.Training); } } } else if (SubTask == CurrentSubTask.Patrolling) { if (CurrentTargetPosition.WithinDistance(npc.Position, 3)) { Settlement set = npc.NPCKingdomData.GetSettlement(); CurrentTargetPosition = set.RandomPathPoint().AsVector3(); npc.GetLoadedEntity().LEPathFinder.SetTarget(CurrentTargetPosition); npc.GetLoadedEntity().SpeechBubble.PushMessage("Choosing new patrol target " + CurrentTargetPosition); } } else if (SubTask == CurrentSubTask.Training) { if (CurrentTargetEquiptment == null) { CurrentTargetEquiptment = GameManager.RNG.RandomFromList(WorkEquiptment); for (int i = 0; i < 10; i++) { if (CurrentTargetEquiptment.CurrentUser != null) { CurrentTargetEquiptment = GameManager.RNG.RandomFromList(WorkEquiptment); } else { CurrentTargetEquiptment.CurrentUser = npc; } } //If no valid equiptment is found, we patrol if (CurrentTargetEquiptment == null) { SetSubTask(npc, CurrentSubTask.Patrolling); } else { //if the equiptment is non null, we target and travel to it CurrentTargetPosition = CurrentTargetEquiptment.WorkPosition(); npc.GetLoadedEntity().LEPathFinder.SetTarget(CurrentTargetPosition); npc.GetLoadedEntity().SpeechBubble.PushMessage("Training on object " + CurrentTargetPosition); } } } }