public IEnumerator WorkWithVillage(VillageInteraction interaction) { VillageBody village = EntityManager.EntityHash[interaction.VillageID] as VillageBody; if (village == null || DistanceTo(village) > GameManager.Instance.Config.MaxInteractionDistance) { return(Wait(new AiProtocol.Command.Wait())); } if (interaction is MagazinePush) { return(MagazinePush(village, interaction as MagazinePush)); } else if (interaction is MagazinePull) { return(MagazinePull(village, interaction as MagazinePull)); } else if (interaction is Procreate) { return(Procreate(village, interaction as Procreate)); } else if (interaction is PickTool) { return(PickTool(village, interaction as PickTool)); } else { throw new ArgumentOutOfRangeException(); } }
IEnumerator Procreate(VillageBody village, Procreate procreate) { CurrentCommand = procreate; IsSneaking = false; yield return(WaitWithProgress(2f)); village.PutGeneticMaterial(this); CurrentCommand = null; }
IEnumerator MagazinePull(VillageBody village, MagazinePull pull) { CurrentCommand = pull; IsSneaking = false; yield return(WaitWithProgress(0.5f)); village.MagazinePull(pull.Type, this); CurrentCommand = null; }
IEnumerator PickTool(VillageBody village, PickTool pickTool) { CurrentCommand = pickTool; IsSneaking = false; yield return(WaitWithProgress(1f)); SetToolActive(Tool, false); Tool = pickTool.Tool; ToolLevel = village.ToolLevel(Tool); SetToolActive(Tool, true); CurrentCommand = null; }
IEnumerator MagazinePush(VillageBody village, MagazinePush push) { EntityBody PushTarget = EntityManager.EntityHash[push.TargetID]; CurrentCommand = push; IsSneaking = false; yield return(WaitWithProgress(0.5f)); if (!Equipment.Contains(PushTarget)) { yield break; } if (!village.WillAccept(PushTarget)) { yield break; } RemoveFromEq(PushTarget); village.MagazinePush(PushTarget); CurrentCommand = null; }