Beispiel #1
0
        private List <string> GetEffectNames(string planetaryFx)
        {
            if (string.IsNullOrEmpty(planetaryFx))
            {
                return(null);
            }
            List <string>        list = new List <string>();
            StaticDataController staticDataController = Service.StaticDataController;

            char[] separator = new char[]
            {
                '|'
            };
            string[] array = planetaryFx.Split(separator);
            int      i     = 0;
            int      num   = array.Length;

            while (i < num)
            {
                EffectsTypeVO optional = staticDataController.GetOptional <EffectsTypeVO>(array[i]);
                if (optional == null || string.IsNullOrEmpty(optional.AssetName))
                {
                    return(null);
                }
                list.Add(optional.AssetName);
                i++;
            }
            return(list);
        }
Beispiel #2
0
        public static string GetDebrisAssetNameForEntity(SmartEntity entity, bool isBuilding)
        {
            SizeComponent sizeComp = entity.SizeComp;
            int           val      = Units.BoardToGridX(sizeComp.Width);
            int           val2     = Units.BoardToGridZ(sizeComp.Depth);
            int           num      = Math.Min(val, val2);
            string        uid;

            if (isBuilding)
            {
                BuildingTypeVO buildingType = entity.BuildingComp.BuildingType;
                string         text         = string.IsNullOrEmpty(buildingType.DestructFX) ? "fx_debris_{0}x{1}" : buildingType.DestructFX;
                BuildingType   type         = buildingType.Type;
                if (type != BuildingType.Wall)
                {
                    if (type != BuildingType.Turret)
                    {
                        if (type != BuildingType.ShieldGenerator)
                        {
                            uid = string.Format(text, new object[]
                            {
                                num,
                                num
                            });
                        }
                        else
                        {
                            uid = "fx_debris_6x6";
                        }
                    }
                    else
                    {
                        uid = ((buildingType.Faction == FactionType.Tusken) ? "effect176" : string.Format(text, new object[]
                        {
                            num,
                            num
                        }));
                    }
                }
                else
                {
                    uid = "effect176";
                }
            }
            else
            {
                uid = string.Format("fx_vehdebris_{0}x{1}", new object[]
                {
                    num,
                    num
                });
            }
            EffectsTypeVO effectsTypeVO = Service.Get <IDataController>().Get <EffectsTypeVO>(uid);

            return(effectsTypeVO.AssetName);
        }
Beispiel #3
0
 private static void AddSpawnEffect(TroopTypeVO troopType, List <IAssetVO> assets, StaticDataController dc)
 {
     if (troopType != null)
     {
         string spawnEffectUid = troopType.SpawnEffectUid;
         if (!string.IsNullOrEmpty(spawnEffectUid))
         {
             EffectsTypeVO item = dc.Get <EffectsTypeVO>(spawnEffectUid);
             assets.Add(item);
         }
     }
 }
Beispiel #4
0
        protected void PlaySpawnEffect(SmartEntity entity)
        {
            StaticDataController staticDataController = Service.StaticDataController;
            TroopTypeVO          troopTypeVO          = staticDataController.Get <TroopTypeVO>(entity.TroopComp.TroopType.Uid);
            string spawnEffectUid = troopTypeVO.SpawnEffectUid;

            if (!string.IsNullOrEmpty(spawnEffectUid))
            {
                EffectsTypeVO effectsTypeVO = Service.StaticDataController.Get <EffectsTypeVO>(spawnEffectUid);
                Service.FXManager.CreateAndAttachFXToEntity(entity, effectsTypeVO.AssetName, "SpawnEffect" + entity.ID.ToString(), null, false, Vector3.zero, true);
                Service.BattleController.CameraShakeObj.Shake(0.5f, 0.25f);
            }
        }
Beispiel #5
0
        public void UpdateChampionAnimationStateInHomeOrWarBoardMode(SmartEntity entity, bool underRepair)
        {
            if (entity.GameObjectViewComp == null)
            {
                return;
            }
            EffectsTypeVO effectsTypeVO = Service.Get <IDataController>().Get <EffectsTypeVO>("effectSmoke");
            Animator      component     = entity.GameObjectViewComp.MainGameObject.GetComponent <Animator>();

            if (underRepair)
            {
                component.SetInteger("Motivation", 8);
                Service.Get <FXManager>().CreateAndAttachFXToEntity(entity, effectsTypeVO.AssetName, "effectSmoke" + entity.ID.ToString(), null, false, Vector3.zero, true);
                return;
            }
            component.SetInteger("Motivation", 0);
            Service.Get <FXManager>().RemoveAttachedFXFromEntity(entity, "effectSmoke" + entity.ID.ToString());
        }
Beispiel #6
0
        private void PrepareEntityView(SmartEntity entity, GameObject gameObject)
        {
            EntityRef entityRef = gameObject.AddComponent <EntityRef>();

            entityRef.Entity = entity;
            StaticDataController    staticDataController = Service.StaticDataController;
            GameObjectViewComponent gameObjectViewComponent;

            if (entity.GameObjectViewComp != null)
            {
                gameObjectViewComponent = entity.GameObjectViewComp;
                Vector3 position = gameObjectViewComponent.MainTransform.position;
                UnityEngine.Object.Destroy(gameObjectViewComponent.MainGameObject);
                gameObjectViewComponent.MainGameObject         = gameObject;
                gameObjectViewComponent.MainTransform.position = position;
            }
            else
            {
                float tooltipHeightOffset = 0f;
                if (entity.BuildingComp != null)
                {
                    tooltipHeightOffset = entity.BuildingComp.BuildingType.TooltipHeightOffset;
                    EffectsTypeVO effectsTypeVO = staticDataController.Get <EffectsTypeVO>("effect203");
                    AssetManager  assetManager  = Service.AssetManager;
                    assetManager.RegisterPreloadableAsset(effectsTypeVO.AssetName);
                    AssetHandle assetHandle = AssetHandle.Invalid;
                    assetManager.Load(ref assetHandle, effectsTypeVO.AssetName, new AssetSuccessDelegate(this.SparkFxSuccess), null, entity);
                }
                else if (entity.TroopComp != null)
                {
                    TroopTypeVO troopTypeVO = Service.StaticDataController.Get <TroopTypeVO>(entity.TroopComp.TroopType.Uid);
                    tooltipHeightOffset = troopTypeVO.TooltipHeightOffset;
                }
                gameObjectViewComponent = new GameObjectViewComponent(gameObject, tooltipHeightOffset);
                entity.Add(gameObjectViewComponent);
            }
            SupportComponent     supportComp     = entity.SupportComp;
            SupportViewComponent supportViewComp = entity.SupportViewComp;

            if (supportComp != null && supportViewComp == null)
            {
                SupportViewComponent component = new SupportViewComponent();
                entity.Add <SupportViewComponent>(component);
                if (Service.BuildingController.PurchasingBuilding != entity)
                {
                    Service.BuildingTooltipController.EnsureBuildingTooltip(entity);
                }
            }
            GeneratorComponent     generatorComp          = entity.GeneratorComp;
            GeneratorViewComponent generatorViewComponent = entity.GeneratorViewComp;

            if (generatorComp != null && generatorViewComponent == null)
            {
                generatorViewComponent = new GeneratorViewComponent(entity);
                entity.Add <GeneratorViewComponent>(generatorViewComponent);
            }
            TrapComponent     trapComp          = entity.TrapComp;
            TrapViewComponent trapViewComponent = entity.TrapViewComp;

            if (trapComp != null && trapViewComponent == null)
            {
                Animator  component2 = gameObjectViewComponent.MainGameObject.GetComponent <Animator>();
                Transform transform  = gameObjectViewComponent.MainGameObject.transform.Find("Contents");
                if (component2 == null)
                {
                    Service.Logger.ErrorFormat("A trap has been added that does not have a MecAnim controller. Building Uid: {0}, AssetName: {1}", new object[]
                    {
                        entity.BuildingComp.BuildingType.Uid,
                        entity.BuildingComp.BuildingType.AssetName
                    });
                }
                else if (transform == null)
                {
                    Service.Logger.ErrorFormat("A trap has been added that does not have a Contents transform. Building Uid: {0}, AssetName: {1}", new object[]
                    {
                        entity.BuildingComp.BuildingType.Uid,
                        entity.BuildingComp.BuildingType.AssetName
                    });
                }
                else
                {
                    GameObject gameObject2 = transform.gameObject;
                    if (gameObject2 == null)
                    {
                        Service.Logger.ErrorFormat("A trap has been added that does not have a Contents GameObject. Building Uid: {0}, AssetName: {1}", new object[]
                        {
                            entity.BuildingComp.BuildingType.Uid,
                            entity.BuildingComp.BuildingType.AssetName
                        });
                    }
                    trapViewComponent = new TrapViewComponent(component2);
                    if (trapComp.Type.EventType == TrapEventType.Turret)
                    {
                        Transform transform2 = gameObjectViewComponent.MainGameObject.transform;
                        Transform transform3 = transform2.Find(trapComp.Type.TurretTED.TurretAnimatorName);
                        if (transform3 == null)
                        {
                            Service.Logger.ErrorFormat("Trap {0}: Cannot find a gameobject in path {1}", new object[]
                            {
                                entity.BuildingComp.BuildingType.Uid,
                                trapComp.Type.TurretTED.TurretAnimatorName
                            });
                        }
                        else
                        {
                            Animator component3 = transform3.gameObject.GetComponent <Animator>();
                            if (component3 == null)
                            {
                                Service.Logger.ErrorFormat("Trap {0}: Cannot find an animator on gameobject in path {1}", new object[]
                                {
                                    entity.BuildingComp.BuildingType.Uid,
                                    trapComp.Type.TurretTED.TurretAnimatorName
                                });
                            }
                            else
                            {
                                trapViewComponent.TurretAnim = component3;
                            }
                        }
                    }
                    entity.Add <TrapViewComponent>(trapViewComponent);
                }
            }
            AssetMeshDataMonoBehaviour component4 = gameObjectViewComponent.MainGameObject.GetComponent <AssetMeshDataMonoBehaviour>();

            if (component4 != null && component4.OtherGameObjects != null)
            {
                for (int i = 0; i < component4.OtherGameObjects.Count; i++)
                {
                    if (component4.OtherGameObjects[i].name.Contains("center_of_mass"))
                    {
                        gameObjectViewComponent.CenterOfMass = component4.OtherGameObjects[i];
                    }
                    else if (component4.OtherGameObjects[i].name.Contains("locator_hit"))
                    {
                        gameObjectViewComponent.HitLocators.Add(component4.OtherGameObjects[i]);
                    }
                    else if (component4.OtherGameObjects[i].name.Contains("locator_vehicle"))
                    {
                        gameObjectViewComponent.VehicleLocator = component4.OtherGameObjects[i];
                    }
                    else if (component4.OtherGameObjects[i].name.Contains("locator_effect"))
                    {
                        gameObjectViewComponent.EffectLocators.Add(component4.OtherGameObjects[i]);
                    }
                }
            }
            if (entity.TroopComp != null)
            {
                TroopTypeVO troopTypeVO2 = (TroopTypeVO)entity.TroopComp.TroopType;
                if (!string.IsNullOrEmpty(troopTypeVO2.PlanetAttachmentId))
                {
                    string uid = Service.WorldTransitioner.GetMapDataLoader().GetPlanetData().Uid;
                    List <PlanetAttachmentVO> list = new List <PlanetAttachmentVO>();
                    foreach (PlanetAttachmentVO current in staticDataController.GetAll <PlanetAttachmentVO>())
                    {
                        if (current.AttachmentId == troopTypeVO2.PlanetAttachmentId && current.Planets != null && Array.IndexOf <string>(current.Planets, uid) != -1)
                        {
                            list.Add(current);
                        }
                    }
                    AssetManager assetManager2 = Service.AssetManager;
                    for (int j = 0; j < list.Count; j++)
                    {
                        if (list[j] == null)
                        {
                            Service.Logger.ErrorFormat("Attachment is null for troop {0}, asset {1}", new object[]
                            {
                                troopTypeVO2.Uid,
                                troopTypeVO2.AssetName
                            });
                        }
                        else
                        {
                            AssetHandle        assetHandle2       = AssetHandle.Invalid;
                            PlanetAttachmentTO planetAttachmentTO = new PlanetAttachmentTO();
                            planetAttachmentTO.Entity  = entity;
                            planetAttachmentTO.Locator = UnityUtils.FindGameObject(gameObjectViewComponent.MainGameObject, list[j].Locator);
                            if (planetAttachmentTO.Locator == null)
                            {
                                Service.Logger.ErrorFormat("Locator {0} not found in asset {1}, and it should be according to PlanetAttachmentData {2}", new object[]
                                {
                                    list[j].Locator,
                                    troopTypeVO2.AssetName,
                                    list[j].Uid
                                });
                                planetAttachmentTO.Locator = gameObjectViewComponent.MainGameObject;
                            }
                            assetManager2.Load(ref assetHandle2, list[j].AssetName, new AssetSuccessDelegate(this.PlanetAttachmentSuccess), null, planetAttachmentTO);
                        }
                    }
                }
            }
            FactoryComponent factoryComp = entity.FactoryComp;

            if (factoryComp != null)
            {
                EffectsTypeVO effectsTypeVO2 = staticDataController.Get <EffectsTypeVO>("effect203");
                AssetManager  assetManager3  = Service.AssetManager;
                assetManager3.RegisterPreloadableAsset(effectsTypeVO2.AssetName);
                AssetHandle assetHandle3 = AssetHandle.Invalid;
                assetManager3.Load(ref assetHandle3, effectsTypeVO2.AssetName, new AssetSuccessDelegate(this.SparkFxSuccess), null, entity);
            }
            this.SetupGunLocators(entity, component4);
            if (entity.TroopShieldHealthComp != null && entity.TroopShieldViewComp == null)
            {
                TroopTypeVO troop = Service.StaticDataController.Get <TroopTypeVO>(entity.TroopComp.TroopType.Uid);
                entity.Add <TroopShieldViewComponent>(new TroopShieldViewComponent(troop));
            }
            gameObject.SetActive(false);
            this.CheckHealthView(entity);
            this.CheckMeterShaderView(entity);
            Service.EntityRenderController.UpdateNewEntityView(entity);
        }
Beispiel #7
0
        private void PrepareEntityView(SmartEntity entity, GameObject gameObject)
        {
            EntityRef entityRef = gameObject.AddComponent <EntityRef>();

            entityRef.Entity = entity;
            IDataController         dataController = Service.Get <IDataController>();
            GameObjectViewComponent gameObjectViewComponent;

            if (entity.GameObjectViewComp != null)
            {
                gameObjectViewComponent = entity.GameObjectViewComp;
                UnityEngine.Object.Destroy(gameObjectViewComponent.MainGameObject);
                gameObjectViewComponent.MainGameObject = gameObject;
            }
            else
            {
                float tooltipHeightOffset = 0f;
                if (entity.BuildingComp != null)
                {
                    tooltipHeightOffset = entity.BuildingComp.BuildingType.TooltipHeightOffset;
                    EffectsTypeVO effectsTypeVO = dataController.Get <EffectsTypeVO>("effect203");
                    AssetManager  assetManager  = Service.Get <AssetManager>();
                    assetManager.RegisterPreloadableAsset(effectsTypeVO.AssetName);
                    AssetHandle assetHandle = AssetHandle.Invalid;
                    assetManager.Load(ref assetHandle, effectsTypeVO.AssetName, new AssetSuccessDelegate(this.SparkFxSuccess), null, entity);
                }
                else if (entity.TroopComp != null)
                {
                    TroopTypeVO troopTypeVO = Service.Get <IDataController>().Get <TroopTypeVO>(entity.TroopComp.TroopType.Uid);
                    tooltipHeightOffset = troopTypeVO.TooltipHeightOffset;
                }
                gameObjectViewComponent = new GameObjectViewComponent(gameObject, tooltipHeightOffset);
                entity.Add(gameObjectViewComponent);
            }
            SupportComponent     supportComp     = entity.SupportComp;
            SupportViewComponent supportViewComp = entity.SupportViewComp;

            if (supportComp != null && supportViewComp == null)
            {
                SupportViewComponent component = new SupportViewComponent();
                entity.Add <SupportViewComponent>(component);
                if (Service.Get <BuildingController>().PurchasingBuilding != entity)
                {
                    Service.Get <BuildingTooltipController>().EnsureBuildingTooltip(entity);
                }
            }
            GeneratorComponent     generatorComp          = entity.GeneratorComp;
            GeneratorViewComponent generatorViewComponent = entity.GeneratorViewComp;

            if (generatorComp != null && generatorViewComponent == null)
            {
                generatorViewComponent = new GeneratorViewComponent(entity);
                entity.Add <GeneratorViewComponent>(generatorViewComponent);
            }
            TrapComponent     trapComp          = entity.TrapComp;
            TrapViewComponent trapViewComponent = entity.TrapViewComp;

            if (trapComp != null && trapViewComponent == null)
            {
                Animator  component2 = gameObjectViewComponent.MainGameObject.GetComponent <Animator>();
                Transform transform  = gameObjectViewComponent.MainGameObject.transform.FindChild("Contents");
                if (component2 == null)
                {
                    Service.Get <StaRTSLogger>().ErrorFormat("A trap has been added that does not have a MecAnim controller. Building Uid: {0}, AssetName: {1}", new object[]
                    {
                        entity.BuildingComp.BuildingType.Uid,
                        entity.BuildingComp.BuildingType.AssetName
                    });
                }
                else if (transform == null)
                {
                    Service.Get <StaRTSLogger>().ErrorFormat("A trap has been added that does not have a Contents transform. Building Uid: {0}, AssetName: {1}", new object[]
                    {
                        entity.BuildingComp.BuildingType.Uid,
                        entity.BuildingComp.BuildingType.AssetName
                    });
                }
                else
                {
                    GameObject gameObject2 = transform.gameObject;
                    if (gameObject2 == null)
                    {
                        Service.Get <StaRTSLogger>().ErrorFormat("A trap has been added that does not have a Contents GameObject. Building Uid: {0}, AssetName: {1}", new object[]
                        {
                            entity.BuildingComp.BuildingType.Uid,
                            entity.BuildingComp.BuildingType.AssetName
                        });
                    }
                    trapViewComponent = new TrapViewComponent(component2);
                    if (trapComp.Type.EventType == TrapEventType.Turret)
                    {
                        Transform transform2 = gameObjectViewComponent.MainGameObject.transform;
                        Transform transform3 = transform2.FindChild(trapComp.Type.TurretTED.TurretAnimatorName);
                        if (transform3 == null)
                        {
                            Service.Get <StaRTSLogger>().ErrorFormat("Trap {0}: Cannot find a gameobject in path {1}", new object[]
                            {
                                entity.BuildingComp.BuildingType.Uid,
                                trapComp.Type.TurretTED.TurretAnimatorName
                            });
                        }
                        else
                        {
                            Animator component3 = transform3.gameObject.GetComponent <Animator>();
                            if (component3 == null)
                            {
                                Service.Get <StaRTSLogger>().ErrorFormat("Trap {0}: Cannot find an animator on gameobject in path {1}", new object[]
                                {
                                    entity.BuildingComp.BuildingType.Uid,
                                    trapComp.Type.TurretTED.TurretAnimatorName
                                });
                            }
                            else
                            {
                                trapViewComponent.TurretAnim = component3;
                            }
                        }
                    }
                    entity.Add <TrapViewComponent>(trapViewComponent);
                }
            }
            AssetMeshDataMonoBehaviour component4 = gameObjectViewComponent.MainGameObject.GetComponent <AssetMeshDataMonoBehaviour>();

            if (component4 != null && component4.OtherGameObjects != null)
            {
                for (int i = 0; i < component4.OtherGameObjects.Count; i++)
                {
                    if (component4.OtherGameObjects[i].name.Contains("center_of_mass"))
                    {
                        gameObjectViewComponent.CenterOfMass = component4.OtherGameObjects[i];
                    }
                    else if (component4.OtherGameObjects[i].name.Contains("locator_hit"))
                    {
                        gameObjectViewComponent.HitLocators.Add(component4.OtherGameObjects[i]);
                    }
                    else if (component4.OtherGameObjects[i].name.Contains("locator_vehicle"))
                    {
                        gameObjectViewComponent.VehicleLocator = component4.OtherGameObjects[i];
                    }
                    else if (component4.OtherGameObjects[i].name.Contains("locator_effect"))
                    {
                        gameObjectViewComponent.EffectLocators.Add(component4.OtherGameObjects[i]);
                    }
                }
            }
            FactoryComponent factoryComp = entity.FactoryComp;

            if (factoryComp != null)
            {
                EffectsTypeVO effectsTypeVO2 = dataController.Get <EffectsTypeVO>("effect203");
                AssetManager  assetManager2  = Service.Get <AssetManager>();
                assetManager2.RegisterPreloadableAsset(effectsTypeVO2.AssetName);
                AssetHandle assetHandle2 = AssetHandle.Invalid;
                assetManager2.Load(ref assetHandle2, effectsTypeVO2.AssetName, new AssetSuccessDelegate(this.SparkFxSuccess), null, entity);
            }
            this.SetupGunLocators(entity, component4);
            if (entity.TroopShieldHealthComp != null && entity.TroopShieldViewComp == null)
            {
                TroopTypeVO troop = Service.Get <IDataController>().Get <TroopTypeVO>(entity.TroopComp.TroopType.Uid);
                entity.Add <TroopShieldViewComponent>(new TroopShieldViewComponent(troop));
            }
            gameObject.SetActive(false);
            this.CheckHealthView(entity);
            this.CheckMeterShaderView(entity);
            Service.Get <EntityRenderController>().UpdateNewEntityView(entity);
        }