public static bool Execute(UnitOrder order) { //Debug.Log("Executing to pos - " + order.GetTo().Index); var index = ChunkUtil.GetUpper(order.GetTo().Index); var chunkNumber = order.GetUnit().ChunkNumber; var chunk = ChunkManager.GetChunkByNum(chunkNumber); if (order.GetUnit().CurrentPos != index && ChunkUtil.IsAnyEntity(chunkNumber, index)) { var obj = chunk.GetGameObjectByIndex(index); if (obj == null) { return(GameMoveManager.CancelPathVVay(order.GetUnit())); //return false; } var underEnt = obj.GetComponent <GameEntity>(); if (underEnt.Owner != order.GetUnit().Owner) { return(AttackTo(order)); } //Debug.Log("Cancel attacking"); return(GameMoveManager.CancelPathVVay(order.GetUnit())); //return false; } //Debug.Log("Moving to: " + order.GetTo().Index); return(MoveExecutor.Execute(order)); }
void FixedUpdate() { if (PauseMenu_HTML.IsPaused || GroupUtil.IsNeutral(Group)) { return; } foreach (var ab in AbilityList) { ab.Update(); } GameMoveManager.OnMoveUpdate(this); if (Group == "" || !GroupUtil.isCreatureGroup(Group) || GroupUtil.IsNeutral(Group) || Owner == PlayersManager.GetMyPlayer() ) { return; } AI_Main.Update(this); }
public static void InitLibraries(LuaVM vm) { UnityOs.InitLuaModule(vm); ModifiersManager.InitLuaModule(); ChunkFinder.InitLuaModule(); SimpleOrderManager.InitLuaModule(); GameMoveManager.InitLuaModule(); AI_Calculation.InitLuaModule(); PathCalcManager.InitLuaModule(); FlagManager.InitLuaModule(); ProgressUnitBar.InitLuaModule(); LuaChunkManager.InitLuaModule(); ErrorBar_HTML.InitLuaModule(); LuaHelper.InitLuaModule(); ResearchManager.InitLuaModule(); }
public override void KillSelf() { if (Destroyed) { return; } var chunk = ChunkManager.GetChunkByNum(ChunkNumber); chunk.SetIndex(CurrentPos, -1); chunk.RemoveObject(CurrentPos); if (pickUped != null) { ItemEvents.OnDeathDropItem(pickUped, this); } ClickManager.RemoveChosing(gameObject); GameMoveManager.CancelAllOrders(this); if (GroupUtil.isCreatureGroup(Group)) { GameOrderManager.RemoveMarks(this); //SimpleOrderManager.CancelOrders(this); if (MovingPath != null) { MovingPath.Clear(); } } if (SecondaryGroundLvL.isSecondaryGroup(Group)) { SecondaryGroundLvL.RemovePos(ChunkNumber, CurrentPos); } if (FlagManager.IsFlagAtPos(CurrentPos)) { FlagManager.RemoveFlag(CurrentPos); } ProgressUnitBar.RemoveProgressBar(this); CreatureGroupManager.RemoveEntFromGroup(this); BuildingsGroupManager.RemoveBuildingFromGroup(this); RemoveAbilities(); if (research != null) { var sameBuilds = BuildingsGroupManager.GetAllInChunkWithName(ChunkNumber, OriginalName); if (sameBuilds.Count == 0) { Owner.RemoveResearch(research); } } Coloring.RecolorObject(ChunkUtil.GetDovvner(CurrentPos)); Owner.foodCount -= foodCost; Owner.foodMax -= foodGive; if (gameObject != null) { Destroy(gameObject); } Destroyed = true; }