Пример #1
0
    //----------------------------------------------------------------------------
    // Init player
    //----------------------------------------------------------------------------
    private void Awake()
    {
        // Assert required components
        LootComponent lootComponent = GetComponent <LootComponent>();

        Debug.Assert(lootComponent != null, "You haven't assign loot component to the player!");

        CannonComponent cannonComponent = GetComponent <CannonComponent>();

        Debug.Assert(cannonComponent != null, "You haven't assign cannon component to the player!");

        Debug.Assert(m_manager != null, "You haven't assign gameplay manager to the player.");

        Debug.Assert(m_respawnObject != null, "You haven't assign respawn object to the player.");

        // Upgrades
        ResetUpgrades();
        m_characterRadius = GetComponent <CapsuleCollider>().radius;
        m_characterHeight = GetComponent <CapsuleCollider>().height;
        m_characterCenter = GetComponent <CapsuleCollider>().center;

        // Init Data
        score                = 0;
        m_stamina            = GetComponent <Invector.vCharacterController.vActions.vSwimming>().stamina;
        m_characterSwimSpeed = GetComponent <Invector.vCharacterController.vActions.vSwimming>().swimForwardSpeed;
    }
Пример #2
0
    //----------------------------------------------------------------------------
    // Collision detected enter trigger
    //----------------------------------------------------------------------------
    protected void OnTriggerEnter(Collider other)
    {
        Player player = other.gameObject.GetComponent <Player>();

        if (player != null &&                                                                                         // Collier is player
            (player.GetComponent <LootComponent>().GetLootCount() < player.GetComponent <LootComponent>().m_maxLoot)) // Player's current loot count has not hit max loot yet
        {
            if (m_LootType == LootType.Treasure)
            {
                LootComponent playerLootComponent = player.GetComponent <LootComponent>();
                if (playerLootComponent != null)
                {
                    playerLootComponent.Loot(m_value);
                    Destroy(this.gameObject);                            // Kill this loot object
                }
            }
            else
            {
                CannonComponent playerCannonComponent = player.GetComponent <CannonComponent>();
                if (playerCannonComponent != null)
                {
                    playerCannonComponent.AddCannon(m_value);
                    Destroy(this.gameObject);                            // Kill this loot object
                }
            }
        }
    }
Пример #3
0
        private void EarnLootFromDeath(LootComponent lootComp)
        {
            int i   = 0;
            int num = 6;

            while (i < num)
            {
                this.lootEarned[i] += lootComp.LootQuantities[i];
                i++;
            }
        }
Пример #4
0
        private void EarnCalculatedLoot(LootComponent lootComp, int damagePercent)
        {
            if (damagePercent == 100)
            {
                this.EarnLootFromDeath(lootComp);
                return;
            }
            int i   = 0;
            int num = 6;

            while (i < num)
            {
                int maxLoot = lootComp.LootQuantities[i];
                this.lootEarned[i] += this.CalculateLootFromDamagePercentage(damagePercent, maxLoot);
                i++;
            }
        }
Пример #5
0
        public void UpdateLootOnHealthChange(Entity entity, HealthComponent healthComp, int delta)
        {
            if (delta == 0)
            {
                return;
            }
            LootComponent lootComponent = entity.Get <LootComponent>();

            if (lootComponent == null || delta == 0)
            {
                return;
            }
            if (healthComp.IsDead())
            {
                return;
            }
            this.EarnLootFromDamage(lootComponent, healthComp, delta);
            Service.EventManager.SendEvent(EventId.LootEarnedUpdated, lootComponent);
        }
Пример #6
0
    //----------------------------------------------------------------------------
    // On dead
    //  - Lose all loot in ship’s hold
    //  - Lose all upgrades
    //  - Respawn at Pirate Island
    //----------------------------------------------------------------------------
    public void OnDead()
    {
        m_drivingShip.OnPlayerDead();
        GetOffShip();

        // Lose loot
        LootComponent lootComponent = GetComponent <LootComponent>();

        lootComponent.Clear();

        // Lose all upgrades
        ResetUpgrades();
        GetComponent <CannonComponent>().ResetUpgrades();
        GetComponent <LootComponent>().ResetUpgrades();
        m_manager.ResetUpgrades();

        // Respawn at pirate island
        GetComponent <Transform>().position = m_respawnObject.GetComponent <Transform>().position;
        GetComponent <HealthComponent>().RecoverToFullHealth();
    }
Пример #7
0
        public EatResponse OnEvent(EventId id, object cookie)
        {
            if (id != EventId.EntityKilled)
            {
                return(EatResponse.NotEaten);
            }
            Entity entity = cookie as Entity;

            if (entity == null)
            {
                return(EatResponse.NotEaten);
            }
            LootComponent     lootComponent     = entity.Get <LootComponent>();
            BuildingComponent buildingComponent = entity.Get <BuildingComponent>();

            if (lootComponent == null)
            {
                return(EatResponse.NotEaten);
            }
            if (this.deadLootedEntities.ContainsKey(buildingComponent.BuildingTO.Key))
            {
                Service.Logger.ErrorFormat("Entity {0} reported dead twice to LootController.", new object[]
                {
                    buildingComponent.BuildingTO.Key
                });
                return(EatResponse.NotEaten);
            }
            if (string.IsNullOrEmpty(buildingComponent.BuildingTO.Key))
            {
                Service.Logger.Error("Recieved dead building with invalid BuildingTO Key!");
                return(EatResponse.NotEaten);
            }
            this.deadLootedEntities[buildingComponent.BuildingTO.Key] = lootComponent;
            this.RefreshEarnedLoot();
            return(EatResponse.NotEaten);
        }
Пример #8
0
        private void EarnLootFromDamage(LootComponent lootComp, HealthComponent healthComp, int healthDelta)
        {
            int num  = 0;
            int i    = 0;
            int num2 = 6;

            while (i < num2)
            {
                int num3 = lootComp.LootQuantities[i];
                if (num3 != 0)
                {
                    int num4          = GameUtils.CalculateDamagePercentage(healthComp.Health - healthDelta, healthComp.MaxHealth);
                    int num5          = GameUtils.CalculateDamagePercentage(healthComp);
                    int damagePercent = num5 - num4;
                    int num6          = this.CalculateLootFromDamagePercentage(damagePercent, num3);
                    this.lootEarned[i] += num6;
                    Service.CurrencyEffects.PlayEffect(lootComp.Entity, (CurrencyType)i, num6);
                    lootComp.IncParticleCount();
                    num++;
                }
                i++;
            }
            Service.EventManager.SendEvent(EventId.LootEarnedUpdated, healthComp.Entity);
        }
Пример #9
0
 void Awake()
 {
     m_playerLoot          = m_player.GetComponent <LootComponent>();
     m_playerUpgradeScript = m_player.GetComponent <Player>();
 }
Пример #10
0
 void Awake()
 {
     m_playerLoot       = m_player.GetComponent <LootComponent>();
     m_playerShipHealth = m_player.GetComponent <HealthComponent>();
 }
Пример #11
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));
 }
Пример #12
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));
        }
Пример #13
0
        private SmartEntity CreateBuildingEntity(BuildingTypeVO buildingType, Building building, bool createCollider, bool requestAsset, bool addSupport)
        {
            int           x           = building.X;
            int           z           = building.Z;
            bool          flag        = buildingType.Type == BuildingType.Blocker;
            SmartEntity   smartEntity = this.NewEntity();
            TeamComponent component   = new TeamComponent(TeamType.Defender);

            smartEntity.Add(component);
            int num = 0;

            if (!flag && buildingType.SizeX > 1 && buildingType.SizeY > 1)
            {
                num = 1;
            }
            TransformComponent transformComponent = new TransformComponent(Units.GridToBoardX(x), Units.GridToBoardZ(z), 1.57079637f, true, Units.GridToBoardX(buildingType.SizeX - num), Units.GridToBoardZ(buildingType.SizeY - num));

            smartEntity.Add(transformComponent);
            SizeComponent sizeComponent = Units.SizeCompFromGrid(buildingType.SizeX, buildingType.SizeY);

            smartEntity.Add(sizeComponent);
            if (buildingType.Type != BuildingType.Clearable)
            {
                smartEntity.Add(new DamageableComponent(transformComponent));
            }
            BuildingComponent buildingComponent = new BuildingComponent(buildingType, building);

            smartEntity.Add(buildingComponent);
            smartEntity.Add(new BuffComponent());
            smartEntity.Add(new HealthViewComponent());
            FilterComponent filter = CollisionFilters.BUILDING;

            if (buildingType.Type == BuildingType.Trap)
            {
                filter = CollisionFilters.TRAP;
            }
            else if (buildingType.Type == BuildingType.Wall)
            {
                filter = CollisionFilters.WALL;
            }
            else if (buildingType.Type == BuildingType.Clearable)
            {
                filter = CollisionFilters.CLEARABLE;
            }
            else if (buildingType.Type == BuildingType.ChampionPlatform)
            {
                filter = CollisionFilters.PLATFORM;
            }
            BoardItem <Entity> boardItem = new BoardItem <Entity>(sizeComponent, smartEntity, filter);

            smartEntity.Add(new BoardItemComponent(boardItem));
            if (buildingType.Type == BuildingType.Turret)
            {
                TurretTypeVO turretType = Service.Get <IDataController>().Get <TurretTypeVO>(buildingType.TurretUid);
                this.AddTurretComponentsToEntity(smartEntity, turretType);
            }
            if (buildingType.Type == BuildingType.Trap)
            {
                this.AddTrapComponentsToEntity(smartEntity, buildingType);
            }
            if (buildingType.Type == BuildingType.ShieldGenerator)
            {
                this.AddShieldComponentsToEntity(smartEntity, buildingType);
            }
            HealthComponent component2 = new HealthComponent(buildingType.Health, buildingComponent.BuildingType.ArmorType);

            smartEntity.Add(component2);
            if (addSupport)
            {
                smartEntity.Add <SupportComponent>(new SupportComponent());
            }
            if (buildingType.Type == BuildingType.ChampionPlatform)
            {
                smartEntity.Add <ChampionPlatformComponent>(new ChampionPlatformComponent());
            }
            if (buildingType.Type == BuildingType.Housing)
            {
                smartEntity.Add <HousingComponent>(new HousingComponent());
            }
            switch (buildingType.Type)
            {
            case BuildingType.HQ:
                smartEntity.Add <HQComponent>(new HQComponent());
                break;

            case BuildingType.Barracks:
                smartEntity.Add <BarracksComponent>(new BarracksComponent());
                break;

            case BuildingType.Factory:
                smartEntity.Add <FactoryComponent>(new FactoryComponent());
                break;

            case BuildingType.FleetCommand:
                smartEntity.Add <FleetCommandComponent>(new FleetCommandComponent());
                break;

            case BuildingType.HeroMobilizer:
                smartEntity.Add <TacticalCommandComponent>(new TacticalCommandComponent());
                break;

            case BuildingType.Squad:
                smartEntity.Add <SquadBuildingComponent>(new SquadBuildingComponent());
                break;

            case BuildingType.Starport:
                smartEntity.Add <StarportComponent>(new StarportComponent());
                break;

            case BuildingType.DroidHut:
                smartEntity.Add <DroidHutComponent>(new DroidHutComponent());
                break;

            case BuildingType.Wall:
                smartEntity.Add <WallComponent>(new WallComponent());
                break;

            case BuildingType.Turret:
                smartEntity.Add <TurretBuildingComponent>(new TurretBuildingComponent());
                break;

            case BuildingType.TroopResearch:
                smartEntity.Add <OffenseLabComponent>(new OffenseLabComponent());
                break;

            case BuildingType.DefenseResearch:
                smartEntity.Add <DefenseLabComponent>(new DefenseLabComponent());
                break;

            case BuildingType.Resource:
                if (building.LastCollectTime == 0u)
                {
                    building.LastCollectTime = ServerTime.Time;
                }
                smartEntity.Add <GeneratorComponent>(new GeneratorComponent());
                break;

            case BuildingType.Storage:
                smartEntity.Add <StorageComponent>(new StorageComponent());
                break;

            case BuildingType.Clearable:
                smartEntity.Add <ClearableComponent>(new ClearableComponent());
                break;

            case BuildingType.Cantina:
                smartEntity.Add <CantinaComponent>(new CantinaComponent());
                break;

            case BuildingType.NavigationCenter:
                smartEntity.Add <NavigationCenterComponent>(new NavigationCenterComponent());
                break;

            case BuildingType.ScoutTower:
                smartEntity.Add <ScoutTowerComponent>(new ScoutTowerComponent());
                break;

            case BuildingType.Armory:
                smartEntity.Add <ArmoryComponent>(new ArmoryComponent());
                break;
            }
            if (buildingType.IsLootable)
            {
                LootComponent component3 = new LootComponent();
                smartEntity.Add <LootComponent>(component3);
            }
            if (requestAsset)
            {
                Service.Get <EntityViewManager>().LoadEntityAsset(smartEntity);
            }
            return(smartEntity);
        }