예제 #1
0
 private void AnimateContrabandShuttle(ShuttleAnim anim, float percent)
 {
     if (anim.Anim == null)
     {
         return;
     }
     if (percent < 1f)
     {
         ShuttleState state = anim.State;
         if (state != ShuttleState.Landing && state != ShuttleState.Idle)
         {
             anim.EnqueueState(ShuttleState.Landing);
             anim.EnqueueState(ShuttleState.Idle);
             return;
         }
     }
     else
     {
         ShuttleState state = anim.State;
         if (state == ShuttleState.Landing || state == ShuttleState.Idle)
         {
             anim.EnqueueState(ShuttleState.LiftOff);
             return;
         }
         this.RemoveStarportShuttle(anim.Starport);
     }
 }
예제 #2
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");
         }
     }
 }
예제 #3
0
        private void TryShowEffect()
        {
            if (this.troopEntity == null)
            {
                Service.Get <StaRTSLogger>().Error("TryShowEffect with Null troopEntity");
                return;
            }
            bool flag = !this.showFullEffect || (this.troopCardTexture != null && this.effectObj != null && this.effectObj.transform != null);

            if (!this.ShuttleReadyForShowEffect())
            {
                this.shuttle = Service.Get <ShuttleController>().GetShuttleForStarport(this.starportEntity);
            }
            if (!flag || !this.pathReached || !this.ShuttleReadyForShowEffect())
            {
                if (!this.ShuttleReadyForShowEffect())
                {
                    Service.Get <EventManager>().RegisterObserver(this, EventId.ShuttleAnimStateChanged, EventPriority.Default);
                }
                return;
            }
            GameObjectViewComponent gameObjectViewComponent = this.troopEntity.Get <GameObjectViewComponent>();

            if (gameObjectViewComponent == null)
            {
                Service.Get <EventManager>().RegisterObserver(this, EventId.TroopViewReady, EventPriority.Default);
                return;
            }
            Service.Get <EventManager>().SendEvent(EventId.TroopLoadingIntoStarport, this.troopEntity);
            if (this.entityFader == null || gameObjectViewComponent.MainGameObject == null)
            {
                this.Finish();
                return;
            }
            Vector3 position = this.shuttle.CenterOfMass.transform.position;

            this.animPosition = new AnimPosition(gameObjectViewComponent.MainGameObject, 0.8f, position);
            Service.Get <AnimController>().Animate(this.animPosition);
            this.entityFader.FadeOut(this.troopEntity, 0f, 0.3f, null, new FadingDelegate(this.OnFadeOutComplete));
            AssetMeshDataMonoBehaviour component = gameObjectViewComponent.MainGameObject.GetComponent <AssetMeshDataMonoBehaviour>();

            if (component != null && component.ShadowGameObject != null)
            {
                component.ShadowGameObject.SetActive(false);
            }
            this.timerId = Service.Get <ViewTimerManager>().CreateViewTimer(2f, false, new TimerDelegate(this.OnEffectTimer), null);
            if (this.showFullEffect)
            {
                this.effectObj.SetActive(true);
                position.y = 1.2f;
                this.effectObj.transform.position  = position;
                this.troopCardMaterial             = UnityUtils.EnsureMaterialCopy(this.troopCardPS.GetComponent <Renderer>());
                this.troopCardMaterial.mainTexture = this.troopCardTexture;
                this.troopCardPS.Play();
                this.shuttleGlowPS.Play();
                this.shuttle.PulseOutline();
            }
        }
예제 #4
0
 public void Cleanup()
 {
     if (this.loadedAssets)
     {
         if (this.effectObj != null)
         {
             UnityEngine.Object.Destroy(this.effectObj);
         }
         UnityUtils.DestroyMaterial(this.troopCardMaterial);
         AssetManager assetManager = Service.Get <AssetManager>();
         if (this.effectHandle != AssetHandle.Invalid)
         {
             assetManager.Unload(this.effectHandle);
             this.effectHandle = AssetHandle.Invalid;
         }
         if (this.troopHandle != AssetHandle.Invalid)
         {
             assetManager.Unload(this.troopHandle);
             this.troopHandle = AssetHandle.Invalid;
         }
     }
     if (this.shuttle == null)
     {
         Service.Get <EventManager>().UnregisterObserver(this, EventId.ShuttleAnimStateChanged);
     }
     else
     {
         this.shuttle = null;
     }
     if (this.timerId != 0u)
     {
         Service.Get <ViewTimerManager>().KillViewTimer(this.timerId);
     }
     else
     {
         this.timerId = 0u;
     }
     if (this.animPosition != null)
     {
         Service.Get <AnimController>().CompleteAndRemoveAnim(this.animPosition);
     }
     this.troopVO           = null;
     this.troopEntity       = null;
     this.starportEntity    = null;
     this.entityFader       = null;
     this.onFinished        = null;
     this.effectObj         = null;
     this.troopCardPS       = null;
     this.shuttleGlowPS     = null;
     this.troopCardTexture  = null;
     this.troopCardMaterial = null;
     this.animPosition      = null;
     this.showFullEffect    = false;
     this.pathReached       = false;
     Service.Get <EventManager>().UnregisterObserver(this, EventId.TroopViewReady);
     Service.Get <EventManager>().UnregisterObserver(this, EventId.BuildingMovedOnBoard);
     Service.Get <EventManager>().UnregisterObserver(this, EventId.BuildingReplaced);
 }
예제 #5
0
 private void AnimateArmoryShuttle(ShuttleAnim anim)
 {
     if (anim.Anim == null || !ArmoryUtils.IsAnyEquipmentActive(Service.Get <CurrentPlayer>().ActiveArmory))
     {
         return;
     }
     anim.EnqueueState(ShuttleState.DropOff);
     anim.EnqueueState(ShuttleState.Idle);
 }
예제 #6
0
        private void OnTakeOffFxSuccess(object asset, object cookie)
        {
            GameObject gameObject = (GameObject)asset;

            gameObject = UnityEngine.Object.Instantiate <GameObject>(gameObject);
            ShuttleAnim shuttleAnim = (ShuttleAnim)cookie;

            shuttleAnim.TakeOffEffect = gameObject;
            shuttleAnim.TakeOffEffect.GetComponent <ParticleSystem>().Stop(true);
        }
예제 #7
0
        public ShuttleAnim GetShuttleForStarport(Entity starport)
        {
            ShuttleAnim result = null;

            if (this.shuttles.ContainsKey(starport))
            {
                result = this.shuttles[starport];
            }
            return(result);
        }
예제 #8
0
        private void AnimateShuttle(ShuttleAnim anim, float percent)
        {
            if (percent <= 0f)
            {
                this.RemoveStarportShuttle(anim.Starport);
                return;
            }
            if (anim.Anim == null)
            {
                return;
            }
            if (percent < 1f)
            {
                switch (anim.State)
                {
                case ShuttleState.None:
                    anim.EnqueueState(ShuttleState.Landing);
                    anim.EnqueueState(ShuttleState.Idle);
                    return;

                case ShuttleState.Landing:
                case ShuttleState.Idle:
                    break;

                default:
                    return;
                }
            }
            else
            {
                switch (anim.State)
                {
                case ShuttleState.None:
                    anim.EnqueueState(ShuttleState.Landing);
                    anim.EnqueueState(ShuttleState.Idle);
                    anim.EnqueueState(ShuttleState.LiftOff);
                    anim.EnqueueState(ShuttleState.Hover);
                    return;

                case ShuttleState.Landing:
                case ShuttleState.LiftOff:
                case ShuttleState.Hover:
                    break;

                case ShuttleState.Idle:
                    anim.EnqueueState(ShuttleState.LiftOff);
                    anim.EnqueueState(ShuttleState.Hover);
                    break;

                default:
                    return;
                }
            }
        }
예제 #9
0
        public void DestroyArmoryShuttle(Entity entity)
        {
            if (!this.shuttles.ContainsKey(entity))
            {
                return;
            }
            ShuttleAnim shuttleAnim = this.shuttles[entity];

            if (shuttleAnim.State == ShuttleState.Idle || !ArmoryUtils.IsAnyEquipmentActive(Service.Get <CurrentPlayer>().ActiveArmory))
            {
                this.RemoveStarportShuttle(entity);
            }
        }
예제 #10
0
 public EatResponse OnEvent(EventId id, object cookie)
 {
     if (id <= EventId.TroopViewReady)
     {
         if (id != EventId.BuildingMovedOnBoard)
         {
             if (id == EventId.TroopViewReady)
             {
                 EntityViewParams entityViewParams = (EntityViewParams)cookie;
                 if (entityViewParams.Entity == this.troopEntity)
                 {
                     Service.Get <EventManager>().UnregisterObserver(this, EventId.TroopViewReady);
                     this.TryShowEffect();
                 }
             }
         }
         else if (this.starportEntity == cookie)
         {
             this.shuttle = null;
             Service.Get <EventManager>().RegisterObserver(this, EventId.ShuttleAnimStateChanged, EventPriority.Default);
         }
     }
     else if (id != EventId.BuildingReplaced)
     {
         if (id == EventId.ShuttleAnimStateChanged)
         {
             ShuttleAnim shuttleAnim = (ShuttleAnim)cookie;
             if (shuttleAnim.State == ShuttleState.Idle && shuttleAnim.Starport == this.starportEntity)
             {
                 this.shuttle = shuttleAnim;
                 Service.Get <EventManager>().UnregisterObserver(this, EventId.ShuttleAnimStateChanged);
                 this.TryShowEffect();
             }
         }
     }
     else
     {
         Entity entity = (Entity)cookie;
         if (this.starportEntity.Get <StarportComponent>() == null)
         {
             StarportComponent starportComponent = entity.Get <StarportComponent>();
             if (starportComponent != null)
             {
                 this.starportEntity = entity;
                 this.shuttle        = Service.Get <ShuttleController>().GetShuttleForStarport(this.starportEntity);
             }
         }
     }
     return(EatResponse.NotEaten);
 }
예제 #11
0
        public TransportTroopEffect(Entity troopEntity, TroopTypeVO troopVO, Entity starportEntity, ViewFader entityFader, TransportTroopEffect.OnEffectFinished onFinished, bool showFullEffect)
        {
            this.troopVO        = troopVO;
            this.troopEntity    = troopEntity;
            this.starportEntity = starportEntity;
            this.entityFader    = entityFader;
            this.onFinished     = onFinished;
            this.showFullEffect = showFullEffect;
            if (showFullEffect)
            {
                TextureVO optional = Service.Get <IDataController>().GetOptional <TextureVO>("unittransport_event_troop_" + troopVO.TroopID);
                if (optional != null)
                {
                    GeometryTag geometryTag = new GeometryTag(troopVO, optional.AssetName);
                    Service.Get <EventManager>().SendEvent(EventId.TextureCreated, geometryTag);
                    AssetManager assetManager = Service.Get <AssetManager>();
                    assetManager.Load(ref this.troopHandle, geometryTag.assetName, new AssetSuccessDelegate(this.OnTroopCardLoaded), new AssetFailureDelegate(this.OnTroopCardLoadFailed), null);
                    assetManager.Load(ref this.effectHandle, "troop_card_spawn", new AssetSuccessDelegate(this.OnEffectLoaded), new AssetFailureDelegate(this.OnEffectLoadFailed), null);
                    this.loadedAssets = true;
                }
                else
                {
                    Service.Get <StaRTSLogger>().WarnFormat("Transport troop effect error: {0} not found in TextureData", new object[]
                    {
                        "unittransport_event_troop_" + troopVO.TroopID
                    });
                    this.showFullEffect = false;
                }
            }
            ShuttleAnim shuttleForStarport = Service.Get <ShuttleController>().GetShuttleForStarport(starportEntity);

            if (shuttleForStarport != null && shuttleForStarport.State == ShuttleState.Idle)
            {
                this.shuttle = shuttleForStarport;
            }
            else
            {
                Service.Get <EventManager>().RegisterObserver(this, EventId.ShuttleAnimStateChanged, EventPriority.Default);
            }
            Service.Get <EventManager>().RegisterObserver(this, EventId.BuildingMovedOnBoard, EventPriority.Default);
            Service.Get <EventManager>().RegisterObserver(this, EventId.BuildingReplaced, EventPriority.Default);
            this.timerId     = 0u;
            this.pathReached = false;
        }
예제 #12
0
        private void UnloadShuttle(ShuttleAnim anim)
        {
            anim.Stop();
            if (anim.ShadowMaterial != null)
            {
                UnityUtils.DestroyMaterial(anim.ShadowMaterial);
                anim.ShadowMaterial = null;
            }
            AssetManager assetManager = Service.Get <AssetManager>();

            if (anim.GameObj != null)
            {
                UnityEngine.Object.Destroy(anim.GameObj);
                anim.GameObj = null;
            }
            if (anim.MainHandle != AssetHandle.Invalid)
            {
                assetManager.Unload(anim.MainHandle);
                anim.MainHandle = AssetHandle.Invalid;
            }
            if (anim.LandingEffect != null)
            {
                UnityEngine.Object.Destroy(anim.LandingEffect);
                anim.LandingEffect = null;
            }
            if (anim.LandingHandle != AssetHandle.Invalid)
            {
                assetManager.Unload(anim.LandingHandle);
                anim.LandingHandle = AssetHandle.Invalid;
            }
            if (anim.TakeOffEffect != null)
            {
                UnityEngine.Object.Destroy(anim.TakeOffEffect);
                anim.TakeOffEffect = null;
            }
            if (anim.TakeoffHandle != AssetHandle.Invalid)
            {
                assetManager.Unload(anim.TakeoffHandle);
                anim.TakeoffHandle = AssetHandle.Invalid;
            }
        }
예제 #13
0
        private void AnimateShuttle(ShuttleAnim anim, float percent)
        {
            if (percent <= 0f)
            {
                this.RemoveStarportShuttle(anim.Starport);
                return;
            }
            if (anim.Anim == null)
            {
                return;
            }
            if (percent < 1f)
            {
                ShuttleState state = anim.State;
                if (state != ShuttleState.Landing && state != ShuttleState.Idle)
                {
                    if (state == ShuttleState.None)
                    {
                        anim.EnqueueState(ShuttleState.Landing);
                        anim.EnqueueState(ShuttleState.Idle);
                    }
                }
            }
            else
            {
                switch (anim.State)
                {
                case ShuttleState.None:
                    anim.EnqueueState(ShuttleState.Landing);
                    anim.EnqueueState(ShuttleState.Idle);
                    anim.EnqueueState(ShuttleState.LiftOff);
                    anim.EnqueueState(ShuttleState.Hover);
                    break;

                case ShuttleState.Idle:
                    anim.EnqueueState(ShuttleState.LiftOff);
                    anim.EnqueueState(ShuttleState.Hover);
                    break;
                }
            }
        }
        private void UpdateContraBandShipAnimation(SmartEntity entity)
        {
            if (entity == null || entity.BuildingComp.BuildingType.Type != BuildingType.Resource || entity.BuildingComp.BuildingType.Currency != CurrencyType.Contraband)
            {
                return;
            }
            IState currentState = Service.Get <GameStateMachine>().CurrentState;

            if (!(currentState is HomeState) || ContractUtils.IsBuildingUpgrading(entity) || ContractUtils.IsBuildingConstructing(entity))
            {
                Service.Get <ShuttleController>().RemoveStarportShuttle(entity);
            }
            else
            {
                Service.Get <ShuttleController>().UpdateContrabandShuttle(entity);
            }
            ShuttleAnim shuttleForStarport = Service.Get <ShuttleController>().GetShuttleForStarport(entity);

            if (shuttleForStarport != null)
            {
                this.UpdateContraBandGeneratorAnimation(entity, shuttleForStarport);
            }
        }
        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;
                }
            }
        }
        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);
        }
예제 #17
0
 private void UpdateShuttle(Entity starport, float percent, int shuttleType)
 {
     if (percent <= 0f && shuttleType != 1)
     {
         this.RemoveStarportShuttle(starport);
         return;
     }
     if (!this.shuttles.ContainsKey(starport))
     {
         BuildingComponent buildingComponent = starport.Get <BuildingComponent>();
         BuildingTypeVO    buildingType      = buildingComponent.BuildingType;
         string            text = null;
         if (shuttleType == 1)
         {
             text = "contrabandship_con-mod";
         }
         else if (shuttleType == 2)
         {
             text = "supplyship_smg-ani";
         }
         else
         {
             FactionType faction = buildingType.Faction;
             if (faction != FactionType.Empire)
             {
                 if (faction == FactionType.Rebel)
                 {
                     if (this.rebelShuttles.ContainsKey(buildingType.Lvl))
                     {
                         text = this.rebelShuttles[buildingType.Lvl];
                     }
                     else
                     {
                         text = "e9explor_rbl-mod";
                     }
                 }
             }
             else if (this.empireShuttles.ContainsKey(buildingType.Lvl))
             {
                 text = this.empireShuttles[buildingType.Lvl];
             }
             else
             {
                 text = "lamdaclassshuttle_emp-mod";
             }
         }
         if (text != null)
         {
             ShuttleAnim shuttleAnim = new ShuttleAnim(starport);
             shuttleAnim.Percentage          = percent;
             shuttleAnim.IsContrabandShuttle = (shuttleType == 1);
             shuttleAnim.IsArmoryShuttle     = (shuttleType == 2);
             AssetManager assetManager = Service.Get <AssetManager>();
             assetManager.Load(ref shuttleAnim.LandingHandle, "fx_landing_lrg", new AssetSuccessDelegate(this.OnLandingFxSuccess), null, shuttleAnim);
             assetManager.Load(ref shuttleAnim.TakeoffHandle, "fx_takeoff_lrg", new AssetSuccessDelegate(this.OnTakeOffFxSuccess), null, shuttleAnim);
             assetManager.Load(ref shuttleAnim.MainHandle, text, new AssetSuccessDelegate(this.OnAssetSuccess), new AssetFailureDelegate(this.OnAssetFailure), shuttleAnim);
             this.shuttles.Add(starport, shuttleAnim);
         }
         return;
     }
     if (shuttleType == 1)
     {
         this.AnimateContrabandShuttle(this.shuttles[starport], percent);
         return;
     }
     if (shuttleType == 2)
     {
         this.AnimateArmoryShuttle(this.shuttles[starport]);
         return;
     }
     this.AnimateShuttle(this.shuttles[starport], percent);
 }
예제 #18
0
        private void OnAssetSuccess(object asset, object cookie)
        {
            GameObject  gameObject  = (GameObject)asset;
            ShuttleAnim shuttleAnim = (ShuttleAnim)cookie;

            shuttleAnim.GameObj = gameObject;
            SmartEntity smartEntity = (SmartEntity)shuttleAnim.Starport;

            if (this.shuttles.ContainsKey(smartEntity))
            {
                shuttleAnim.Anim = gameObject.GetComponent <Animation>();
                GameObjectViewComponent gameObjectViewComponent = smartEntity.Get <GameObjectViewComponent>();
                Transform transform = gameObject.transform;
                AssetMeshDataMonoBehaviour component;
                if (shuttleAnim.IsContrabandShuttle)
                {
                    bool flag = shuttleAnim.Percentage < 1f || shuttleAnim.State == ShuttleState.Landing || shuttleAnim.State == ShuttleState.Idle;
                    if (smartEntity.GameObjectViewComp == null || smartEntity.GameObjectViewComp.MainGameObject == null)
                    {
                        this.UnloadShuttle(shuttleAnim);
                        StorageSpreadUtils.UpdateAllStarportFullnessMeters();
                        return;
                    }
                    component = smartEntity.GameObjectViewComp.MainGameObject.GetComponent <AssetMeshDataMonoBehaviour>();
                    for (int i = 0; i < component.OtherGameObjects.Count; i++)
                    {
                        if (component.OtherGameObjects[i].name.Contains("locator_vehicle"))
                        {
                            transform.position = component.OtherGameObjects[i].transform.position;
                            break;
                        }
                    }
                    if (flag)
                    {
                        this.AnimateContrabandShuttle(shuttleAnim, shuttleAnim.Percentage);
                    }
                }
                else if (shuttleAnim.IsArmoryShuttle)
                {
                    if (smartEntity.GameObjectViewComp == null || smartEntity.GameObjectViewComp.MainGameObject == null)
                    {
                        this.UnloadShuttle(shuttleAnim);
                        return;
                    }
                    transform.position = gameObjectViewComponent.MainTransform.position;
                    this.AnimateArmoryShuttle(shuttleAnim);
                }
                else
                {
                    transform.position = gameObjectViewComponent.MainTransform.position;
                    this.AnimateShuttle(shuttleAnim, shuttleAnim.Percentage);
                }
                transform.rotation = Quaternion.AngleAxis(-90f, Vector3.up);
                component          = gameObject.GetComponent <AssetMeshDataMonoBehaviour>();
                if (component != null && component.OtherGameObjects != null)
                {
                    shuttleAnim.ShadowGameObject = component.ShadowGameObject;
                    for (int j = 0; j < component.OtherGameObjects.Count; j++)
                    {
                        if (component.OtherGameObjects[j].name.Contains("center_of_mass"))
                        {
                            shuttleAnim.CenterOfMass = component.OtherGameObjects[j];
                            break;
                        }
                    }
                }
                if (shuttleAnim.ShadowGameObject != null)
                {
                    shuttleAnim.ShadowMaterial        = UnityUtils.EnsureMaterialCopy(shuttleAnim.ShadowGameObject.GetComponent <Renderer>());
                    shuttleAnim.ShadowMaterial.shader = Service.Get <AssetManager>().Shaders.GetShader("TransportShadow");
                }
            }
            else
            {
                this.UnloadShuttle(shuttleAnim);
            }
            StorageSpreadUtils.UpdateAllStarportFullnessMeters();
        }