public ElveState_Climb(ElveBehavior owner, float dir) : base(owner) { Assert.IsTrue(dir == 1.0f || dir == -1.0f, "Dir must be +/- 1, but it is " + dir); Dir = dir; }
public ElveState_CrossLedge(ElveBehavior owner, Vector2i moveAmount) : base(owner) { MoveAmount = moveAmount; Assert.IsTrue(moveAmount.x == 1 || moveAmount.x == -1); Assert.IsTrue(moveAmount.y == 1 || moveAmount.y == -1); }
public override bool CanElveDoJob(ElveBehavior elve) { PathFinder<VoxelNode> pather = new PathFinder<VoxelNode>(VoxelGraph.Instance, (n1, n2) => new VoxelEdge(n1, n2, PathingConstants.MovementTypes.Walk)); pather.Start = new VoxelNode((Vector2)elve.MyTransform.position); pather.End = new VoxelNode(PlantPos); return pather.FindPath(); }
public override IEnumerator RunJobCoroutine(ElveBehavior elve) { yield return null; elveMovement = elve.GetComponent<ElveMovementController>(); //Move to the target. if (!elveMovement.StartPath(PlantPos)) { StopJob(true, "Path is blocked"); yield break; } while (!elveMovement.IsPathCompleted) yield return null; //Plant the seed. Assert.IsNull(elve.CurrentState); elve.CurrentState = new ElveState_UseMagic(elve, JobConstants.Instance.TimeToPlantSeed, ElveBehavior.Surfaces.Floor); while (elve.CurrentState != null) yield return null; //Stop the job before creating the seed. //Otherwise, the changing of that voxel will cause this job to cancel itself. StopJob(false); WorldVoxels.Instance.SetVoxelAt(PlantPos, SeedType); SeedManager.Instance.Seeds.Add(new SeedManager.SeedData(PlantPos, GrowPattern)); }
public ElveState_MoveToEdge(ElveBehavior owner, ElveState toResume, float dir) : base(owner) { Dir = dir; ToResume = toResume; }
/// <summary> /// An empty callback. Used above when triggering the "OnStateChanged" event. /// </summary> private static void DummyFunc(ElveBehavior m, ElveState s1, ElveState s2) { }
public ElveState_UseMagic(ElveBehavior owner, float duration, ElveBehavior.Surfaces target) : base(owner) { TimeLeft = duration; Target = target; }
/// <summary> /// A coroutine that makes the given Elve do this job. /// NOTE: Make sure at least one update cycle has passed before calling "StopJob()". /// </summary> public abstract IEnumerator RunJobCoroutine(ElveBehavior elve);
/// <summary> /// Calculates whether the given Elve can do this job, ignoring labor requirements. /// </summary> public abstract bool CanElveDoJob(ElveBehavior elve);
void Awake() { tr = transform; fsm = GetComponent<ElveBehavior>(); }
public ElveState(ElveBehavior owner) { Owner = owner; }