Exemplo n.º 1
0
 public EatResponse OnEvent(EventId id, object cookie)
 {
     if (id == EventId.CurrencyCollected)
     {
         CurrencyCollectionTag currencyCollectionTag = cookie as CurrencyCollectionTag;
         if (currencyCollectionTag.Type == this.currencyType)
         {
             this.parent.ChildUpdated(this, currencyCollectionTag.Delta);
             this.IncrementCollection(currencyCollectionTag.Delta);
         }
     }
     return(EatResponse.NotEaten);
 }
Exemplo n.º 2
0
        private void OnCollectCurrency(Entity buildingEntity, BuildingComponent buildingComp, int amountCollected)
        {
            CurrencyCollectionTag currencyCollectionTag = new CurrencyCollectionTag();

            currencyCollectionTag.Building = buildingEntity;
            currencyCollectionTag.Type     = buildingComp.BuildingType.Currency;
            currencyCollectionTag.Delta    = amountCollected;
            Service.Get <CurrencyEffects>().PlayEffect(buildingEntity, currencyCollectionTag.Type, amountCollected);
            this.UpdateStorageEffectsAfterCollection(buildingEntity, buildingComp.BuildingType);
            GeneratorViewComponent generatorViewComp = ((SmartEntity)buildingEntity).GeneratorViewComp;

            if (generatorViewComp != null)
            {
                generatorViewComp.ShowAmountCollectedText(amountCollected, currencyCollectionTag.Type);
            }
            Service.Get <EventManager>().SendEvent(EventId.CurrencyCollected, currencyCollectionTag);
        }
Exemplo n.º 3
0
 public EatResponse OnEvent(EventId id, object cookie)
 {
     if (id <= EventId.EntityDestroyed)
     {
         if (id != EventId.BuildingViewReady)
         {
             if (id != EventId.CurrencyCollected)
             {
                 if (id != EventId.EntityDestroyed)
                 {
                     return(EatResponse.NotEaten);
                 }
                 uint num = (uint)cookie;
                 using (Dictionary <Entity, ShuttleAnim> .KeyCollection.Enumerator enumerator = this.shuttles.Keys.GetEnumerator())
                 {
                     while (enumerator.MoveNext())
                     {
                         Entity current = enumerator.Current;
                         if (current.ID == num)
                         {
                             this.RemoveStarportShuttle(current);
                             break;
                         }
                     }
                     return(EatResponse.NotEaten);
                 }
             }
             else
             {
                 CurrencyCollectionTag currencyCollectionTag = cookie as CurrencyCollectionTag;
                 if (currencyCollectionTag.Type == CurrencyType.Contraband)
                 {
                     this.UpdateContrabandShuttle((SmartEntity)currencyCollectionTag.Building);
                     return(EatResponse.NotEaten);
                 }
                 return(EatResponse.NotEaten);
             }
         }
         EntityViewParams entityViewParams = (EntityViewParams)cookie;
         SmartEntity      entity           = entityViewParams.Entity;
         if (!this.shuttles.ContainsKey(entity) && Service.Get <GameStateMachine>().CurrentState is HomeState && entity.BuildingComp.BuildingType.Type == BuildingType.Resource && entity.BuildingComp.BuildingType.Currency == CurrencyType.Contraband)
         {
             this.UpdateContrabandShuttle(entity);
         }
     }
     else if (id <= EventId.BuildingReplaced)
     {
         if (id != EventId.StarportMeterUpdated)
         {
             if (id == EventId.BuildingReplaced)
             {
                 Entity         entity2      = (Entity)cookie;
                 BuildingTypeVO buildingType = entity2.Get <BuildingComponent>().BuildingType;
                 if (buildingType.Type == BuildingType.Starport || (buildingType.Type == BuildingType.Resource && buildingType.Currency == CurrencyType.Contraband))
                 {
                     if (buildingType.Currency == CurrencyType.Contraband)
                     {
                         this.UpdateShuttle(entity2, 0.5f, 1);
                     }
                     else if (buildingType.Type == BuildingType.Armory)
                     {
                         this.UpdateShuttle(entity2, 0.5f, 2);
                     }
                     else
                     {
                         this.UpdateShuttle(entity2, 0.5f, 0);
                     }
                 }
             }
         }
         else
         {
             MeterShaderComponent meterShaderComponent = (MeterShaderComponent)cookie;
             this.UpdateShuttle(meterShaderComponent.Entity, meterShaderComponent.Percentage, 0);
         }
     }
     else if (id != EventId.UserLiftedBuilding)
     {
         if (id == EventId.EquipmentDeactivated)
         {
             NodeList <ArmoryNode> armoryNodeList = Service.Get <BuildingLookupController>().ArmoryNodeList;
             for (ArmoryNode armoryNode = armoryNodeList.Head; armoryNode != null; armoryNode = armoryNode.Next)
             {
                 this.DestroyArmoryShuttle(armoryNode.Entity);
             }
         }
     }
     else
     {
         Entity         entity3       = (Entity)cookie;
         BuildingTypeVO buildingType2 = entity3.Get <BuildingComponent>().BuildingType;
         if (buildingType2.Type == BuildingType.Starport || (buildingType2.Type == BuildingType.Resource && buildingType2.Currency == CurrencyType.Contraband) || buildingType2.Type == BuildingType.Armory)
         {
             this.RemoveStarportShuttle(entity3);
         }
     }
     return(EatResponse.NotEaten);
 }
        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);
        }