Beispiel #1
0
        private BoardCell <Entity> CanConnect(Entity wall)
        {
            if (wall == null)
            {
                return(null);
            }
            BuildingComponent buildingComponent = wall.Get <BuildingComponent>();

            if (buildingComponent == null)
            {
                return(null);
            }
            BuildingTypeVO buildingType = buildingComponent.BuildingType;

            if (buildingType == null)
            {
                return(null);
            }
            if (buildingType.Connectors == null)
            {
                return(null);
            }
            BoardItemComponent boardItemComponent = wall.Get <BoardItemComponent>();

            if (boardItemComponent == null)
            {
                return(null);
            }
            return(boardItemComponent.BoardItem.CurrentCell);
        }
Beispiel #2
0
        public SmartEntity ReplaceBuildingAfterTOChange(SmartEntity building)
        {
            BuildingComponent  buildingComp  = building.BuildingComp;
            Building           buildingTO    = buildingComp.BuildingTO;
            BoardItemComponent boardItemComp = building.BoardItemComp;
            BoardItem          boardItem     = boardItemComp.BoardItem;
            BoardCell          currentCell   = boardItem.CurrentCell;
            int           x             = currentCell.X;
            int           z             = currentCell.Z;
            EntityFactory entityFactory = Service.EntityFactory;
            PostBattleRepairController postBattleRepairController = Service.PostBattleRepairController;

            if (postBattleRepairController.IsEntityInRepair(building))
            {
                postBattleRepairController.RemoveExistingRepair(building);
            }
            SmartEntity smartEntity = entityFactory.CreateBuildingEntity(buildingTO, true, true, true);

            Service.CurrencyEffects.TransferEffects(building, smartEntity);
            Service.MobilizationEffectsManager.TransferEffects(building, smartEntity);
            string uid = buildingTO.Uid;

            buildingTO.Uid = buildingComp.BuildingType.Uid;
            entityFactory.DestroyEntity(building, true, true);
            buildingTO.Uid = uid;
            Service.WorldController.AddBuildingHelper(smartEntity, x, z, true);
            Service.EventManager.SendEvent(EventId.BuildingReplaced, smartEntity);
            return(smartEntity);
        }
Beispiel #3
0
        public BoardCell <Entity> MoveBuildingWithinBoard(Entity building, int boardX, int boardZ)
        {
            BoardController    boardController    = Service.Get <BoardController>();
            BoardItemComponent boardItemComponent = building.Get <BoardItemComponent>();
            BoardItem <Entity> boardItem          = boardItemComponent.BoardItem;
            BuildingComponent  buildingComponent  = building.Get <BuildingComponent>();
            bool checkSkirt = buildingComponent.BuildingType.Type != BuildingType.Blocker;
            BoardCell <Entity> boardCell = boardController.Board.MoveChild(boardItem, boardX, boardZ, building.Get <HealthComponent>(), true, checkSkirt);

            if (boardCell != null)
            {
                TransformComponent transformComponent = building.Get <TransformComponent>();
                transformComponent.X = boardCell.X;
                transformComponent.Z = boardCell.Z;
                DamageableComponent damageableComponent = building.Get <DamageableComponent>();
                if (damageableComponent != null)
                {
                    damageableComponent.Init();
                }
                Building buildingTO = building.Get <BuildingComponent>().BuildingTO;
                buildingTO.SyncWithTransform(transformComponent);
                Service.Get <EventManager>().SendEvent(EventId.BuildingMovedOnBoard, building);
            }
            else
            {
                Service.Get <StaRTSLogger>().ErrorFormat("Failed to move building {0}:{1} to ({2},{3})", new object[]
                {
                    buildingComponent.BuildingTO.Key,
                    buildingComponent.BuildingTO.Uid,
                    boardX,
                    boardZ
                });
            }
            return(boardCell);
        }
        public SmartEntity SpawnTroop(TroopTypeVO troopType, TeamType teamType, IntPosition boardPosition, TroopSpawnMode spawnMode, bool sendPlacedEvent, bool forceAllow)
        {
            Entity             spawnBuilding = null;
            BoardCell <Entity> boardCell     = null;

            if (!this.FinalizeSafeBoardPosition(troopType, ref spawnBuilding, ref boardPosition, ref boardCell, teamType, spawnMode, forceAllow))
            {
                return(null);
            }
            SmartEntity smartEntity = Service.Get <EntityFactory>().CreateTroopEntity(troopType, teamType, boardPosition, spawnBuilding, spawnMode, true, true);

            if (smartEntity == null)
            {
                return(null);
            }
            BoardItemComponent boardItemComp = smartEntity.BoardItemComp;
            BoardItem <Entity> boardItem     = boardItemComp.BoardItem;

            if (Service.Get <BoardController>().Board.AddChild(boardItem, boardCell.X, boardCell.Z, null, false, !forceAllow && troopType.Type != TroopType.Champion) == null)
            {
                return(null);
            }
            Service.Get <EntityController>().AddEntity(smartEntity);
            Service.Get <TroopAbilityController>().OnTroopSpawned(smartEntity);
            if (troopType.Type != TroopType.Champion || teamType == TeamType.Attacker)
            {
                base.EnsureBattlePlayState();
            }
            if (sendPlacedEvent)
            {
                Service.Get <EventManager>().SendEvent(EventId.TroopPlacedOnBoard, smartEntity);
            }
            return(smartEntity);
        }
Beispiel #5
0
        public void RemoveEntity(Entity entity, bool removeSpawnProtection)
        {
            BoardItemComponent boardItemComponent = entity.Get <BoardItemComponent>();

            if (boardItemComponent == null)
            {
                return;
            }
            BuildingComponent buildingComponent = entity.Get <BuildingComponent>();

            this.board.RemoveChild(boardItemComponent.BoardItem, buildingComponent != null && buildingComponent.BuildingType.Type != BuildingType.Blocker, buildingComponent != null);
            if (buildingComponent != null)
            {
                FlagStamp flagStamp = boardItemComponent.BoardItem.FlagStamp;
                if (flagStamp == null)
                {
                    return;
                }
                flagStamp.Clear();
                if (!removeSpawnProtection)
                {
                    uint num = 4u;
                    if (buildingComponent.BuildingType.AllowDefensiveSpawn)
                    {
                        num |= 32u;
                    }
                    flagStamp.Fill(num);
                }
                this.board.AddFlagStamp(flagStamp);
            }
            Service.EventManager.SendEvent(EventId.BuildingRemovedFromBoard, entity);
        }
Beispiel #6
0
        public Entity ReplaceBuildingAfterTOChange(Entity building)
        {
            BuildingComponent  buildingComponent  = building.Get <BuildingComponent>();
            Building           buildingTO         = buildingComponent.BuildingTO;
            BoardItemComponent boardItemComponent = building.Get <BoardItemComponent>();
            BoardItem <Entity> boardItem          = boardItemComponent.BoardItem;
            BoardCell <Entity> currentCell        = boardItem.CurrentCell;
            int           x             = currentCell.X;
            int           z             = currentCell.Z;
            EntityFactory entityFactory = Service.Get <EntityFactory>();
            PostBattleRepairController postBattleRepairController = Service.Get <PostBattleRepairController>();

            if (postBattleRepairController.IsEntityInRepair(building))
            {
                postBattleRepairController.RemoveExistingRepair(building);
            }
            Entity entity = entityFactory.CreateBuildingEntity(buildingTO, true, true, true);

            Service.Get <CurrencyEffects>().TransferEffects(building, entity);
            Service.Get <MobilizationEffectsManager>().TransferEffects(building, entity);
            string uid = buildingTO.Uid;

            buildingTO.Uid = buildingComponent.BuildingType.Uid;
            entityFactory.DestroyEntity(building, true, true);
            buildingTO.Uid = uid;
            Service.Get <WorldController>().AddBuildingHelper(entity, x, z, true);
            Service.Get <EventManager>().SendEvent(EventId.BuildingReplaced, entity);
            return(entity);
        }
Beispiel #7
0
        private bool BuildingIsPlacable(Entity building)
        {
            bool checkSkirt = building.Get <BuildingComponent>().BuildingType.Type != BuildingType.Blocker;
            BoardItemComponent boardItemComponent = building.Get <BoardItemComponent>();
            TransformComponent transformComponent = building.Get <TransformComponent>();

            return(Service.BoardController.Board.CanOccupy(boardItemComponent.BoardItem, transformComponent.X, transformComponent.Z, checkSkirt));
        }
Beispiel #8
0
        public void RemoveEntity(Entity entity, bool removeSpawnProtection)
        {
            BoardItemComponent boardItemComponent = entity.Get <BoardItemComponent>();

            if (boardItemComponent != null)
            {
                Service.Get <BoardController>().RemoveEntity(entity, removeSpawnProtection);
            }
        }
Beispiel #9
0
        private void LiftSelectedBuilding(SmartEntity buildingInSelection, bool sendLiftedEvent, bool clearPreviousAnchorPos)
        {
            this.lifted = true;
            if (buildingInSelection == this.buildingSelector.SelectedBuilding)
            {
                Service.UXController.HUD.ShowContextButtons(buildingInSelection);
            }
            Vector3            grabPoint          = this.buildingSelector.GrabPoint;
            BoardItemComponent boardItemComponent = buildingInSelection.Get <BoardItemComponent>();

            if (boardItemComponent.BoardItem.Filter == CollisionFilters.BUILDING)
            {
                boardItemComponent.BoardItem.Filter = CollisionFilters.BUILDING_GHOST;
            }
            else if (boardItemComponent.BoardItem.Filter == CollisionFilters.TRAP)
            {
                boardItemComponent.BoardItem.Filter = CollisionFilters.TRAP_GHOST;
            }
            else if (boardItemComponent.BoardItem.Filter == CollisionFilters.WALL)
            {
                boardItemComponent.BoardItem.Filter = CollisionFilters.WALL_GHOST;
            }
            else if (boardItemComponent.BoardItem.Filter == CollisionFilters.BLOCKER)
            {
                boardItemComponent.BoardItem.Filter = CollisionFilters.BLOCKER_GHOST;
            }
            else if (boardItemComponent.BoardItem.Filter == CollisionFilters.PLATFORM)
            {
                boardItemComponent.BoardItem.Filter = CollisionFilters.PLATFORM_GHOST;
            }
            this.canOccupy = true;
            if (clearPreviousAnchorPos)
            {
                this.ClearPreviousAnchors();
            }
            TransformComponent transformComp       = this.buildingSelector.SelectedBuilding.TransformComp;
            Vector3            worldGroundPosition = new Vector3(Units.BoardToWorldX(transformComp.X), 0f, Units.BoardToWorldZ(transformComp.Z));

            if (sendLiftedEvent)
            {
                Service.EventManager.SendEvent(EventId.UserLiftedBuilding, buildingInSelection);
                Service.EventManager.SendEvent(EventId.UserLiftedBuildingAudio, buildingInSelection);
            }
            float num;
            float num2;

            EditBaseController.BuildingBoardToWorld(this.buildingSelector.SelectedBuilding, 0, 0, out num, out num2);
            worldGroundPosition.x += num + grabPoint.x;
            worldGroundPosition.z += num2 + grabPoint.z;
            this.MoveLiftedBuilding(buildingInSelection, worldGroundPosition);
            Service.EntityViewManager.SetCollider(buildingInSelection, false);
            this.buildingSelector.ApplySelectedEffect(buildingInSelection);
            Service.BuildingTooltipController.HideBuildingTooltip(buildingInSelection);
        }
Beispiel #10
0
        private bool BuildingCanFit(Entity building)
        {
            bool result = false;

            if (building != null)
            {
                BoardItemComponent boardItemComponent = building.Get <BoardItemComponent>();
                TransformComponent transformComponent = building.Get <TransformComponent>();
                result = Service.BoardController.Board.FitsAt(boardItemComponent.BoardItem, transformComponent.X, transformComponent.Z, 1);
            }
            return(result);
        }
Beispiel #11
0
        public BoardCell <Entity> AddBuildingToBoard(Entity building, int boardX, int boardZ, bool sendEvent)
        {
            BoardItemComponent boardItemComponent = building.Get <BoardItemComponent>();
            BoardItem <Entity> boardItem          = boardItemComponent.BoardItem;
            SizeComponent      size = boardItem.Size;
            BuildingComponent  buildingComponent = building.Get <BuildingComponent>();
            BuildingTypeVO     buildingType      = buildingComponent.BuildingType;
            bool      flag        = buildingType.Type == BuildingType.Clearable || buildingType.Type == BuildingType.Trap || buildingType.Type == BuildingType.ChampionPlatform;
            bool      flag2       = buildingType.Type == BuildingType.Blocker;
            int       walkableGap = flag2 ? 0 : this.CalculateWalkableGap(size);
            FlagStamp flagStamp   = this.CreateFlagStamp(building, buildingType, size, walkableGap);

            if (!flag)
            {
                this.AddUnWalkableUnDestructibleFlags(flagStamp, size, walkableGap, flag2);
            }
            boardItem.FlagStamp = flagStamp;
            BoardController    boardController = Service.Get <BoardController>();
            BoardCell <Entity> boardCell       = boardController.Board.AddChild(boardItem, boardX, boardZ, building.Get <HealthComponent>(), !flag2);

            if (boardCell == null)
            {
                Service.Get <StaRTSLogger>().ErrorFormat("Failed to add building {0}:{1} at ({2},{3})", new object[]
                {
                    buildingComponent.BuildingTO.Key,
                    buildingComponent.BuildingTO.Uid,
                    boardX,
                    boardZ
                });
                return(null);
            }
            TransformComponent transformComponent = building.Get <TransformComponent>();

            transformComponent.X = boardX;
            transformComponent.Z = boardZ;
            DamageableComponent damageableComponent = building.Get <DamageableComponent>();

            if (damageableComponent != null)
            {
                damageableComponent.Init();
            }
            buildingComponent.BuildingTO.SyncWithTransform(transformComponent);
            if (sendEvent)
            {
                Service.Get <EventManager>().SendEvent(EventId.BuildingPlacedOnBoard, building);
            }
            if (buildingType.Type == BuildingType.DroidHut)
            {
                this.DroidHut = building;
            }
            return(boardCell);
        }
Beispiel #12
0
        private SmartEntity CreateWalkerBaseEntity(IntPosition boardPosition, int sizeX, int sizeY)
        {
            Entity             entity    = this.NewEntity();
            int                num       = sizeX / 2;
            TransformComponent component = new TransformComponent(boardPosition.x - num, boardPosition.z - num, 0f, false, sizeX, sizeX);

            entity.Add(component);
            SizeComponent component2 = Units.SizeCompFromGrid(sizeX, sizeY);

            entity.Add(component2);
            BoardItem <Entity> boardItem  = new BoardItem <Entity>(Units.SizeCompFromGrid(1, 1), entity, CollisionFilters.TROOP);
            BoardItemComponent component3 = new BoardItemComponent(boardItem);

            entity.Add(component3);
            return((SmartEntity)entity);
        }
Beispiel #13
0
        private Entity CreateDroid(CivilianTypeVO droidType)
        {
            Entity droidHut = this.GetDroidHut();

            if (droidHut == null)
            {
                return(null);
            }
            TransformComponent transformComponent = droidHut.Get <TransformComponent>();
            IntPosition        position           = new IntPosition(transformComponent.X - 1, transformComponent.Z - 1);
            Entity             entity             = Service.EntityFactory.CreateDroidEntity(droidType, position);
            BoardItemComponent boardItemComponent = entity.Get <BoardItemComponent>();

            Service.BoardController.Board.AddChild(boardItemComponent.BoardItem, position.x, position.z, null, false);
            Service.EntityController.AddEntity(entity);
            return(entity);
        }
Beispiel #14
0
        public bool FindStartingLocation(Entity building, out int boardX, out int boardZ, int cx, int cz, bool stampable)
        {
            BoardItemComponent boardItemComponent = building.Get <BoardItemComponent>();
            BoardItem <Entity> boardItem          = boardItemComponent.BoardItem;
            Board <Entity>     board = Service.Get <BoardController>().Board;

            if (stampable)
            {
                this.ChooseNextStampLocation(ref cx, ref cz);
            }
            bool checkSkirt = building.Get <BuildingComponent>().BuildingType.Type != BuildingType.Blocker;

            if (!board.CanOccupy(boardItem, cx, cz, checkSkirt))
            {
                Rand rand = Service.Get <Rand>();
                if (!stampable)
                {
                    cx += rand.ViewRangeInt(-2, 3) * 1;
                    cz += rand.ViewRangeInt(-2, 3) * 1;
                }
                for (int i = 1; i < 42; i++)
                {
                    int num  = rand.ViewRangeInt(0, 4);
                    int num2 = i;
                    for (int j = 0; j < 4; j++)
                    {
                        int num3 = (j + num) % 4;
                        for (int k = -i; k < i; k++)
                        {
                            int num4 = cx + this.edgeRotations[num3, 0, 0] * num2 + this.edgeRotations[num3, 0, 1] * k;
                            int num5 = cz + this.edgeRotations[num3, 1, 0] * num2 + this.edgeRotations[num3, 1, 1] * k;
                            if (board.CanOccupy(boardItem, num4, num5, checkSkirt))
                            {
                                boardX = num4;
                                boardZ = num5;
                                return(true);
                            }
                        }
                    }
                }
            }
            boardX = cx;
            boardZ = cz;
            return(false);
        }
Beispiel #15
0
        private void SpawnInfantry(ContractEventData contractData)
        {
            SmartEntity smartEntity = this.FindIdleStarport(contractData);

            if (smartEntity == null)
            {
                return;
            }
            Entity             entity             = contractData.Entity;
            TransformComponent transformComponent = entity.Get <TransformComponent>();
            BoardCell          boardCell          = null;
            IntPosition        boardPosition      = new IntPosition(transformComponent.X, transformComponent.Z);
            TroopTypeVO        troopTypeVO        = this.sdc.Get <TroopTypeVO>(contractData.Contract.ProductUid);

            Service.TroopController.FinalizeSafeBoardPosition(troopTypeVO, ref entity, ref boardPosition, ref boardCell, TeamType.Defender, TroopSpawnMode.Unleashed, true);
            SmartEntity        smartEntity2  = Service.EntityFactory.CreateTroopEntity(troopTypeVO, TeamType.Defender, boardPosition, entity, TroopSpawnMode.Unleashed, false, true);
            BoardItemComponent boardItemComp = smartEntity2.BoardItemComp;

            Service.BoardController.Board.AddChild(boardItemComp.BoardItem, boardCell.X, boardCell.Z, null, false);
            Service.EntityController.AddEntity(smartEntity2);
            TroopComponent troopComp      = smartEntity2.TroopComp;
            TeamComponent  teamComp       = smartEntity2.TeamComp;
            bool           flag           = false;
            PathingManager pathingManager = Service.PathingManager;

            pathingManager.StartPathing(smartEntity2, smartEntity, smartEntity2.TransformComp, false, out flag, 0, new PathTroopParams
            {
                TroopWidth            = smartEntity2.SizeComp.Width,
                DPS                   = 0,
                MinRange              = 0u,
                MaxRange              = 2u,
                MaxSpeed              = troopComp.SpeedVO.MaxSpeed,
                PathSearchWidth       = troopComp.TroopType.PathSearchWidth,
                IsMelee               = true,
                IsOverWall            = false,
                IsHealer              = false,
                CrushesWalls          = false,
                IsTargetShield        = false,
                TargetInRangeModifier = troopComp.TroopType.TargetInRangeModifier
            }, new PathBoardParams
            {
                IgnoreWall   = teamComp != null && teamComp.IsDefender(),
                Destructible = false
            }, false, true);
            if (!flag)
            {
                pathingManager.StartPathing(smartEntity2, smartEntity, smartEntity2.TransformComp, false, out flag, 0, new PathTroopParams
                {
                    TroopWidth            = smartEntity2.SizeComp.Width,
                    DPS                   = 0,
                    MinRange              = 0u,
                    MaxRange              = 2u,
                    MaxSpeed              = troopComp.SpeedVO.MaxSpeed,
                    PathSearchWidth       = troopComp.TroopType.PathSearchWidth,
                    IsMelee               = true,
                    IsOverWall            = false,
                    IsHealer              = false,
                    CrushesWalls          = false,
                    IsTargetShield        = false,
                    TargetInRangeModifier = troopComp.TroopType.TargetInRangeModifier
                }, new PathBoardParams
                {
                    IgnoreWall   = true,
                    Destructible = false
                }, false, true);
            }
            smartEntity2.StateComp.CurState = EntityState.Moving;
            bool showFullEffect = true;

            if (this.numTroopEffectsByStarport == null)
            {
                this.numTroopEffectsByStarport = new Dictionary <Entity, int>();
            }
            if (this.numTroopEffectsByStarport.ContainsKey(smartEntity))
            {
                Dictionary <Entity, int> dictionary;
                SmartEntity key;
                int         num;
                (dictionary = this.numTroopEffectsByStarport)[key = smartEntity] = (num = dictionary[key]) + 1;
                if (num >= 10)
                {
                    showFullEffect = false;
                }
            }
            else
            {
                this.numTroopEffectsByStarport.Add(smartEntity, 1);
            }
            if (this.troopEffectsByEntity == null)
            {
                this.troopEffectsByEntity = new Dictionary <Entity, TransportTroopEffect>();
            }
            this.troopEffectsByEntity.Add(smartEntity2, new TransportTroopEffect(smartEntity2, troopTypeVO, smartEntity, this.entityFader, new TransportTroopEffect.OnEffectFinished(this.OnTroopEffectFinished), showFullEffect));
        }
Beispiel #16
0
        private bool LowerLiftedBuildingHelper(SmartEntity buildingInSelection, DropKind dropKind, bool affectBoard, bool sendLoweredEvent, bool playLoweredSound, bool showContextButtons, string tag)
        {
            this.lifted = false;
            this.moved  = false;
            BuildingTypeVO buildingTypeVO = null;
            int            num            = 0;
            int            num2           = 0;

            if ((this.canOccupy || dropKind != DropKind.JustDrop) && this.prevValidBoardAnchorX.ContainsKey(buildingInSelection) && this.prevValidBoardAnchorZ.ContainsKey(buildingInSelection))
            {
                num  = this.prevValidBoardAnchorX[buildingInSelection];
                num2 = this.prevValidBoardAnchorZ[buildingInSelection];
            }
            else if (this.prevValidBoardAnchorX.ContainsKey(buildingInSelection) && this.prevValidBoardAnchorZ.ContainsKey(buildingInSelection))
            {
                num  = this.prevValidBoardAnchorX[buildingInSelection];
                num2 = this.prevValidBoardAnchorZ[buildingInSelection];
            }
            else if (this.buildingSelector.AdditionalSelectedBuildings.Count == 0)
            {
                if (buildingInSelection != null)
                {
                    Service.Logger.Warn("Something went wrong placing " + buildingInSelection.ToString() + " we should not be hitting this case where prevValidBoardAnchorX and prevValidBoardAnchorZ do not contain buildingInSelection");
                }
                else
                {
                    Service.Logger.Warn("Something went wrong, we should not be hitting this case where prevValidBoardAnchorX and prevValidBoardAnchorZ do not contain buildingInSelection");
                }
            }
            if (affectBoard)
            {
                BoardCell boardCell = this.buildingController.OnLowerLiftedBuilding(buildingInSelection, num, num2, dropKind == DropKind.ConfirmPurchase, ref buildingTypeVO, tag);
                if (boardCell == null)
                {
                    this.buildingSelector.DeselectSelectedBuilding();
                    Service.EventManager.SendEvent(EventId.UserLoweredBuilding, buildingInSelection);
                    this.DestroyBuilding(buildingInSelection);
                    return(false);
                }
                BoardItemComponent boardItemComponent = buildingInSelection.Get <BoardItemComponent>();
                if (boardItemComponent.BoardItem.Filter == CollisionFilters.BUILDING_GHOST)
                {
                    boardItemComponent.BoardItem.Filter = CollisionFilters.BUILDING;
                }
                else if (boardItemComponent.BoardItem.Filter == CollisionFilters.TRAP_GHOST)
                {
                    boardItemComponent.BoardItem.Filter = CollisionFilters.TRAP;
                }
                else if (boardItemComponent.BoardItem.Filter == CollisionFilters.WALL_GHOST)
                {
                    boardItemComponent.BoardItem.Filter = CollisionFilters.WALL;
                }
                else if (boardItemComponent.BoardItem.Filter == CollisionFilters.BLOCKER_GHOST)
                {
                    boardItemComponent.BoardItem.Filter = CollisionFilters.BLOCKER;
                }
                else if (boardItemComponent.BoardItem.Filter == CollisionFilters.PLATFORM_GHOST)
                {
                    boardItemComponent.BoardItem.Filter = CollisionFilters.PLATFORM;
                }
                else
                {
                    Service.Logger.ErrorFormat("LowerLiftedBuilding : Unexpected filter type {0}", new object[]
                    {
                        boardItemComponent.BoardItem.Filter
                    });
                    boardItemComponent.BoardItem.Filter = CollisionFilters.BUILDING;
                }
                num  = boardCell.X;
                num2 = boardCell.Z;
            }
            else
            {
                float x;
                float z;
                EditBaseController.BuildingBoardToWorld(this.buildingSelector.SelectedBuilding, num, num2, out x, out z);
                Vector3 worldGroundPosition = new Vector3(x, 0f, z);
                worldGroundPosition.x += this.buildingSelector.GrabPoint.x;
                worldGroundPosition.z += this.buildingSelector.GrabPoint.z;
                this.MoveLiftedBuilding(this.buildingSelector.SelectedBuilding, worldGroundPosition);
            }
            GameObjectViewComponent gameObjectViewComponent = buildingInSelection.Get <GameObjectViewComponent>();

            if (gameObjectViewComponent != null)
            {
                TransformComponent transformComponent = buildingInSelection.Get <TransformComponent>();
                gameObjectViewComponent.SetXYZ(Units.BoardToWorldX(transformComponent.CenterX()), 0f, Units.BoardToWorldZ(transformComponent.CenterZ()));
            }
            Service.EntityViewManager.SetCollider(buildingInSelection, true);
            if (sendLoweredEvent)
            {
                Service.EventManager.SendEvent(EventId.UserLoweredBuilding, buildingInSelection);
            }
            if (playLoweredSound)
            {
                Service.EventManager.SendEvent(EventId.UserLoweredBuildingAudio, buildingInSelection);
            }
            this.buildingSelector.ApplySelectedEffect(buildingInSelection);
            if (buildingTypeVO != null)
            {
                this.buildingController.StartPurchaseBuilding(buildingTypeVO, -1);
            }
            else if (showContextButtons)
            {
                Service.UXController.HUD.ShowContextButtons(buildingInSelection);
            }
            Service.BuildingTooltipController.EnsureBuildingTooltip(buildingInSelection);
            return(true);
        }
Beispiel #17
0
        protected override Entity AddComponentAndDispatchAddEvent(ComponentBase comp, Type compCls)
        {
            bool flag = false;

            if (comp is AreaTriggerComponent)
            {
                this.AreaTriggerComp = (AreaTriggerComponent)comp;
                flag = true;
            }
            if (comp is ArmoryComponent)
            {
                this.ArmoryComp = (ArmoryComponent)comp;
                flag            = true;
            }
            if (comp is AssetComponent)
            {
                this.AssetComp = (AssetComponent)comp;
                flag           = true;
            }
            if (comp is AttackerComponent)
            {
                this.AttackerComp = (AttackerComponent)comp;
                flag = true;
            }
            if (comp is BarracksComponent)
            {
                this.BarracksComp = (BarracksComponent)comp;
                flag = true;
            }
            if (comp is BoardItemComponent)
            {
                this.BoardItemComp = (BoardItemComponent)comp;
                flag = true;
            }
            if (comp is BuildingAnimationComponent)
            {
                this.BuildingAnimationComp = (BuildingAnimationComponent)comp;
                flag = true;
            }
            if (comp is BuildingComponent)
            {
                this.BuildingComp = (BuildingComponent)comp;
                flag = true;
            }
            if (comp is ChampionComponent)
            {
                this.ChampionComp = (ChampionComponent)comp;
                flag = true;
            }
            if (comp is CivilianComponent)
            {
                this.CivilianComp = (CivilianComponent)comp;
                flag = true;
            }
            if (comp is ClearableComponent)
            {
                this.ClearableComp = (ClearableComponent)comp;
                flag = true;
            }
            if (comp is DamageableComponent)
            {
                this.DamageableComp = (DamageableComponent)comp;
                flag = true;
            }
            if (comp is DefenderComponent)
            {
                this.DefenderComp = (DefenderComponent)comp;
                flag = true;
            }
            if (comp is DefenseLabComponent)
            {
                this.DefenseLabComp = (DefenseLabComponent)comp;
                flag = true;
            }
            if (comp is DroidComponent)
            {
                this.DroidComp = (DroidComponent)comp;
                flag           = true;
            }
            if (comp is DroidHutComponent)
            {
                this.DroidHutComp = (DroidHutComponent)comp;
                flag = true;
            }
            if (comp is SquadBuildingComponent)
            {
                this.SquadBuildingComp = (SquadBuildingComponent)comp;
                flag = true;
            }
            if (comp is NavigationCenterComponent)
            {
                this.NavigationCenterComp = (NavigationCenterComponent)comp;
                flag = true;
            }
            if (comp is FactoryComponent)
            {
                this.FactoryComp = (FactoryComponent)comp;
                flag             = true;
            }
            if (comp is CantinaComponent)
            {
                this.CantinaComp = (CantinaComponent)comp;
                flag             = true;
            }
            if (comp is FleetCommandComponent)
            {
                this.FleetCommandComp = (FleetCommandComponent)comp;
                flag = true;
            }
            if (comp is FollowerComponent)
            {
                this.FollowerComp = (FollowerComponent)comp;
                flag = true;
            }
            if (comp is GameObjectViewComponent)
            {
                this.GameObjectViewComp = (GameObjectViewComponent)comp;
                flag = true;
            }
            if (comp is GeneratorComponent)
            {
                this.GeneratorComp = (GeneratorComponent)comp;
                flag = true;
            }
            if (comp is GeneratorViewComponent)
            {
                this.GeneratorViewComp = (GeneratorViewComponent)comp;
                flag = true;
            }
            if (comp is HealerComponent)
            {
                this.HealerComp = (HealerComponent)comp;
                flag            = true;
            }
            if (comp is TroopShieldComponent)
            {
                this.TroopShieldComp = (TroopShieldComponent)comp;
                flag = true;
            }
            if (comp is TroopShieldViewComponent)
            {
                this.TroopShieldViewComp = (TroopShieldViewComponent)comp;
                flag = true;
            }
            if (comp is TroopShieldHealthComponent)
            {
                this.TroopShieldHealthComp = (TroopShieldHealthComponent)comp;
                flag = true;
            }
            if (comp is HealthComponent)
            {
                this.HealthComp = (HealthComponent)comp;
                flag            = true;
            }
            if (comp is HealthViewComponent)
            {
                this.HealthViewComp = (HealthViewComponent)comp;
                flag = true;
            }
            if (comp is HQComponent)
            {
                this.HQComp = (HQComponent)comp;
                flag        = true;
            }
            if (comp is KillerComponent)
            {
                this.KillerComp = (KillerComponent)comp;
                flag            = true;
            }
            if (comp is LootComponent)
            {
                this.LootComp = (LootComponent)comp;
                flag          = true;
            }
            if (comp is MeterShaderComponent)
            {
                this.MeterShaderComp = (MeterShaderComponent)comp;
                flag = true;
            }
            if (comp is OffenseLabComponent)
            {
                this.OffenseLabComp = (OffenseLabComponent)comp;
                flag = true;
            }
            if (comp is PathingComponent)
            {
                this.PathingComp = (PathingComponent)comp;
                flag             = true;
            }
            if (comp is SecondaryTargetsComponent)
            {
                this.SecondaryTargetsComp = (SecondaryTargetsComponent)comp;
                flag = true;
            }
            if (comp is ShieldBorderComponent)
            {
                this.ShieldBorderComp = (ShieldBorderComponent)comp;
                flag = true;
            }
            if (comp is ShieldGeneratorComponent)
            {
                this.ShieldGeneratorComp = (ShieldGeneratorComponent)comp;
                flag = true;
            }
            if (comp is SizeComponent)
            {
                this.SizeComp = (SizeComponent)comp;
                flag          = true;
            }
            if (comp is ShooterComponent)
            {
                this.ShooterComp = (ShooterComponent)comp;
                flag             = true;
            }
            if (comp is StarportComponent)
            {
                this.StarportComp = (StarportComponent)comp;
                flag = true;
            }
            if (comp is StateComponent)
            {
                this.StateComp = (StateComponent)comp;
                flag           = true;
            }
            if (comp is StorageComponent)
            {
                this.StorageComp = (StorageComponent)comp;
                flag             = true;
            }
            if (comp is SupportComponent)
            {
                this.SupportComp = (SupportComponent)comp;
                flag             = true;
            }
            if (comp is SupportViewComponent)
            {
                this.SupportViewComp = (SupportViewComponent)comp;
                flag = true;
            }
            if (comp is TacticalCommandComponent)
            {
                this.TacticalCommandComp = (TacticalCommandComponent)comp;
                flag = true;
            }
            if (comp is ChampionPlatformComponent)
            {
                this.ChampionPlatformComp = (ChampionPlatformComponent)comp;
                flag = true;
            }
            if (comp is TeamComponent)
            {
                this.TeamComp = (TeamComponent)comp;
                flag          = true;
            }
            if (comp is TrackingComponent)
            {
                this.TrackingComp = (TrackingComponent)comp;
                flag = true;
            }
            if (comp is TrackingGameObjectViewComponent)
            {
                this.TrackingGameObjectViewComp = (TrackingGameObjectViewComponent)comp;
                flag = true;
            }
            if (comp is TransformComponent)
            {
                this.TransformComp = (TransformComponent)comp;
                flag = true;
            }
            if (comp is TransportComponent)
            {
                this.TransportComp = (TransportComponent)comp;
                flag = true;
            }
            if (comp is TroopComponent)
            {
                this.TroopComp = (TroopComponent)comp;
                flag           = true;
            }
            if (comp is TurretBuildingComponent)
            {
                this.TurretBuildingComp = (TurretBuildingComponent)comp;
                flag = true;
            }
            if (comp is TurretShooterComponent)
            {
                this.TurretShooterComp = (TurretShooterComponent)comp;
                flag = true;
            }
            if (comp is WalkerComponent)
            {
                this.WalkerComp = (WalkerComponent)comp;
                flag            = true;
            }
            if (comp is WallComponent)
            {
                this.WallComp = (WallComponent)comp;
                flag          = true;
            }
            if (comp is BuffComponent)
            {
                this.BuffComp = (BuffComponent)comp;
                flag          = true;
            }
            if (comp is TrapComponent)
            {
                this.TrapComp = (TrapComponent)comp;
                flag          = true;
            }
            if (comp is TrapViewComponent)
            {
                this.TrapViewComp = (TrapViewComponent)comp;
                flag = true;
            }
            if (comp is HousingComponent)
            {
                this.HousingComp = (HousingComponent)comp;
                flag             = true;
            }
            if (comp is ScoutTowerComponent)
            {
                this.ScoutTowerComp = (ScoutTowerComponent)comp;
                flag = true;
            }
            if (comp is SpawnComponent)
            {
                this.SpawnComp = (SpawnComponent)comp;
                flag           = true;
            }
            if (!flag && compCls != null)
            {
                Service.Logger.Error("Invalid component add: " + compCls.Name);
            }
            return(base.AddComponentAndDispatchAddEvent(comp, compCls));
        }
Beispiel #18
0
 public override object Remove(Type compCls)
 {
     if (compCls == typeof(AreaTriggerComponent))
     {
         this.AreaTriggerComp = null;
     }
     else if (compCls == typeof(ArmoryComponent))
     {
         this.ArmoryComp = null;
     }
     else if (compCls == typeof(AssetComponent))
     {
         this.AssetComp = null;
     }
     else if (compCls == typeof(AttackerComponent))
     {
         this.AttackerComp = null;
     }
     else if (compCls == typeof(BarracksComponent))
     {
         this.BarracksComp = null;
     }
     else if (compCls == typeof(BoardItemComponent))
     {
         this.BoardItemComp = null;
     }
     else if (compCls == typeof(BuildingAnimationComponent))
     {
         this.BuildingAnimationComp = null;
     }
     else if (compCls == typeof(BuildingComponent))
     {
         this.BuildingComp = null;
     }
     else if (compCls == typeof(CantinaComponent))
     {
         this.CantinaComp = null;
     }
     else if (compCls == typeof(ChampionComponent))
     {
         this.ChampionComp = null;
     }
     else if (compCls == typeof(CivilianComponent))
     {
         this.CivilianComp = null;
     }
     else if (compCls == typeof(ClearableComponent))
     {
         this.ClearableComp = null;
     }
     else if (compCls == typeof(DamageableComponent))
     {
         this.DamageableComp = null;
     }
     else if (compCls == typeof(DefenderComponent))
     {
         this.DefenderComp = null;
     }
     else if (compCls == typeof(DefenseLabComponent))
     {
         this.DefenseLabComp = null;
     }
     else if (compCls == typeof(DroidComponent))
     {
         this.DroidComp = null;
     }
     else if (compCls == typeof(DroidHutComponent))
     {
         this.DroidHutComp = null;
     }
     else if (compCls == typeof(SquadBuildingComponent))
     {
         this.SquadBuildingComp = null;
     }
     else if (compCls == typeof(NavigationCenterComponent))
     {
         this.NavigationCenterComp = null;
     }
     else if (compCls == typeof(FactoryComponent))
     {
         this.FactoryComp = null;
     }
     else if (compCls == typeof(FleetCommandComponent))
     {
         this.FleetCommandComp = null;
     }
     else if (compCls == typeof(FollowerComponent))
     {
         this.FollowerComp = null;
     }
     else if (compCls == typeof(GameObjectViewComponent))
     {
         this.GameObjectViewComp = null;
     }
     else if (compCls == typeof(GeneratorComponent))
     {
         this.GeneratorComp = null;
     }
     else if (compCls == typeof(GeneratorViewComponent))
     {
         this.GeneratorViewComp = null;
     }
     else if (compCls == typeof(HealerComponent))
     {
         this.HealerComp = null;
     }
     else if (compCls == typeof(HealthComponent))
     {
         this.HealthComp = null;
     }
     else if (compCls == typeof(TroopShieldComponent))
     {
         this.TroopShieldComp = null;
     }
     else if (compCls == typeof(TroopShieldViewComponent))
     {
         this.TroopShieldViewComp = null;
     }
     else if (compCls == typeof(TroopShieldHealthComponent))
     {
         this.TroopShieldHealthComp = null;
     }
     else if (compCls == typeof(HealthViewComponent))
     {
         this.HealthViewComp = null;
     }
     else if (compCls == typeof(HQComponent))
     {
         this.HQComp = null;
     }
     else if (compCls == typeof(KillerComponent))
     {
         this.KillerComp = null;
     }
     else if (compCls == typeof(LootComponent))
     {
         this.LootComp = null;
     }
     else if (compCls == typeof(MeterShaderComponent))
     {
         this.MeterShaderComp = null;
     }
     else if (compCls == typeof(OffenseLabComponent))
     {
         this.OffenseLabComp = null;
     }
     else if (compCls == typeof(PathingComponent))
     {
         this.PathingComp = null;
     }
     else if (compCls == typeof(SecondaryTargetsComponent))
     {
         this.SecondaryTargetsComp = null;
     }
     else if (compCls == typeof(ShieldBorderComponent))
     {
         this.ShieldBorderComp = null;
     }
     else if (compCls == typeof(ShieldGeneratorComponent))
     {
         this.ShieldGeneratorComp = null;
     }
     else if (compCls == typeof(SizeComponent))
     {
         this.SizeComp = null;
     }
     else if (compCls == typeof(ShooterComponent))
     {
         this.ShooterComp = null;
     }
     else if (compCls == typeof(StarportComponent))
     {
         this.StarportComp = null;
     }
     else if (compCls == typeof(StateComponent))
     {
         this.StateComp = null;
     }
     else if (compCls == typeof(StorageComponent))
     {
         this.StorageComp = null;
     }
     else if (compCls == typeof(SupportComponent))
     {
         this.SupportComp = null;
     }
     else if (compCls == typeof(SupportViewComponent))
     {
         this.SupportViewComp = null;
     }
     else if (compCls == typeof(TacticalCommandComponent))
     {
         this.TacticalCommandComp = null;
     }
     else if (compCls == typeof(ChampionPlatformComponent))
     {
         this.ChampionPlatformComp = null;
     }
     else if (compCls == typeof(TeamComponent))
     {
         this.TeamComp = null;
     }
     else if (compCls == typeof(TrackingComponent))
     {
         this.TrackingComp = null;
     }
     else if (compCls == typeof(TrackingGameObjectViewComponent))
     {
         this.TrackingGameObjectViewComp = null;
     }
     else if (compCls == typeof(TransformComponent))
     {
         this.TransformComp = null;
     }
     else if (compCls == typeof(TransportComponent))
     {
         this.TransportComp = null;
     }
     else if (compCls == typeof(TroopComponent))
     {
         this.TroopComp = null;
     }
     else if (compCls == typeof(TurretBuildingComponent))
     {
         this.TurretBuildingComp = null;
     }
     else if (compCls == typeof(TurretShooterComponent))
     {
         this.TurretShooterComp = null;
     }
     else if (compCls == typeof(WalkerComponent))
     {
         this.WalkerComp = null;
     }
     else if (compCls == typeof(WallComponent))
     {
         this.WallComp = null;
     }
     else if (compCls == typeof(BuffComponent))
     {
         this.BuffComp = null;
     }
     else if (compCls == typeof(TrapComponent))
     {
         this.TrapComp = null;
     }
     else if (compCls == typeof(TrapViewComponent))
     {
         this.TrapViewComp = null;
     }
     else if (compCls == typeof(HousingComponent))
     {
         this.HousingComp = null;
     }
     else if (compCls == typeof(SpawnComponent))
     {
         this.SpawnComp = null;
     }
     return(base.Remove(compCls));
 }