コード例 #1
0
 private void AddAllLoweredFootprints()
 {
     if (this.loweredFootprint == null)
     {
         this.loweredFootprint = new Footprint("Lowered Footprint", 3f);
         BuildingController      buildingController = Service.Get <BuildingController>();
         NodeList <BuildingNode> nodeList           = Service.Get <EntityController>().GetNodeList <BuildingNode>();
         for (BuildingNode buildingNode = nodeList.Head; buildingNode != null; buildingNode = buildingNode.Next)
         {
             SmartEntity smartEntity = (SmartEntity)buildingNode.Entity;
             if (!buildingController.IsLifted(smartEntity) && !Service.Get <BaseLayoutToolController>().IsBuildingStashed(smartEntity))
             {
                 this.AddLoweredFootprint(smartEntity);
             }
         }
         if (buildingController.IsPurchasing && !buildingController.IsLifted(buildingController.PurchasingBuilding))
         {
             this.AddLoweredFootprint((SmartEntity)buildingController.PurchasingBuilding);
         }
         bool allowErrorThrown = true;
         if (Service.Get <BaseLayoutToolController>().IsBaseLayoutModeActive)
         {
             allowErrorThrown = false;
         }
         this.loweredFootprint.GenerateMesh(true, false, allowErrorThrown);
     }
 }
コード例 #2
0
        private bool CanPlaceAllRewardBuildings(string[] rewardBuildings)
        {
            bool result = true;
            BuildingController buildingController = Service.Get <BuildingController>();
            int i   = 0;
            int num = rewardBuildings.Length;

            while (i < num)
            {
                string[] array = rewardBuildings[i].Split(new char[]
                {
                    ':'
                });
                int            num2     = Convert.ToInt32(array[1], CultureInfo.InvariantCulture);
                string         uid      = array[0];
                BuildingTypeVO optional = Service.Get <IDataController>().GetOptional <BuildingTypeVO>(uid);
                if (optional != null)
                {
                    for (int j = 0; j < num2; j++)
                    {
                        if (!buildingController.FoundFirstEmptySpaceFor(optional))
                        {
                            result = false;
                            break;
                        }
                    }
                }
                i++;
            }
            return(result);
        }
コード例 #3
0
        public void StampUnstashBuildingByUID(string buildingUID)
        {
            BuildingController buildingController = Service.Get <BuildingController>();
            Entity             selectedBuilding   = buildingController.SelectedBuilding;
            BoardCell <Entity> currentCell        = selectedBuilding.Get <BoardItemComponent>().BoardItem.CurrentCell;

            buildingController.SaveLastStampLocation(currentCell.X, currentCell.Z);
            if (this.IsListOutOfGivenBuilding(buildingUID))
            {
                buildingController.DisableUnstashStampingState();
                return;
            }
            this.UnstashBuildingByUID(buildingUID, false, true, true, true);
        }
コード例 #4
0
        public void UnstashBuildingByUID(string buildingUID, bool returnToOriginalPosition, bool stampable, bool panToBuilding, bool playLoweredSound)
        {
            if (this.stashedBuildingMap == null)
            {
                return;
            }
            if (!this.stashedBuildingMap.ContainsKey(buildingUID) || this.stashedBuildingMap[buildingUID].Count < 1)
            {
                Service.Logger.Error("Can't unstash! No buildings of : " + buildingUID + " currently stashed");
                return;
            }
            List <SmartEntity> list         = this.stashedBuildingMap[buildingUID];
            SmartEntity        smartEntity  = list[0];
            BuildingComponent  buildingComp = smartEntity.BuildingComp;
            bool flag = false;

            if (stampable && this.IsBuildingStampable(smartEntity))
            {
                flag = true;
            }
            Position pos = null;

            if (returnToOriginalPosition)
            {
                pos = this.lastSavedMap.GetPosition(buildingComp.BuildingTO.Key);
                if (flag)
                {
                    flag = false;
                    Service.Logger.Warn("No stamping while reverting!!");
                }
            }
            BuildingController      buildingController      = Service.BuildingController;
            GameObjectViewComponent gameObjectViewComponent = smartEntity.Get <GameObjectViewComponent>();
            TransformComponent      transformComponent      = smartEntity.Get <TransformComponent>();

            if (gameObjectViewComponent != null)
            {
                gameObjectViewComponent.SetXYZ(Units.BoardToWorldX(transformComponent.CenterX()), 0f, Units.BoardToWorldZ(transformComponent.CenterZ()));
            }
            if (smartEntity.Has <HealthViewComponent>())
            {
                HealthViewComponent healthViewComponent = smartEntity.Get <HealthViewComponent>();
                healthViewComponent.SetupElements();
            }
            List <SmartEntity> list2 = this.stashedBuildingMap[buildingUID];

            if (list2.Contains(smartEntity))
            {
                list2.Remove(smartEntity);
                if (!buildingController.PositionUnstashedBuilding(smartEntity, pos, flag, panToBuilding, playLoweredSound))
                {
                    Service.Logger.ErrorFormat("Unable to place building from stash.  Building {0} {1}", new object[]
                    {
                        smartEntity.Get <BuildingComponent>().BuildingTO.Key,
                        smartEntity.Get <BuildingComponent>().BuildingType.Uid
                    });
                    Service.UXController.MiscElementsManager.ShowPlayerInstructionsError(Service.Lang.Get("NO_VALID_POSITION_FOR_UNSTASH", new object[0]));
                    this.StashBuilding(smartEntity);
                }
            }
        }