Esempio n. 1
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);
        }
Esempio n. 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);
        }