Exemplo n.º 1
0
        private void SaveBaseLayout(PositionMap diffMap)
        {
            if (Service.Get <GameStateMachine>().CurrentState is WarBaseEditorState)
            {
                Service.Get <WarBaseEditController>().SaveWarBaseMap(diffMap);
                return;
            }
            BuildingMultiMoveCommand command = new BuildingMultiMoveCommand(new BuildingMultiMoveRequest
            {
                PositionMap = diffMap
            });

            Service.Get <ServerAPI>().Enqueue(command);
        }
Exemplo n.º 2
0
 private void SaveBaseLayout(PositionMap diffMap)
 {
     if (Service.GameStateMachine.CurrentState is WarBaseEditorState)
     {
         Service.WarBaseEditController.SaveWarBaseMap(diffMap);
     }
     else
     {
         BuildingMultiMoveCommand command = new BuildingMultiMoveCommand(new BuildingMultiMoveRequest
         {
             PositionMap = diffMap
         });
         Service.ServerAPI.Enqueue(command);
     }
 }
Exemplo n.º 3
0
        private void LowerLiftedBuilding(DropKind dropKind, bool affectBoard, bool sendLoweredEvent, bool playLoweredSound, bool showContextButtons)
        {
            SmartEntity selectedBuilding = this.buildingSelector.SelectedBuilding;

            if (selectedBuilding == null)
            {
                this.lifted = false;
                this.moved  = false;
                return;
            }
            UXController uXController = Service.UXController;

            if (dropKind != DropKind.JustDrop)
            {
                uXController.MiscElementsManager.HideConfirmGroup();
            }
            if (affectBoard && dropKind == DropKind.ConfirmPurchase)
            {
                BuildingTypeVO buildingType  = selectedBuilding.BuildingComp.BuildingType;
                int            credits       = buildingType.Credits;
                int            materials     = buildingType.Materials;
                int            contraband    = buildingType.Contraband;
                string         value         = StringUtils.ToLowerCaseUnderscoreSeperated(buildingType.Type.ToString());
                StringBuilder  stringBuilder = new StringBuilder();
                stringBuilder.Append(value);
                stringBuilder.Append("|");
                stringBuilder.Append(buildingType.BuildingID);
                stringBuilder.Append("|");
                stringBuilder.Append(buildingType.Lvl);
                if (PayMeScreen.ShowIfNotEnoughCurrency(credits, materials, contraband, stringBuilder.ToString(), new OnScreenModalResult(this.OnPayMeForCurrencyResult)))
                {
                    return;
                }
                if (buildingType.Type != BuildingType.DroidHut && PayMeScreen.ShowIfNoFreeDroids(new OnScreenModalResult(this.OnPayMeForDroidResult), null))
                {
                    return;
                }
                if (buildingType.Type == BuildingType.NavigationCenter && buildingType.Lvl == 1)
                {
                    Service.UXController.HUD.InitialNavigationCenterPlanetSelect(selectedBuilding, buildingType, new OnScreenModalResult(this.OnPickPlanetResult));
                    return;
                }
            }
            BuildingTypeVO buildingType2 = selectedBuilding.Get <BuildingComponent>().BuildingType;

            if (buildingType2.Time == 0 && dropKind != DropKind.JustDrop)
            {
                showContextButtons = false;
            }
            if (dropKind != DropKind.JustDrop)
            {
                uXController.HUD.ToggleExitEditModeButton(true);
            }
            this.canOccupy = this.EntireSelectionIsPlaceable();
            if (!this.canOccupy)
            {
                this.LiftSelectedBuilding(selectedBuilding, false, false);
                int i     = 0;
                int count = this.buildingSelector.AdditionalSelectedBuildings.Count;
                while (i < count)
                {
                    this.LiftSelectedBuilding(this.buildingSelector.AdditionalSelectedBuildings[i], false, false);
                    i++;
                }
            }
            bool flag   = !this.LowerLiftedBuildingHelper(selectedBuilding, dropKind, affectBoard, sendLoweredEvent, playLoweredSound, showContextButtons, string.Empty);
            int  j      = 0;
            int  count2 = this.buildingSelector.AdditionalSelectedBuildings.Count;

            while (j < count2)
            {
                this.LowerLiftedBuildingHelper(this.buildingSelector.AdditionalSelectedBuildings[j], dropKind, affectBoard, false, false, false, string.Empty);
                j++;
            }
            if (sendLoweredEvent)
            {
                for (int k = 0; k < this.buildingSelector.AdditionalSelectedBuildings.Count; k++)
                {
                    Service.EventManager.SendEvent(EventId.UserLoweredBuilding, this.buildingSelector.AdditionalSelectedBuildings[k]);
                }
                Service.EventManager.SendEvent(EventId.UserLoweredBuilding, flag ? null : selectedBuilding);
            }
            if (affectBoard && dropKind == DropKind.JustDrop && this.ShouldSaveAfterEveryMove())
            {
                BuildingMultiMoveRequest buildingMultiMoveRequest = new BuildingMultiMoveRequest();
                buildingMultiMoveRequest.PositionMap = new PositionMap();
                Position position = new Position();
                position.X = selectedBuilding.Get <TransformComponent>().X;
                position.Z = selectedBuilding.Get <TransformComponent>().Z;
                buildingMultiMoveRequest.PositionMap.AddPosition(selectedBuilding.Get <BuildingComponent>().BuildingTO.Key, position);
                for (int l = 0; l < this.buildingSelector.AdditionalSelectedBuildings.Count; l++)
                {
                    Entity entity = this.buildingSelector.AdditionalSelectedBuildings[l];
                    position   = new Position();
                    position.X = entity.Get <TransformComponent>().X;
                    position.Z = entity.Get <TransformComponent>().Z;
                    buildingMultiMoveRequest.PositionMap.AddPosition(entity.Get <BuildingComponent>().BuildingTO.Key, position);
                }
                BuildingMultiMoveCommand command = new BuildingMultiMoveCommand(buildingMultiMoveRequest);
                Service.ServerAPI.Sync(command);
            }
            if (dropKind == DropKind.ConfirmPurchase || dropKind == DropKind.CancelPurchase)
            {
                Service.EventManager.SendEvent(EventId.BuildingPurchaseModeEnded, null);
            }
        }