public IEnumerator <Coroutine> FindPathAndMove(TriCell target, bool entityCheck, bool terrainCheck) { TriGrid inst = TriGrid.Instance; if (target && IsValidDestination(target)) { inst.FindPath(Location, target, entityCheck, terrainCheck); if (inst.HasPath) { pathToTravel = inst.GetPath(); CancelNowAct(); yield return(nowRoutine = StartCoroutine(TravelPath())); inst.ClearPath(); ActResult = true; } else { ActResult = false; } } else { inst.ClearPath(); ActResult = false; } yield return(null); }
public void SetEditMode(bool toggle) { enabled = !toggle; grid.ClearPath(); }
public override void Tick() { base.Tick(); if (Clock.IsDay()) { if (Work) { RoutineTarget = Work; } else if (Company) { RoutineTarget = Company; } else if (Home) { RoutineTarget = Home; } else { RoutineTarget = TriIsland.GetCamp(); } } else { if (Home) { RoutineTarget = Home; } else { RoutineTarget = TriIsland.GetCamp(); } } if (nowWork == null && !acting && commandQueue.Count == 0 && RoutineTarget && RoutineTarget != Building) { CancelAllAct(); Debug.LogWarning("<color=#ff0000>act canceled</color> and moved to : " + routineTarget); TriGrid inst = TriGrid.Instance; inst.FindPath(Location, routineTarget.EntranceLocation, true, true); if (inst.HasPath) { inst.ClearPath(); AddCommand(new MoveCommand(RoutineTarget.EntranceLocation, true, true)); AddCommand(new GetInCommand(RoutineTarget)); } else { inst.ClearPath(); if (RoutineTarget == Work) { AddCommand(new ChangeWorkCommand(null)); } else if (RoutineTarget == Company) { AddCommand(new ChangeJobCommand(null)); } else if (RoutineTarget == Home) { AddCommand(new ChangeHomeCommand(null)); } } } }