public IEnumerable <Act.Status> SummonSkeleton(Body grave) { if (grave.IsDead) { yield return(Act.Status.Fail); } SummonSkeleton(grave.Position); grave.Die(); yield return(Act.Status.Success); }
public IEnumerable <Act.Status> SummonSkeleton(Body grave) { if (grave.IsDead) { SetMessage("Failed to summon skeleton: grave is nonexistent."); yield return(Act.Status.Fail); } SummonSkeleton(grave.Position); grave.Die(); yield return(Act.Status.Success); }
public override IEnumerable <Status> Run() { if (!Creature.Faction.WallBuilder.IsDesignation(Voxel)) { yield return(Status.Fail); yield break; } foreach (Status status in Creature.HitAndWait(1.0f, true)) { if (status == Status.Running) { yield return(status); } } Body grabbed = Creature.Inventory.RemoveAndCreate(Resource).FirstOrDefault(); if (grabbed == null) { yield return(Status.Fail); yield break; } else { if (Creature.Faction.WallBuilder.IsDesignation(Voxel)) { TossMotion motion = new TossMotion(1.0f, 2.0f, grabbed.LocalTransform, Voxel.Position + new Vector3(0.5f, 0.5f, 0.5f)); motion.OnComplete += grabbed.Die; grabbed.AnimationQueue.Add(motion); WallBuilder put = Creature.Faction.WallBuilder.GetDesignation(Voxel); put.Put(PlayState.ChunkManager); Creature.Faction.WallBuilder.Designations.Remove(put); Creature.Stats.NumBlocksPlaced++; Creature.AI.AddXP(1); yield return(Status.Success); } else { Creature.Inventory.Resources.AddItem(grabbed); grabbed.Die(); yield return(Status.Fail); } } }
public void GatherImmediately(Body item, Inventory.RestockType restockType = Inventory.RestockType.None) { if (item is CoinPile) { var money = (item as CoinPile).Money; AI.AddMoney(money); item.Die(); AI.GatherManager.StockMoneyOrders.Add(new GatherManager.StockMoneyOrder() { Destination = null, Money = money }); } else { Inventory.Pickup(item, restockType); } }
public override bool AddItem(Body component) { bool worked = base.AddItem(component); HandleBoxes(); if (Boxes.Count > 0) { TossMotion toss = new TossMotion(1.0f, 2.5f, component.LocalTransform, Boxes[Boxes.Count - 1].LocalTransform.Translation + new Vector3(0.5f, 0.5f, 0.5f)); component.GetRoot().GetComponent <Physics>().CollideMode = Physics.CollisionMode.None; component.AnimationQueue.Add(toss); toss.OnComplete += component.Die; } else { component.Die(); } return(worked); }
void toss_OnComplete(Body entity) { entity.Die(); }
public override IEnumerable <Status> Run() { if (!Creature.Faction.WallBuilder.IsDesignation(Voxel)) { yield return(Status.Fail); yield break; } foreach (Status status in Creature.HitAndWait(1.0f, true, Voxel.Position)) { if (status == Status.Running) { yield return(status); } } Body grabbed = Creature.Inventory.RemoveAndCreate(Resource).FirstOrDefault(); if (grabbed == null) { yield return(Status.Fail); yield break; } else { if (Creature.Faction.WallBuilder.IsDesignation(Voxel)) { // If the creature intersects the box, find a voxel adjacent to it that is free, and jump there to avoid getting crushed. if (Creature.Physics.BoundingBox.Intersects(Voxel.GetBoundingBox())) { List <Voxel> neighbors = Voxel.Chunk.GetNeighborsEuclidean(Voxel); Voxel closest = null; float closestDist = float.MaxValue; foreach (Voxel voxel in neighbors) { float dist = (voxel.Position - Creature.Physics.Position).LengthSquared(); if (dist < closestDist && voxel.IsEmpty) { closestDist = dist; closest = voxel; } } if (closest != null) { TossMotion teleport = new TossMotion(0.5f, 1.0f, Creature.Physics.GlobalTransform, closest.Position + Vector3.One * 0.5f); Creature.Physics.AnimationQueue.Add(teleport); } } TossMotion motion = new TossMotion(1.0f, 2.0f, grabbed.LocalTransform, Voxel.Position + new Vector3(0.5f, 0.5f, 0.5f)); motion.OnComplete += grabbed.Die; grabbed.GetComponent <Physics>().CollideMode = Physics.CollisionMode.None; grabbed.AnimationQueue.Add(motion); WallBuilder put = Creature.Faction.WallBuilder.GetDesignation(Voxel); put.Put(Creature.Manager.World.ChunkManager); Creature.Faction.WallBuilder.Designations.Remove(put); Creature.Stats.NumBlocksPlaced++; Creature.AI.AddXP(1); yield return(Status.Success); } else { Creature.Inventory.Resources.AddItem(grabbed); grabbed.Die(); yield return(Status.Fail); } } }