public override int Execute(LogicLevel level) { LogicGameObject gameObject = level.GetGameObjectManager().GetGameObjectByID(this.m_gameObjectId); if (gameObject != null && gameObject.GetGameObjectType() == LogicGameObjectType.BUILDING) { if (gameObject.GetVillageType() == level.GetVillageType()) { LogicResourceProductionComponent resourceProductionComponent = gameObject.GetResourceProductionComponent(); if (resourceProductionComponent != null) { if (LogicDataTables.GetGlobals().CollectAllResourcesAtOnce()) { int baseAvailableResources = resourceProductionComponent.GetResourceCount(); int baseCollectedResources = resourceProductionComponent.CollectResources(true); bool storageIsFull = baseAvailableResources > 0 && baseCollectedResources == 0; LogicArrayList <LogicComponent> components = level.GetComponentManager().GetComponents(resourceProductionComponent.GetComponentType()); for (int i = 0; i < components.Size(); i++) { LogicResourceProductionComponent component = (LogicResourceProductionComponent)components[i]; if (resourceProductionComponent != component && resourceProductionComponent.GetResourceData() == component.GetResourceData()) { int availableResources = component.GetResourceCount(); int collectedResources = component.CollectResources(!storageIsFull); if (availableResources > 0) { if (collectedResources == 0) { storageIsFull = true; } } } } } else { resourceProductionComponent.CollectResources(true); } return(0); } return(-1); } return(-3); } return(-2); }
/// <summary> /// Executes this command. /// </summary> public override int Execute(LogicLevel level) { LogicGameObject gameObject = level.GetGameObjectManager().GetGameObjectByID(this._gameObjectId); if (gameObject != null) { int gameObjectType = gameObject.GetGameObjectType(); if (gameObjectType <= 6 && gameObjectType != 3) { if (gameObjectType != 0 || ((LogicBuildingData)gameObject.GetData()).GetVillageType() == level.GetVillageType()) { if (gameObjectType == 0) { if (((LogicBuilding)gameObject).GetWallIndex() != 0) { return(-21); } } int x = gameObject.GetTileX(); int y = gameObject.GetTileY(); int width = gameObject.GetWidthInTiles(); int height = gameObject.GetHeightInTiles(); if (gameObject.GetVillageType() != 0) { for (int i = 0; i < width; i++) { for (int j = 0; j < height; j++) { LogicObstacle tallGrass = level.GetTileMap().GetTile(x + i, y + j).GetTallGrass(); if (tallGrass != null) { level.GetGameObjectManager().RemoveGameObject(tallGrass); } } } } if (level.IsValidPlaceForBuilding(this._x, this._y, width, height, gameObject)) { gameObject.SetPositionXY(this._x << 9, this._y << 9); if (this._x != x || this._y != y) { if (level.GetHomeOwnerAvatar() != null) { LogicAvatar homeOwnerAvatar = level.GetHomeOwnerAvatar(); if (homeOwnerAvatar.GetTownHallLevel() >= LogicDataTables.GetGlobals().GetChallengeBaseCooldownTownHall()) { level.SetLayoutCooldownSecs(level.GetActiveLayout(level.GetVillageType()), LogicDataTables.GetGlobals().GetChallengeBaseSaveCooldown()); } } } return(0); } return(-3); } return(-32); } return(-1); } return(-2); }