private void UpdateArmoryAnimation(SmartEntity entity)
        {
            IState            currentState  = Service.Get <GameStateMachine>().CurrentState;
            CurrentPlayer     currentPlayer = Service.Get <CurrentPlayer>();
            BuildingComponent buildingComp  = entity.BuildingComp;

            if (!(currentState is HomeState) || buildingComp == null || buildingComp.BuildingType.Type != BuildingType.Armory)
            {
                return;
            }
            BuildingAnimationComponent buildingAnimationComp = entity.BuildingAnimationComp;

            if (buildingAnimationComp == null)
            {
                return;
            }
            Animation anim = buildingAnimationComp.Anim;

            if (!ArmoryUtils.IsAnyEquipmentActive(currentPlayer.ActiveArmory) && anim.GetClip("Idle") != null)
            {
                anim.Stop();
                anim.Play("Idle");
                Service.Get <ShuttleController>().DestroyArmoryShuttle(entity);
                return;
            }
            if (entity.StateComp.CurState == EntityState.Idle && anim.IsPlaying("Idle") && anim.GetClip("Active") != null && anim.GetClip("Intro") != null)
            {
                anim.Stop();
                anim.Play("Intro");
                this.EnqueueAnimation(buildingAnimationComp, "Active");
                Service.Get <ShuttleController>().UpdateArmoryShuttle(entity);
            }
        }
        private void StartAnimationOnContractStarted(Entity entity, Contract contract, IState currentState)
        {
            if (Service.Get <ISupportController>().IsBuildingFrozen(contract.ContractTO.BuildingKey))
            {
                return;
            }
            BuildingAnimationComponent buildingAnimationComponent = entity.Get <BuildingAnimationComponent>();

            if (buildingAnimationComponent == null)
            {
                return;
            }
            bool flag = contract.DeliveryType == DeliveryType.UpgradeBuilding || contract.DeliveryType == DeliveryType.Building;

            if (flag)
            {
                buildingAnimationComponent.BuildingUpgrading = true;
            }
            else
            {
                buildingAnimationComponent.BuildingUpgrading = false;
                buildingAnimationComponent.Manufacturing     = true;
            }
            this.UpdateAnimation(entity, currentState, buildingAnimationComponent, true);
        }
        private void UpdateAnimation(Entity entity, IState gameMode, BuildingAnimationComponent animComp, bool updateContraband)
        {
            TrapComponent trapComp = ((SmartEntity)entity).TrapComp;

            if (trapComp != null)
            {
                return;
            }
            if (this.BuildingEligibleForActiveAnimation(entity, gameMode, animComp))
            {
                this.PlayAnimation(animComp.Anim, "Active");
                this.PlayFXs(animComp.ListOfParticleSystems);
            }
            else if (this.BuildingEligibleForIdleAnimation(entity, gameMode, animComp))
            {
                this.PlayAnimation(animComp.Anim, "Idle");
                this.StopFXs(animComp.ListOfParticleSystems);
            }
            else
            {
                this.StopAnimation(animComp.Anim);
                this.StopFXs(animComp.ListOfParticleSystems);
            }
            this.UpdateArmoryAnimation((SmartEntity)entity);
            if (updateContraband)
            {
                this.UpdateContraBandShipAnimation((SmartEntity)entity);
            }
        }
Exemple #4
0
 private void UpdateContraBandGeneratorAnimation(SmartEntity entity, ShuttleAnim currentState)
 {
     if (entity.BuildingComp.BuildingType.Type != BuildingType.Resource || entity.BuildingComp.BuildingType.Currency != CurrencyType.Contraband)
     {
         return;
     }
     if (currentState != null)
     {
         BuildingAnimationComponent buildingAnimationComp = entity.BuildingAnimationComp;
         Animation    anim  = buildingAnimationComp.Anim;
         ShuttleState state = currentState.State;
         if (state != ShuttleState.Landing && state != ShuttleState.LiftOff)
         {
             if (state == ShuttleState.Idle)
             {
                 if (anim.GetClip("Active") != null && anim.GetClip("Intro") != null)
                 {
                     anim.Stop();
                     anim.Play("Intro");
                     this.EnqueueAnimation(buildingAnimationComp, "Active");
                 }
             }
         }
         else if (anim.GetClip("Full") != null)
         {
             anim.Stop();
             anim.Play("Full");
         }
     }
 }
        private void UpdateAnimationOnGeneratorFull(SmartEntity entity, IState currentState)
        {
            if (!(currentState is HomeState))
            {
                return;
            }
            BuildingAnimationComponent buildingAnimationComp = entity.BuildingAnimationComp;
            Animation anim = buildingAnimationComp.Anim;

            if (anim.GetClip("Full") != null)
            {
                anim.Stop();
                anim.Play("Full");
            }
            this.UpdateContraBandShipAnimation(entity);
        }
        private void UpdateAnimationOnContractStopped(Entity entity, IState currentState)
        {
            BuildingAnimationComponent buildingAnimationComponent = entity.Get <BuildingAnimationComponent>();

            if (buildingAnimationComponent == null)
            {
                return;
            }
            if (buildingAnimationComponent.BuildingUpgrading)
            {
                buildingAnimationComponent.BuildingUpgrading = false;
            }
            else if (buildingAnimationComponent.Manufacturing)
            {
                buildingAnimationComponent.Manufacturing = false;
            }
            this.UpdateAnimation(entity, currentState, buildingAnimationComponent, false);
        }
        private void UpdateContraBandGeneratorAnimation(SmartEntity entity, ShuttleAnim currentState)
        {
            if (entity.BuildingComp.BuildingType.Type != BuildingType.Resource || entity.BuildingComp.BuildingType.Currency != CurrencyType.Contraband)
            {
                return;
            }
            if (currentState != null)
            {
                BuildingAnimationComponent buildingAnimationComp = entity.BuildingAnimationComp;
                Animation anim = buildingAnimationComp.Anim;
                switch (currentState.State)
                {
                case ShuttleState.Landing:
                case ShuttleState.LiftOff:
                    if (anim.GetClip("Full") != null)
                    {
                        anim.Stop();
                        anim.Play("Full");
                        return;
                    }
                    break;

                case ShuttleState.Idle:
                    if (anim.GetClip("Active") != null && anim.GetClip("Intro") != null)
                    {
                        anim.Stop();
                        anim.Play("Intro");
                        this.EnqueueAnimation(buildingAnimationComp, "Active");
                    }
                    break;

                default:
                    return;
                }
            }
        }
Exemple #8
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));
 }
Exemple #9
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));
        }
        private bool BuildingEligibleForActiveAnimation(Entity entity, IState gameState, BuildingAnimationComponent animComp)
        {
            if (entity == null)
            {
                return(false);
            }
            if (gameState is EditBaseState)
            {
                return(false);
            }
            if (animComp.BuildingUpgrading)
            {
                return(false);
            }
            if (Service.Get <PostBattleRepairController>().IsEntityInRepair(entity))
            {
                return(false);
            }
            if (animComp.Manufacturing)
            {
                return(true);
            }
            BuildingComponent buildingComponent = entity.Get <BuildingComponent>();

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

            if (buildingType.Type == BuildingType.HQ)
            {
                return(true);
            }
            if (buildingType.Type == BuildingType.ShieldGenerator && buildingType.SubType == BuildingSubType.OutpostDefenseGenerator)
            {
                return(true);
            }
            if (!(gameState is HomeState))
            {
                return(false);
            }
            if (buildingComponent.BuildingType.Type == BuildingType.Barracks || buildingComponent.BuildingType.Type == BuildingType.Cantina)
            {
                return(true);
            }
            if (buildingComponent.BuildingType.Type == BuildingType.DroidHut)
            {
                return(true);
            }
            if (buildingComponent.BuildingType.Type == BuildingType.ScoutTower)
            {
                return(Service.Get <RaidDefenseController>().IsRaidAvailable());
            }
            if (buildingComponent.BuildingType.Type == BuildingType.Resource && buildingComponent.BuildingTO.AccruedCurrency < buildingType.Storage)
            {
                return(true);
            }
            if (buildingComponent.BuildingType.Type == BuildingType.Storage && buildingComponent.BuildingTO.CurrentStorage < buildingType.Storage)
            {
                return(true);
            }
            if (buildingComponent.BuildingType.Type == BuildingType.Armory)
            {
                ActiveArmory activeArmory = Service.Get <CurrentPlayer>().ActiveArmory;
                return(ArmoryUtils.IsAnyEquipmentActive(activeArmory));
            }
            return(false);
        }
        public EatResponse OnEvent(EventId id, object cookie)
        {
            IState currentState = Service.Get <GameStateMachine>().CurrentState;

            if (id <= EventId.WorldLoadComplete)
            {
                if (id <= EventId.StorageDoorEvent)
                {
                    if (id != EventId.BuildingViewReady)
                    {
                        switch (id)
                        {
                        case EventId.CurrencyCollected:
                        {
                            CurrencyCollectionTag currencyCollectionTag = cookie as CurrencyCollectionTag;
                            SmartEntity           smartEntity           = (SmartEntity)currencyCollectionTag.Building;
                            if (smartEntity != null)
                            {
                                BuildingAnimationComponent buildingAnimationComp = smartEntity.BuildingAnimationComp;
                                if (buildingAnimationComp != null)
                                {
                                    this.UpdateAnimation(smartEntity, currentState, buildingAnimationComp, true);
                                }
                            }
                            break;
                        }

                        case EventId.GeneratorJustFilled:
                            this.UpdateAnimationOnGeneratorFull((SmartEntity)cookie, currentState);
                            break;

                        case EventId.StorageDoorEvent:
                        {
                            SmartEntity smartEntity = (SmartEntity)cookie;
                            if (smartEntity != null && smartEntity.BuildingAnimationComp != null && smartEntity.StorageComp != null && smartEntity.StorageComp.CurrentFullnessPercentage < 1f)
                            {
                                BuildingAnimationComponent buildingAnimationComp = smartEntity.BuildingAnimationComp;
                                if (this.BuildingEligibleForActiveAnimation(smartEntity, currentState, buildingAnimationComp))
                                {
                                    buildingAnimationComp.Anim.Stop();
                                    int num = this.storageOpenCloseAnims.Length;
                                    for (int i = 0; i < num; i++)
                                    {
                                        this.EnqueueAnimation(buildingAnimationComp, this.storageOpenCloseAnims[i]);
                                    }
                                }
                            }
                            break;
                        }
                        }
                    }
                    else
                    {
                        EntityViewParams entityViewParams = cookie as EntityViewParams;
                        SmartEntity      smartEntity      = entityViewParams.Entity;
                        GameObject       mainGameObject   = smartEntity.GameObjectViewComp.MainGameObject;
                        Animation        component        = mainGameObject.GetComponent <Animation>();
                        if (!(component == null))
                        {
                            AssetMeshDataMonoBehaviour component2 = mainGameObject.GetComponent <AssetMeshDataMonoBehaviour>();
                            this.UpdateAnimation(smartEntity, currentState, new BuildingAnimationComponent(component, component2 ? component2.ListOfParticleSystems : null), true);
                        }
                    }
                }
                else if (id != EventId.TroopRecruited)
                {
                    if (id == EventId.WorldLoadComplete)
                    {
                        this.UpdateAnimations(currentState);
                    }
                }
                else
                {
                    ContractEventData contractEventData = cookie as ContractEventData;
                    if (contractEventData.Contract.DeliveryType == DeliveryType.Infantry)
                    {
                        SmartEntity smartEntity = (SmartEntity)contractEventData.Entity;
                        if (smartEntity != null)
                        {
                            BuildingAnimationComponent buildingAnimationComp = smartEntity.BuildingAnimationComp;
                            if (buildingAnimationComp != null && this.BuildingEligibleForActiveAnimation(smartEntity, currentState, buildingAnimationComp))
                            {
                                buildingAnimationComp.Anim.Stop();
                                for (int j = 0; j < this.barracksOpenCloseAnims.Length; j++)
                                {
                                    this.EnqueueAnimation(buildingAnimationComp, this.barracksOpenCloseAnims[j]);
                                }
                            }
                        }
                    }
                }
            }
            else if (id <= EventId.ContractStopped)
            {
                if (id != EventId.GameStateChanged)
                {
                    switch (id)
                    {
                    case EventId.ContractStarted:
                    case EventId.ContractContinued:
                    {
                        ContractEventData contractEventData2 = (ContractEventData)cookie;
                        this.StartAnimationOnContractStarted(contractEventData2.Entity, contractEventData2.Contract, currentState);
                        break;
                    }

                    case EventId.ContractStopped:
                        this.UpdateAnimationOnContractStopped((Entity)cookie, currentState);
                        break;
                    }
                }
                else
                {
                    this.UpdateAnimations(currentState);
                }
            }
            else if (id != EventId.ScreenClosing)
            {
                switch (id)
                {
                case EventId.EntityPostBattleRepairStarted:
                case EventId.EntityPostBattleRepairFinished:
                {
                    SmartEntity smartEntity = (SmartEntity)cookie;
                    if (smartEntity != null)
                    {
                        BuildingAnimationComponent buildingAnimationComp = smartEntity.BuildingAnimationComp;
                        if (buildingAnimationComp != null)
                        {
                            this.UpdateAnimation(smartEntity, currentState, buildingAnimationComp, true);
                        }
                    }
                    break;
                }

                case EventId.AllPostBattleRepairFinished:
                    break;

                case EventId.ShuttleAnimStateChanged:
                {
                    ShuttleAnim shuttleAnim = (ShuttleAnim)cookie;
                    SmartEntity smartEntity = (SmartEntity)shuttleAnim.Starport;
                    if (smartEntity.BuildingComp.BuildingType.Type == BuildingType.Armory)
                    {
                        Service.Get <ShuttleController>().DestroyArmoryShuttle(smartEntity);
                    }
                    else
                    {
                        this.UpdateContraBandGeneratorAnimation(smartEntity, shuttleAnim);
                    }
                    break;
                }

                default:
                    if (id == EventId.EquipmentDeactivated)
                    {
                        NodeList <ArmoryNode> armoryNodeList = Service.Get <BuildingLookupController>().ArmoryNodeList;
                        for (ArmoryNode armoryNode = armoryNodeList.Head; armoryNode != null; armoryNode = armoryNode.Next)
                        {
                            this.UpdateArmoryAnimation((SmartEntity)armoryNode.Entity);
                        }
                    }
                    break;
                }
            }
            else if (cookie is ArmoryScreen)
            {
                NodeList <ArmoryNode> armoryNodeList2 = Service.Get <BuildingLookupController>().ArmoryNodeList;
                for (ArmoryNode armoryNode2 = armoryNodeList2.Head; armoryNode2 != null; armoryNode2 = armoryNode2.Next)
                {
                    this.UpdateArmoryAnimation((SmartEntity)armoryNode2.Entity);
                }
            }
            return(EatResponse.NotEaten);
        }
 private void EnqueueAnimation(BuildingAnimationComponent animComp, string animationID)
 {
     animComp.Anim.PlayQueued(animationID);
 }
        private bool BuildingEligibleForIdleAnimation(Entity entity, IState gameState, BuildingAnimationComponent animComp)
        {
            if (entity == null)
            {
                return(false);
            }
            if (gameState is EditBaseState)
            {
                return(false);
            }
            if (animComp.BuildingUpgrading)
            {
                return(false);
            }
            if (Service.Get <PostBattleRepairController>().IsEntityInRepair(entity))
            {
                return(false);
            }
            BuildingComponent buildingComponent = entity.Get <BuildingComponent>();

            if (buildingComponent == null)
            {
                return(false);
            }
            if (!(gameState is HomeState))
            {
                return(false);
            }
            if (buildingComponent.BuildingType.Type == BuildingType.ScoutTower)
            {
                return(true);
            }
            if (buildingComponent.BuildingType.Type == BuildingType.Armory)
            {
                ActiveArmory activeArmory = Service.Get <CurrentPlayer>().ActiveArmory;
                return(!ArmoryUtils.IsAnyEquipmentActive(activeArmory));
            }
            return(false);
        }