Exemple #1
0
 private void RemoveTransportRequest(ContractEventData contractData)
 {
     if (this.busyTransportByFactory != null && this.busyTransportByFactory.Contains(contractData.Entity))
     {
         this.busyTransportByFactory.Remove(contractData.Entity);
     }
 }
        public EatResponse OnEvent(EventId id, object cookie)
        {
            if (this.FetchingNewOffer)
            {
                return(EatResponse.NotEaten);
            }
            if (id <= EventId.PlanetRelocate)
            {
                if (id <= EventId.BuildingLevelUpgraded)
                {
                    if (id == EventId.DroidPurchaseCompleted)
                    {
                        goto IL_92;
                    }
                    if (id != EventId.BuildingLevelUpgraded)
                    {
                        return(EatResponse.NotEaten);
                    }
                }
                else if (id != EventId.BuildingConstructed)
                {
                    if (id != EventId.PlanetRelocate)
                    {
                        return(EatResponse.NotEaten);
                    }
                    goto IL_92;
                }
                ContractEventData contractEventData = (ContractEventData)cookie;
                if (contractEventData == null)
                {
                    return(EatResponse.NotEaten);
                }
                BuildingTypeVO buildingVO = contractEventData.BuildingVO;
                if (buildingVO == null)
                {
                    return(EatResponse.NotEaten);
                }
                if (!this.buildingTypeIgnoreList.Contains(buildingVO.Type))
                {
                    this.GetNewOffer(id);
                    return(EatResponse.NotEaten);
                }
                return(EatResponse.NotEaten);
            }
            else if (id <= EventId.SquadJoinedByCurrentPlayer)
            {
                if (id != EventId.SquadLeft && id != EventId.SquadJoinedByCurrentPlayer)
                {
                    return(EatResponse.NotEaten);
                }
            }
            else if (id != EventId.TargetedBundleRewardRedeemed && id != EventId.InAppPurchaseMade)
            {
                return(EatResponse.NotEaten);
            }
IL_92:
            this.GetNewOffer(id);
            return(EatResponse.NotEaten);
        }
Exemple #3
0
        private void SpawnTransport(ContractEventData contractData)
        {
            if (!this.CountTransportRequest(contractData))
            {
                return;
            }
            Entity         entity     = contractData.Entity;
            BuildingTypeVO buildingVO = contractData.BuildingVO;
            string         uid;

            if (buildingVO.Faction == FactionType.Empire)
            {
                uid = this.TRANSPORT_SHIP_EMPIRE;
            }
            else
            {
                if (buildingVO.Faction != FactionType.Rebel)
                {
                    return;
                }
                uid = this.TRANSPORT_SHIP_REBEL;
            }
            TransportTypeVO transportType = Service.StaticDataController.Get <TransportTypeVO>(uid);
            Entity          entity2       = this.FindIdleTransport(transportType);

            if (entity2 == null)
            {
                return;
            }
            Entity entity3 = this.FindIdleStarport(contractData);

            if (entity3 == null)
            {
                return;
            }
            TransformComponent transformComponent = entity.Get <TransformComponent>();
            Vector3            vector             = new Vector3(Units.BoardToWorldX(transformComponent.CenterX()), 0f, Units.BoardToWorldZ(transformComponent.CenterZ()));
            GameObject         vehicleLocator     = entity.Get <GameObjectViewComponent>().VehicleLocator;

            if (vehicleLocator != null)
            {
                this.factoryOffset = new Vector3(0f, vehicleLocator.transform.position.y + TransportController.FACTORY_WALL_HEIGHT, 0f);
            }
            else
            {
                this.factoryOffset = new Vector3(0f, TransportController.FACTORY_WALL_HEIGHT, 0f);
            }
            vector            += this.factoryOffset;
            transformComponent = entity3.Get <TransformComponent>();
            Vector3 vector2 = new Vector3(Units.BoardToWorldX(transformComponent.CenterX()), 0f, Units.BoardToWorldZ(transformComponent.CenterZ()));

            vector2 += TransportController.DOCK_OFFSET;
            TransportComponent transportComponent = entity2.Get <TransportComponent>();

            this.BuildSpline(transportComponent.Spline, TransportController.SPAWN_POSITION, vector, vector2, entity3, contractData);
            entity2.Get <StateComponent>().CurState = EntityState.Moving;
        }
Exemple #4
0
        private void OnUnitMobilized(ContractEventData data)
        {
            DeliveryType deliveryType = data.Contract.DeliveryType;

            if (deliveryType == DeliveryType.Hero || deliveryType == DeliveryType.Starship)
            {
                this.CreateEffect(data.Entity, data.Contract.ProductUid, deliveryType == DeliveryType.Starship, false);
            }
        }
Exemple #5
0
        /// <summary>
        /// 克隆
        /// </summary>
        public IContractEventData Clone()
        {
            IContractEventData cloneContractEventData = new ContractEventData()
            {
                Description = this.Description
            };

            return(cloneContractEventData);
        }
        public EatResponse OnEvent(EventId id, object cookie)
        {
            ContractEventData contractEventData = cookie as ContractEventData;
            BuildingTypeVO    vo = Service.Get <IDataController>().Get <BuildingTypeVO>(contractEventData.Contract.ProductUid);

            if (this.IsBuildingValid(vo) && this.IsConditionSatisfied())
            {
                this.parent.ChildSatisfied(this);
            }
            return(EatResponse.NotEaten);
        }
Exemple #7
0
        private SmartEntity FindIdleStarport(ContractEventData contractData)
        {
            SmartEntity smartEntity = StorageSpreadUtils.FindLeastFullStarport();

            if (smartEntity != null)
            {
                TroopTypeVO troop = this.sdc.Get <TroopTypeVO>(contractData.Contract.ProductUid);
                StorageSpreadUtils.AddTroopToStarportReserve(smartEntity, troop);
            }
            return(smartEntity);
        }
Exemple #8
0
        private void StarportReached(object cookie)
        {
            KeyValuePair <Entity, ContractEventData> keyValuePair = (KeyValuePair <Entity, ContractEventData>)cookie;
            SmartEntity       starport = (SmartEntity)keyValuePair.Key;
            ContractEventData value    = keyValuePair.Value;

            this.RemoveTransportRequest(value);
            TroopTypeVO troop = this.sdc.Get <TroopTypeVO>(value.Contract.ProductUid);

            StorageSpreadUtils.AddTroopToStarportVisually(starport, troop);
            Service.EventManager.SendEvent(EventId.TransportDeparted, null);
        }
        private void StarportReached(object cookie)
        {
            KeyValuePair <Entity, ContractEventData> keyValuePair = (KeyValuePair <Entity, ContractEventData>)cookie;
            Entity            key   = keyValuePair.get_Key();
            ContractEventData value = keyValuePair.get_Value();

            this.RemoveTransportRequest(value);
            TroopTypeVO troop = this.sdc.Get <TroopTypeVO>(value.Contract.ProductUid);

            StorageSpreadUtils.AddTroopToStarportVisually(key, troop);
            Service.Get <EventManager>().SendEvent(EventId.TransportDeparted, null);
        }
Exemple #10
0
 public override EatResponse OnEvent(EventId id, object cookie)
 {
     if (id == EventId.ContractCompleted || id == EventId.ContractCanceled)
     {
         ContractEventData contractEventData = cookie as ContractEventData;
         if (ContractUtils.ContractTypeConsumesDroid(contractEventData.Contract.ContractTO.ContractType) && !this.closing)
         {
             this.Close(null);
         }
     }
     return(base.OnEvent(id, cookie));
 }
Exemple #11
0
 public override EatResponse OnEvent(EventId id, object cookie)
 {
     if (id == EventId.ContractCompleted)
     {
         ContractEventData contractEventData = cookie as ContractEventData;
         if (contractEventData.Contract == this.contract)
         {
             this.Close(null);
         }
     }
     return(base.OnEvent(id, cookie));
 }
Exemple #12
0
 public EatResponse OnEvent(EventId id, object cookie)
 {
     if (id == EventId.TroopRecruited || id == EventId.HeroMobilized)
     {
         ContractEventData contractEventData = cookie as ContractEventData;
         if (this.deliveryType == contractEventData.Contract.DeliveryType)
         {
             this.parent.Progress(this, 1);
         }
     }
     return(EatResponse.NotEaten);
 }
Exemple #13
0
        private void OnContractStarted(ContractEventData data)
        {
            DeliveryType deliveryType = data.Contract.DeliveryType;

            if (deliveryType == DeliveryType.Hero || deliveryType == DeliveryType.Starship)
            {
                this.CreateEffect(data.Entity, null, false, false);
            }
            else if (deliveryType == DeliveryType.UpgradeBuilding && data.BuildingVO.Type == BuildingType.NavigationCenter)
            {
                this.RemoveEffectByEntityId(data.Entity.ID);
            }
        }
Exemple #14
0
 private bool CountTransportRequest(ContractEventData contractData)
 {
     if (this.busyTransportByFactory == null)
     {
         this.busyTransportByFactory = new List <Entity>();
     }
     if (this.busyTransportByFactory.Contains(contractData.Entity))
     {
         return(false);
     }
     this.busyTransportByFactory.Add(contractData.Entity);
     return(true);
 }
Exemple #15
0
 public override EatResponse OnEvent(EventId id, object cookie)
 {
     if (id == EventId.ContractCompleted)
     {
         ContractEventData contractEventData = cookie as ContractEventData;
         ContractType      contractType      = contractEventData.Contract.ContractTO.ContractType;
         if (contractType == ContractType.Research)
         {
             this.CheckActiveContract();
         }
     }
     return(base.OnEvent(id, cookie));
 }
Exemple #16
0
        public EatResponse OnEvent(EventId id, object cookie)
        {
            if (this.FetchingNewOffer)
            {
                return(EatResponse.NotEaten);
            }
            switch (id)
            {
            case EventId.BuildingLevelUpgraded:
            case EventId.BuildingConstructed:
            {
                ContractEventData contractEventData = (ContractEventData)cookie;
                if (contractEventData == null)
                {
                    return(EatResponse.NotEaten);
                }
                BuildingTypeVO buildingVO = contractEventData.BuildingVO;
                if (buildingVO == null)
                {
                    return(EatResponse.NotEaten);
                }
                if (!this.buildingTypeIgnoreList.Contains(buildingVO.Type))
                {
                    this.GetNewOffer(id);
                }
                return(EatResponse.NotEaten);
            }

            case EventId.BuildingSwapped:
IL_22:
                switch (id)
                {
                case EventId.SquadLeft:
                case EventId.SquadJoinedByCurrentPlayer:
                    goto IL_A8;

                case EventId.SquadChatFilterUpdated:
IL_3A:
                    if (id != EventId.DroidPurchaseCompleted && id != EventId.PlanetRelocate && id != EventId.TargetedBundleRewardRedeemed && id != EventId.InAppPurchaseMade)
                    {
                        return(EatResponse.NotEaten);
                    }
                    goto IL_A8;
                }
                goto IL_3A;
IL_A8:
                this.GetNewOffer(id);
                return(EatResponse.NotEaten);
            }
            goto IL_22;
        }
Exemple #17
0
 public EatResponse OnEvent(EventId id, object cookie)
 {
     if (id == EventId.StarshipMobilized && base.IsEventValidForBattleObjective())
     {
         ContractEventData   contractEventData   = (ContractEventData)cookie;
         IDataController     dataController      = Service.Get <IDataController>();
         SpecialAttackTypeVO specialAttackTypeVO = dataController.Get <SpecialAttackTypeVO>(contractEventData.Contract.ProductUid);
         if (specialAttackTypeVO.SpecialAttackID == this.specialAttackID)
         {
             this.parent.Progress(this, 1);
         }
     }
     return(EatResponse.NotEaten);
 }
Exemple #18
0
 public EatResponse OnEvent(EventId id, object cookie)
 {
     if (id == EventId.TroopRecruited)
     {
         ContractEventData    contractEventData    = cookie as ContractEventData;
         StaticDataController staticDataController = Service.StaticDataController;
         TroopTypeVO          optional             = staticDataController.GetOptional <TroopTypeVO>(contractEventData.Contract.ProductUid);
         if (optional != null)
         {
             this.parent.Progress(this, optional.Size);
         }
     }
     return(EatResponse.NotEaten);
 }
Exemple #19
0
 public EatResponse OnEvent(EventId id, object cookie)
 {
     if (id == EventId.TroopRecruited || id == EventId.HeroMobilized)
     {
         ContractEventData    contractEventData    = cookie as ContractEventData;
         StaticDataController staticDataController = Service.StaticDataController;
         TroopTypeVO          troopTypeVO          = staticDataController.Get <TroopTypeVO>(contractEventData.Contract.ProductUid);
         if (troopTypeVO.TroopID == this.troopId)
         {
             this.parent.Progress(this, 1);
         }
     }
     return(EatResponse.NotEaten);
 }
Exemple #20
0
        private void FactoryReached(object cookie)
        {
            ContractEventData contractEventData = cookie as ContractEventData;
            Entity            entity            = contractEventData.Entity;

            this.DespawnVehicle(entity);
            Contract contract = Service.ISupportController.FindCurrentContract(entity.Get <BuildingComponent>().BuildingTO.Key);

            if (contract != null)
            {
                KeyValuePair <Contract, Entity> keyValuePair = new KeyValuePair <Contract, Entity>(contract, entity);
                Service.ViewTimerManager.CreateViewTimer(3f, false, new TimerDelegate(this.CallbackSpawnVehicle), keyValuePair);
            }
            Service.EventManager.SendEvent(EventId.TransportDeparted, null);
        }
 public EatResponse OnEvent(EventId id, object cookie)
 {
     if (id == EventId.TroopRecruited || id == EventId.HeroMobilized)
     {
         base.CheckUnusedPveFlag();
         ContractEventData contractEventData = cookie as ContractEventData;
         IDataController   dataController    = Service.Get <IDataController>();
         TroopTypeVO       troopTypeVO       = dataController.Get <TroopTypeVO>(contractEventData.Contract.ProductUid);
         if (troopTypeVO.TroopID == this.troopId)
         {
             this.parent.Progress(this, 1);
         }
     }
     return(EatResponse.NotEaten);
 }
Exemple #22
0
 public EatResponse OnEvent(EventId id, object cookie)
 {
     if (id == EventId.StarshipMobilized)
     {
         if (this.IsEventValidForGoal())
         {
             ContractEventData    contractEventData    = (ContractEventData)cookie;
             StaticDataController staticDataController = Service.StaticDataController;
             SpecialAttackTypeVO  optional             = staticDataController.GetOptional <SpecialAttackTypeVO>(contractEventData.Contract.ProductUid);
             if (optional != null)
             {
                 this.parent.Progress(this, optional.Size);
             }
         }
     }
     return(EatResponse.NotEaten);
 }
Exemple #23
0
        public EatResponse OnEvent(EventId id, object cookie)
        {
            switch (id)
            {
            case EventId.BuildingLevelUpgraded:
            case EventId.BuildingConstructed:
            {
                ContractEventData contractEventData = cookie as ContractEventData;
                SmartEntity       entity            = (cookie as ContractEventData).Entity;
                BuildingComponent buildingComp      = entity.BuildingComp;
                if (entity != null && buildingComp != null && contractEventData.BuildingVO != null && Service.PerkManager.IsPerkAppliedToBuilding(contractEventData.BuildingVO))
                {
                    Service.BuildingController.UpdateBuildingHighlightForPerks(entity);
                }
                return(EatResponse.NotEaten);
            }

            case EventId.BuildingSwapped:
IL_15:
                if (id == EventId.WorldLoadComplete)
                {
                    this.HighlightActivePerkBuildings();
                    this.RefreshPerkBuildingHighlightTimer();
                    return(EatResponse.NotEaten);
                }
                if (id == EventId.GameStateChanged)
                {
                    IState currentState = Service.GameStateMachine.CurrentState;
                    if (currentState is HomeState)
                    {
                        this.HighlightActivePerkBuildings();
                        this.RefreshPerkBuildingHighlightTimer();
                    }
                    return(EatResponse.NotEaten);
                }
                if (id != EventId.ActivePerksUpdated)
                {
                    return(EatResponse.NotEaten);
                }
                this.RefreshPerkBuildingHighlightTimer();
                return(EatResponse.NotEaten);
            }
            goto IL_15;
        }
Exemple #24
0
 public EatResponse OnEvent(EventId id, object cookie)
 {
     if (id <= EventId.BuildingConstructed)
     {
         if (id == EventId.BuildingLevelUpgraded || id == EventId.BuildingConstructed)
         {
             ContractEventData contractEventData = cookie as ContractEventData;
             Entity            entity            = (cookie as ContractEventData).Entity;
             BuildingComponent buildingComp      = ((SmartEntity)entity).BuildingComp;
             if (entity != null && buildingComp != null && contractEventData.BuildingVO != null && Service.Get <PerkManager>().IsPerkAppliedToBuilding(contractEventData.BuildingVO))
             {
                 Service.Get <BuildingController>().UpdateBuildingHighlightForPerks(entity);
             }
         }
     }
     else if (id != EventId.WorldLoadComplete)
     {
         if (id != EventId.GameStateChanged)
         {
             if (id == EventId.ActivePerksUpdated)
             {
                 this.RefreshPerkBuildingHighlightTimer();
             }
         }
         else
         {
             IState currentState = Service.Get <GameStateMachine>().CurrentState;
             if (currentState is HomeState)
             {
                 this.HighlightActivePerkBuildings();
                 this.RefreshPerkBuildingHighlightTimer();
             }
         }
     }
     else
     {
         this.HighlightActivePerkBuildings();
         this.RefreshPerkBuildingHighlightTimer();
     }
     return(EatResponse.NotEaten);
 }
Exemple #25
0
        private void OnContractCanceled(ContractEventData data)
        {
            if (this.effectsByEntityId == null || !this.effectsByEntityId.ContainsKey(data.Entity.ID))
            {
                return;
            }
            DeliveryType deliveryType = data.Contract.DeliveryType;

            if (deliveryType == DeliveryType.Hero || deliveryType == DeliveryType.Starship)
            {
                if (this.GetMobilizedUnit(deliveryType == DeliveryType.Starship) != null)
                {
                    return;
                }
                List <Contract> list = Service.ISupportController.FindAllTroopContractsForBuilding(data.BuildingKey);
                if (list.Count <= 1)
                {
                    this.RemoveEffectByEntityId(data.Entity.ID);
                }
            }
        }
 public EatResponse OnEvent(EventId id, object cookie)
 {
     if (id == EventId.ContractCompleted)
     {
         IDataController   dataController    = Service.Get <IDataController>();
         ContractEventData contractEventData = (ContractEventData)cookie;
         Contract          contract          = contractEventData.Contract;
         DeliveryType      deliveryType      = contract.DeliveryType;
         if (deliveryType == DeliveryType.Infantry || deliveryType == DeliveryType.Vehicle || deliveryType == DeliveryType.Mercenary)
         {
             TroopTypeVO troop = dataController.Get <TroopTypeVO>(contract.ProductUid);
             if (this.IsTroopValid(troop))
             {
                 this.unitsTrained++;
                 this.parent.ChildUpdated(this, 1);
                 this.EvaluateAmount();
             }
         }
     }
     return(EatResponse.NotEaten);
 }
Exemple #27
0
 public override EatResponse OnEvent(EventId id, object cookie)
 {
     if (id != EventId.ContractCompleted)
     {
         if (id == EventId.InventoryUnlockUpdated)
         {
             this.RefreshGrids();
         }
     }
     else
     {
         ContractEventData contractEventData = cookie as ContractEventData;
         ContractType      contractType      = contractEventData.Contract.ContractTO.ContractType;
         if (contractType == ContractType.Build || contractType == ContractType.Research || contractType == ContractType.Upgrade)
         {
             this.RefreshDeployableData();
             this.RefreshGrids();
         }
     }
     return(base.OnEvent(id, cookie));
 }
Exemple #28
0
        public EatResponse OnEvent(EventId id, object cookie)
        {
            switch (id)
            {
            case EventId.ContractAdded:
            {
                ContractEventData contractEventData = (ContractEventData)cookie;
                if (contractEventData.Contract.ProductUid.Equals(this.eventData[0], StringComparison.InvariantCultureIgnoreCase))
                {
                    this.CountEvent();
                }
                return(EatResponse.NotEaten);
            }

            case EventId.ContractBacklogUpdated:
IL_18:
                switch (id)
                {
                case EventId.ScreenClosing:
                {
                    UXFactory uXFactory = cookie as UXFactory;
                    string    text      = (uXFactory != null && !(uXFactory.Root == null)) ? uXFactory.Root.name : string.Empty;
                    if (text.Equals(this.eventData[0], StringComparison.InvariantCultureIgnoreCase))
                    {
                        this.CountEvent();
                    }
                    return(EatResponse.NotEaten);
                }

                case EventId.ScreenClosed:
                case EventId.ScreenOverlayClosing:
IL_34:
                    if (id != EventId.BuildingPurchaseSuccess)
                    {
                        if (id != EventId.BuildingSelected)
                        {
                            if (id != EventId.DroidPurchaseAnimationComplete)
                            {
                                if (id != EventId.EntityKilled)
                                {
                                    if (id != EventId.TroopDeployed)
                                    {
                                        if (id == EventId.TroopDonationTrackRewardReceived)
                                        {
                                            goto IL_3C0;
                                        }
                                        if (id == EventId.SpecialAttackDeployed)
                                        {
                                            SpecialAttack specialAttack = (SpecialAttack)cookie;
                                            if (specialAttack.VO.Uid.Equals(this.eventData[0], StringComparison.InvariantCultureIgnoreCase))
                                            {
                                                this.CountEvent();
                                            }
                                            return(EatResponse.NotEaten);
                                        }
                                        if (id == EventId.ButtonClicked)
                                        {
                                            string text2 = (string)cookie;
                                            if (text2.Equals(this.eventData[0], StringComparison.InvariantCultureIgnoreCase))
                                            {
                                                this.CountEvent();
                                            }
                                            return(EatResponse.NotEaten);
                                        }
                                        if (id == EventId.ContractCompletedForStoryAction)
                                        {
                                            ContractTO contractTO = (ContractTO)cookie;
                                            if (contractTO.Uid.Equals(this.eventData[0], StringComparison.InvariantCultureIgnoreCase))
                                            {
                                                this.CountEvent();
                                            }
                                            return(EatResponse.NotEaten);
                                        }
                                        if (id == EventId.InventoryResourceUpdated)
                                        {
                                            string text3 = (string)cookie;
                                            if (text3.Equals(this.eventData[0], StringComparison.InvariantCultureIgnoreCase))
                                            {
                                                this.CountEvent();
                                            }
                                            return(EatResponse.NotEaten);
                                        }
                                        if (id != EventId.HeroDeployed && id != EventId.ChampionDeployed)
                                        {
                                            if (id != EventId.EquipmentUnlocked)
                                            {
                                                return(EatResponse.NotEaten);
                                            }
                                            goto IL_3C0;
                                        }
                                    }
                                    Entity             entity         = (Entity)cookie;
                                    TroopComponent     troopComponent = entity.Get <TroopComponent>();
                                    ITroopDeployableVO troopType      = troopComponent.TroopType;
                                    if (troopType.Uid.Equals(this.eventData[0], StringComparison.InvariantCultureIgnoreCase))
                                    {
                                        this.CountEvent();
                                    }
                                    return(EatResponse.NotEaten);
                                }
                                Entity entity2 = (Entity)cookie;
                                string text4   = string.Empty;
                                string a       = this.prepareArgs[1];
                                if (a == "troopKilled")
                                {
                                    TroopComponent troopComponent2 = entity2.Get <TroopComponent>();
                                    if (troopComponent2 == null)
                                    {
                                        return(EatResponse.NotEaten);
                                    }
                                    text4 = troopComponent2.TroopType.Uid;
                                }
                                else if (a == "buildingKilled")
                                {
                                    BuildingComponent buildingComponent = entity2.Get <BuildingComponent>();
                                    if (buildingComponent == null)
                                    {
                                        return(EatResponse.NotEaten);
                                    }
                                    BuildingTypeVO buildingType = buildingComponent.BuildingType;
                                    text4 = buildingType.Uid;
                                }
                                if (text4.Equals(this.eventData[0], StringComparison.InvariantCultureIgnoreCase))
                                {
                                    this.CountEvent();
                                }
                                return(EatResponse.NotEaten);
                            }
IL_3C0:
                            this.CountEvent();
                            return(EatResponse.NotEaten);
                        }
                        Entity            entity3            = (Entity)cookie;
                        BuildingComponent buildingComponent2 = entity3.Get <BuildingComponent>();
                        if (buildingComponent2 == null)
                        {
                            return(EatResponse.NotEaten);
                        }
                        BuildingTypeVO buildingType2 = buildingComponent2.BuildingType;
                        if (buildingType2.Uid.Equals(this.eventData[0], StringComparison.InvariantCultureIgnoreCase))
                        {
                            this.CountEvent();
                        }
                        return(EatResponse.NotEaten);
                    }
                    else
                    {
                        Entity            entity4            = (Entity)cookie;
                        BuildingComponent buildingComponent3 = entity4.Get <BuildingComponent>();
                        if (buildingComponent3 == null)
                        {
                            return(EatResponse.NotEaten);
                        }
                        BuildingTypeVO buildingType3 = buildingComponent3.BuildingType;
                        if (buildingType3.Uid.Equals(this.eventData[0], StringComparison.InvariantCultureIgnoreCase))
                        {
                            this.CountEvent();
                        }
                        return(EatResponse.NotEaten);
                    }
                    break;

                case EventId.ScreenLoaded:
                {
                    UXFactory uXFactory2 = cookie as UXFactory;
                    string    name       = uXFactory2.Root.name;
                    if (name.Equals(this.eventData[0], StringComparison.InvariantCultureIgnoreCase))
                    {
                        this.CountEvent();
                    }
                    return(EatResponse.NotEaten);
                }
                }
                goto IL_34;

            case EventId.ContractStarted:
            {
                ContractEventData contractEventData2 = (ContractEventData)cookie;
                if (contractEventData2.Contract.ProductUid.Equals(this.eventData[0], StringComparison.InvariantCultureIgnoreCase))
                {
                    this.CountEvent();
                }
                return(EatResponse.NotEaten);
            }
            }
            goto IL_18;
        }
        public EatResponse OnEvent(EventId id, object cookie)
        {
            IState currentState      = Service.Get <GameStateMachine>().CurrentState;
            Type   previousStateType = Service.Get <GameStateMachine>().PreviousStateType;

            if (id <= EventId.WorldLoadComplete)
            {
                if (id != EventId.BuildingConstructed)
                {
                    if (id == EventId.WorldLoadComplete)
                    {
                        Service.Get <CurrencyEffects>().Cleanup();
                        if (currentState is ApplicationLoadState || currentState is HomeState)
                        {
                            if (!this.entityController.IsViewSystemSet <GeneratorSystem>())
                            {
                                this.entityController.AddViewSystem(new GeneratorSystem(), 2070, 65535);
                                Service.Get <CurrencyEffects>().InitializeEffects("setupTypeCollection");
                            }
                        }
                        else if (currentState is BattleStartState)
                        {
                            Service.Get <CurrencyEffects>().InitializeEffects("setupTypeLooting");
                        }
                    }
                }
                else
                {
                    ContractEventData contractEventData = (ContractEventData)cookie;
                    this.UpdateStorageEffectsOnBuildingChange(contractEventData.Entity, contractEventData.BuildingVO);
                }
            }
            else if (id != EventId.GameStateChanged)
            {
                if (id != EventId.InventoryResourceUpdated)
                {
                    if (id == EventId.PlanetRelocateStarted && this.entityController.IsViewSystemSet <GeneratorSystem>())
                    {
                        this.entityController.RemoveViewSystem <GeneratorSystem>();
                    }
                }
                else if (currentState is HomeState || currentState is EditBaseState || currentState is ApplicationLoadState)
                {
                    string text = cookie as string;
                    if (text == "credits")
                    {
                        this.UpdateStorageEffectsOnStorages(CurrencyType.Credits);
                    }
                    else if (text == "materials")
                    {
                        this.UpdateStorageEffectsOnStorages(CurrencyType.Materials);
                    }
                    else if (text == "contraband")
                    {
                        this.UpdateStorageEffectsOnStorages(CurrencyType.Contraband);
                    }
                }
            }
            else if (!(currentState is HomeState) && !(currentState is IntroCameraState) && !(currentState is GalaxyState))
            {
                if (this.entityController.IsViewSystemSet <GeneratorSystem>())
                {
                    this.entityController.RemoveViewSystem <GeneratorSystem>();
                }
            }
            else if (previousStateType == typeof(EditBaseState))
            {
                this.entityController.AddViewSystem(new GeneratorSystem(), 2070, 65535);
                Service.Get <CurrencyEffects>().PlaceEffects();
            }
            else if ((previousStateType == typeof(BattleStartState) || previousStateType == typeof(WarBoardState)) && currentState is HomeState)
            {
                this.entityController.AddViewSystem(new GeneratorSystem(), 2070, 65535);
                Service.Get <CurrencyEffects>().PlaceEffects();
            }
            return(EatResponse.NotEaten);
        }
Exemple #30
0
        public EatResponse OnEvent(EventId id, object cookie)
        {
            if (id <= EventId.BuildingReplaced)
            {
                if (id <= EventId.BuildingCancelled)
                {
                    if (id != EventId.BuildingViewReady)
                    {
                        if (id != EventId.BuildingCancelled)
                        {
                            return(EatResponse.NotEaten);
                        }
                    }
                    else
                    {
                        EntityViewParams entityViewParams = (EntityViewParams)cookie;
                        if (entityViewParams.Entity.Has <ScoutTowerComponent>())
                        {
                            this.CreateScoutHolo();
                            return(EatResponse.NotEaten);
                        }
                        return(EatResponse.NotEaten);
                    }
                }
                else if (id != EventId.EntityKilled)
                {
                    if (id != EventId.BuildingConstructed)
                    {
                        if (id != EventId.BuildingReplaced)
                        {
                            return(EatResponse.NotEaten);
                        }
                        Entity entity = cookie as Entity;
                        if (entity.Has <ScoutTowerComponent>())
                        {
                            this.CreateScoutHolo();
                            return(EatResponse.NotEaten);
                        }
                        return(EatResponse.NotEaten);
                    }
                }
                else
                {
                    SmartEntity smartEntity = (SmartEntity)cookie;
                    if (smartEntity.BuildingComp == null)
                    {
                        return(EatResponse.NotEaten);
                    }
                    BuildingType type = smartEntity.BuildingComp.BuildingType.Type;
                    if (!this.raidDefenseTrainerBindings.Contains(type))
                    {
                        return(EatResponse.NotEaten);
                    }
                    UXController uXController = Service.Get <UXController>();
                    Lang         lang         = Service.Get <Lang>();
                    switch (type)
                    {
                    case BuildingType.FleetCommand:
                        Service.Get <DeployerController>().SpecialAttackDeployer.ExitMode();
                        uXController.HUD.DisableSpecialAttacks();
                        uXController.MiscElementsManager.ShowPlayerInstructions(lang.Get("STARSHIP_TRAINER_DESTROYED", new object[0]));
                        return(EatResponse.NotEaten);

                    case BuildingType.HeroMobilizer:
                        Service.Get <DeployerController>().HeroDeployer.ExitMode();
                        uXController.HUD.DisableHeroDeploys();
                        uXController.MiscElementsManager.ShowPlayerInstructions(lang.Get("HERO_TRAINER_DESTROYED", new object[0]));
                        return(EatResponse.NotEaten);

                    case BuildingType.ChampionPlatform:
                    case BuildingType.Housing:
                        return(EatResponse.NotEaten);

                    case BuildingType.Squad:
                        Service.Get <DeployerController>().SquadTroopDeployer.ExitMode();
                        uXController.HUD.DisableSquadDeploy();
                        uXController.MiscElementsManager.ShowPlayerInstructions(lang.Get("SQUAD_CENTER_DESTROYED", new object[0]));
                        return(EatResponse.NotEaten);

                    default:
                        return(EatResponse.NotEaten);
                    }
                }
                ContractEventData contractEventData = (ContractEventData)cookie;
                if (contractEventData.BuildingVO.Type == BuildingType.ScoutTower)
                {
                    this.SendRaidDefenseUpdate();
                }
            }
            else
            {
                if (id <= EventId.ContractStarted)
                {
                    if (id != EventId.WorldLoadComplete)
                    {
                        if (id == EventId.WorldReset)
                        {
                            this.DestroyScoutHolo();
                            return(EatResponse.NotEaten);
                        }
                        if (id != EventId.ContractStarted)
                        {
                            return(EatResponse.NotEaten);
                        }
                    }
                    else
                    {
                        IState currentState = Service.Get <GameStateMachine>().CurrentState;
                        if (currentState is HomeState && this.RaidCompleteDidAwardCrate())
                        {
                            GameUtils.ShowCrateAwardModal(this.lastAwardedCrateUid);
                            this.lastAwardedCrateUid = null;
                            Service.Get <EventManager>().UnregisterObserver(this, EventId.WorldLoadComplete);
                            return(EatResponse.NotEaten);
                        }
                        return(EatResponse.NotEaten);
                    }
                }
                else if (id != EventId.ContractContinued)
                {
                    if (id == EventId.HeroDeployed)
                    {
                        EntityController entityController      = Service.Get <EntityController>();
                        NodeList <OffensiveTroopNode> nodeList = entityController.GetNodeList <OffensiveTroopNode>();
                        TroopAttackController         troopAttackController = Service.Get <TroopAttackController>();
                        for (OffensiveTroopNode offensiveTroopNode = nodeList.Head; offensiveTroopNode != null; offensiveTroopNode = offensiveTroopNode.Next)
                        {
                            troopAttackController.RefreshTarget((SmartEntity)offensiveTroopNode.Entity);
                        }
                        return(EatResponse.NotEaten);
                    }
                    if (id != EventId.PlanetRelocateStarted)
                    {
                        return(EatResponse.NotEaten);
                    }
                    if (this.AreRaidsAccessible())
                    {
                        this.SendRaidDefenseUpdate();
                        return(EatResponse.NotEaten);
                    }
                    return(EatResponse.NotEaten);
                }
                ContractEventData contractEventData2 = (ContractEventData)cookie;
                if (contractEventData2.BuildingVO.Type == BuildingType.ScoutTower)
                {
                    this.DestroyScoutHolo();
                }
            }
            return(EatResponse.NotEaten);
        }