Exemplo n.º 1
0
        public void HideBuildingTooltip(SmartEntity building)
        {
            SupportViewComponent supportViewComp = building.SupportViewComp;

            if (supportViewComp != null)
            {
                supportViewComp.TeardownElements();
            }
        }
Exemplo n.º 2
0
        private void UpdateAllStarportTooltips()
        {
            NodeList <StarportNode> starportNodeList = Service.BuildingLookupController.StarportNodeList;

            for (StarportNode starportNode = starportNodeList.Head; starportNode != null; starportNode = starportNode.Next)
            {
                SupportViewComponent supportViewComponent = starportNode.Entity.Get <SupportViewComponent>();
                if (supportViewComponent != null)
                {
                    supportViewComponent.TeardownElements();
                    this.EnsureBuildingTooltip((SmartEntity)supportViewComponent.Entity);
                }
            }
        }
Exemplo n.º 3
0
        private void StartHealthRepair(HealthViewComponent healthView)
        {
            this.repairing = true;
            healthView.AutoRegenerating = true;
            Entity entity = healthView.Entity;

            this.eventManager.SendEvent(EventId.EntityPostBattleRepairStarted, entity);
            SupportViewComponent supportViewComponent = entity.Get <SupportViewComponent>();

            if (supportViewComponent != null)
            {
                supportViewComponent.TeardownElements();
            }
            GeneratorViewComponent generatorViewComponent = entity.Get <GeneratorViewComponent>();

            if (generatorViewComponent != null)
            {
                generatorViewComponent.SetEnabled(false);
            }
            BuildingComponent buildingComponent = entity.Get <BuildingComponent>();

            Service.Get <StorageEffects>().UpdateFillState(entity, buildingComponent.BuildingType);
        }
Exemplo n.º 4
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);
        }
Exemplo n.º 5
0
 public override object Remove(Type compCls)
 {
     if (compCls == typeof(AreaTriggerComponent))
     {
         this.AreaTriggerComp = null;
     }
     else if (compCls == typeof(ArmoryComponent))
     {
         this.ArmoryComp = null;
     }
     else if (compCls == typeof(AssetComponent))
     {
         this.AssetComp = null;
     }
     else if (compCls == typeof(AttackerComponent))
     {
         this.AttackerComp = null;
     }
     else if (compCls == typeof(BarracksComponent))
     {
         this.BarracksComp = null;
     }
     else if (compCls == typeof(BoardItemComponent))
     {
         this.BoardItemComp = null;
     }
     else if (compCls == typeof(BuildingAnimationComponent))
     {
         this.BuildingAnimationComp = null;
     }
     else if (compCls == typeof(BuildingComponent))
     {
         this.BuildingComp = null;
     }
     else if (compCls == typeof(CantinaComponent))
     {
         this.CantinaComp = null;
     }
     else if (compCls == typeof(ChampionComponent))
     {
         this.ChampionComp = null;
     }
     else if (compCls == typeof(CivilianComponent))
     {
         this.CivilianComp = null;
     }
     else if (compCls == typeof(ClearableComponent))
     {
         this.ClearableComp = null;
     }
     else if (compCls == typeof(DamageableComponent))
     {
         this.DamageableComp = null;
     }
     else if (compCls == typeof(DefenderComponent))
     {
         this.DefenderComp = null;
     }
     else if (compCls == typeof(DefenseLabComponent))
     {
         this.DefenseLabComp = null;
     }
     else if (compCls == typeof(DroidComponent))
     {
         this.DroidComp = null;
     }
     else if (compCls == typeof(DroidHutComponent))
     {
         this.DroidHutComp = null;
     }
     else if (compCls == typeof(SquadBuildingComponent))
     {
         this.SquadBuildingComp = null;
     }
     else if (compCls == typeof(NavigationCenterComponent))
     {
         this.NavigationCenterComp = null;
     }
     else if (compCls == typeof(FactoryComponent))
     {
         this.FactoryComp = null;
     }
     else if (compCls == typeof(FleetCommandComponent))
     {
         this.FleetCommandComp = null;
     }
     else if (compCls == typeof(FollowerComponent))
     {
         this.FollowerComp = null;
     }
     else if (compCls == typeof(GameObjectViewComponent))
     {
         this.GameObjectViewComp = null;
     }
     else if (compCls == typeof(GeneratorComponent))
     {
         this.GeneratorComp = null;
     }
     else if (compCls == typeof(GeneratorViewComponent))
     {
         this.GeneratorViewComp = null;
     }
     else if (compCls == typeof(HealerComponent))
     {
         this.HealerComp = null;
     }
     else if (compCls == typeof(HealthComponent))
     {
         this.HealthComp = null;
     }
     else if (compCls == typeof(TroopShieldComponent))
     {
         this.TroopShieldComp = null;
     }
     else if (compCls == typeof(TroopShieldViewComponent))
     {
         this.TroopShieldViewComp = null;
     }
     else if (compCls == typeof(TroopShieldHealthComponent))
     {
         this.TroopShieldHealthComp = null;
     }
     else if (compCls == typeof(HealthViewComponent))
     {
         this.HealthViewComp = null;
     }
     else if (compCls == typeof(HQComponent))
     {
         this.HQComp = null;
     }
     else if (compCls == typeof(KillerComponent))
     {
         this.KillerComp = null;
     }
     else if (compCls == typeof(LootComponent))
     {
         this.LootComp = null;
     }
     else if (compCls == typeof(MeterShaderComponent))
     {
         this.MeterShaderComp = null;
     }
     else if (compCls == typeof(OffenseLabComponent))
     {
         this.OffenseLabComp = null;
     }
     else if (compCls == typeof(PathingComponent))
     {
         this.PathingComp = null;
     }
     else if (compCls == typeof(SecondaryTargetsComponent))
     {
         this.SecondaryTargetsComp = null;
     }
     else if (compCls == typeof(ShieldBorderComponent))
     {
         this.ShieldBorderComp = null;
     }
     else if (compCls == typeof(ShieldGeneratorComponent))
     {
         this.ShieldGeneratorComp = null;
     }
     else if (compCls == typeof(SizeComponent))
     {
         this.SizeComp = null;
     }
     else if (compCls == typeof(ShooterComponent))
     {
         this.ShooterComp = null;
     }
     else if (compCls == typeof(StarportComponent))
     {
         this.StarportComp = null;
     }
     else if (compCls == typeof(StateComponent))
     {
         this.StateComp = null;
     }
     else if (compCls == typeof(StorageComponent))
     {
         this.StorageComp = null;
     }
     else if (compCls == typeof(SupportComponent))
     {
         this.SupportComp = null;
     }
     else if (compCls == typeof(SupportViewComponent))
     {
         this.SupportViewComp = null;
     }
     else if (compCls == typeof(TacticalCommandComponent))
     {
         this.TacticalCommandComp = null;
     }
     else if (compCls == typeof(ChampionPlatformComponent))
     {
         this.ChampionPlatformComp = null;
     }
     else if (compCls == typeof(TeamComponent))
     {
         this.TeamComp = null;
     }
     else if (compCls == typeof(TrackingComponent))
     {
         this.TrackingComp = null;
     }
     else if (compCls == typeof(TrackingGameObjectViewComponent))
     {
         this.TrackingGameObjectViewComp = null;
     }
     else if (compCls == typeof(TransformComponent))
     {
         this.TransformComp = null;
     }
     else if (compCls == typeof(TransportComponent))
     {
         this.TransportComp = null;
     }
     else if (compCls == typeof(TroopComponent))
     {
         this.TroopComp = null;
     }
     else if (compCls == typeof(TurretBuildingComponent))
     {
         this.TurretBuildingComp = null;
     }
     else if (compCls == typeof(TurretShooterComponent))
     {
         this.TurretShooterComp = null;
     }
     else if (compCls == typeof(WalkerComponent))
     {
         this.WalkerComp = null;
     }
     else if (compCls == typeof(WallComponent))
     {
         this.WallComp = null;
     }
     else if (compCls == typeof(BuffComponent))
     {
         this.BuffComp = null;
     }
     else if (compCls == typeof(TrapComponent))
     {
         this.TrapComp = null;
     }
     else if (compCls == typeof(TrapViewComponent))
     {
         this.TrapViewComp = null;
     }
     else if (compCls == typeof(HousingComponent))
     {
         this.HousingComp = null;
     }
     else if (compCls == typeof(SpawnComponent))
     {
         this.SpawnComp = null;
     }
     return(base.Remove(compCls));
 }
Exemplo n.º 6
0
        protected override Entity AddComponentAndDispatchAddEvent(ComponentBase comp, Type compCls)
        {
            bool flag = false;

            if (comp is AreaTriggerComponent)
            {
                this.AreaTriggerComp = (AreaTriggerComponent)comp;
                flag = true;
            }
            if (comp is ArmoryComponent)
            {
                this.ArmoryComp = (ArmoryComponent)comp;
                flag            = true;
            }
            if (comp is AssetComponent)
            {
                this.AssetComp = (AssetComponent)comp;
                flag           = true;
            }
            if (comp is AttackerComponent)
            {
                this.AttackerComp = (AttackerComponent)comp;
                flag = true;
            }
            if (comp is BarracksComponent)
            {
                this.BarracksComp = (BarracksComponent)comp;
                flag = true;
            }
            if (comp is BoardItemComponent)
            {
                this.BoardItemComp = (BoardItemComponent)comp;
                flag = true;
            }
            if (comp is BuildingAnimationComponent)
            {
                this.BuildingAnimationComp = (BuildingAnimationComponent)comp;
                flag = true;
            }
            if (comp is BuildingComponent)
            {
                this.BuildingComp = (BuildingComponent)comp;
                flag = true;
            }
            if (comp is ChampionComponent)
            {
                this.ChampionComp = (ChampionComponent)comp;
                flag = true;
            }
            if (comp is CivilianComponent)
            {
                this.CivilianComp = (CivilianComponent)comp;
                flag = true;
            }
            if (comp is ClearableComponent)
            {
                this.ClearableComp = (ClearableComponent)comp;
                flag = true;
            }
            if (comp is DamageableComponent)
            {
                this.DamageableComp = (DamageableComponent)comp;
                flag = true;
            }
            if (comp is DefenderComponent)
            {
                this.DefenderComp = (DefenderComponent)comp;
                flag = true;
            }
            if (comp is DefenseLabComponent)
            {
                this.DefenseLabComp = (DefenseLabComponent)comp;
                flag = true;
            }
            if (comp is DroidComponent)
            {
                this.DroidComp = (DroidComponent)comp;
                flag           = true;
            }
            if (comp is DroidHutComponent)
            {
                this.DroidHutComp = (DroidHutComponent)comp;
                flag = true;
            }
            if (comp is SquadBuildingComponent)
            {
                this.SquadBuildingComp = (SquadBuildingComponent)comp;
                flag = true;
            }
            if (comp is NavigationCenterComponent)
            {
                this.NavigationCenterComp = (NavigationCenterComponent)comp;
                flag = true;
            }
            if (comp is FactoryComponent)
            {
                this.FactoryComp = (FactoryComponent)comp;
                flag             = true;
            }
            if (comp is CantinaComponent)
            {
                this.CantinaComp = (CantinaComponent)comp;
                flag             = true;
            }
            if (comp is FleetCommandComponent)
            {
                this.FleetCommandComp = (FleetCommandComponent)comp;
                flag = true;
            }
            if (comp is FollowerComponent)
            {
                this.FollowerComp = (FollowerComponent)comp;
                flag = true;
            }
            if (comp is GameObjectViewComponent)
            {
                this.GameObjectViewComp = (GameObjectViewComponent)comp;
                flag = true;
            }
            if (comp is GeneratorComponent)
            {
                this.GeneratorComp = (GeneratorComponent)comp;
                flag = true;
            }
            if (comp is GeneratorViewComponent)
            {
                this.GeneratorViewComp = (GeneratorViewComponent)comp;
                flag = true;
            }
            if (comp is HealerComponent)
            {
                this.HealerComp = (HealerComponent)comp;
                flag            = true;
            }
            if (comp is TroopShieldComponent)
            {
                this.TroopShieldComp = (TroopShieldComponent)comp;
                flag = true;
            }
            if (comp is TroopShieldViewComponent)
            {
                this.TroopShieldViewComp = (TroopShieldViewComponent)comp;
                flag = true;
            }
            if (comp is TroopShieldHealthComponent)
            {
                this.TroopShieldHealthComp = (TroopShieldHealthComponent)comp;
                flag = true;
            }
            if (comp is HealthComponent)
            {
                this.HealthComp = (HealthComponent)comp;
                flag            = true;
            }
            if (comp is HealthViewComponent)
            {
                this.HealthViewComp = (HealthViewComponent)comp;
                flag = true;
            }
            if (comp is HQComponent)
            {
                this.HQComp = (HQComponent)comp;
                flag        = true;
            }
            if (comp is KillerComponent)
            {
                this.KillerComp = (KillerComponent)comp;
                flag            = true;
            }
            if (comp is LootComponent)
            {
                this.LootComp = (LootComponent)comp;
                flag          = true;
            }
            if (comp is MeterShaderComponent)
            {
                this.MeterShaderComp = (MeterShaderComponent)comp;
                flag = true;
            }
            if (comp is OffenseLabComponent)
            {
                this.OffenseLabComp = (OffenseLabComponent)comp;
                flag = true;
            }
            if (comp is PathingComponent)
            {
                this.PathingComp = (PathingComponent)comp;
                flag             = true;
            }
            if (comp is SecondaryTargetsComponent)
            {
                this.SecondaryTargetsComp = (SecondaryTargetsComponent)comp;
                flag = true;
            }
            if (comp is ShieldBorderComponent)
            {
                this.ShieldBorderComp = (ShieldBorderComponent)comp;
                flag = true;
            }
            if (comp is ShieldGeneratorComponent)
            {
                this.ShieldGeneratorComp = (ShieldGeneratorComponent)comp;
                flag = true;
            }
            if (comp is SizeComponent)
            {
                this.SizeComp = (SizeComponent)comp;
                flag          = true;
            }
            if (comp is ShooterComponent)
            {
                this.ShooterComp = (ShooterComponent)comp;
                flag             = true;
            }
            if (comp is StarportComponent)
            {
                this.StarportComp = (StarportComponent)comp;
                flag = true;
            }
            if (comp is StateComponent)
            {
                this.StateComp = (StateComponent)comp;
                flag           = true;
            }
            if (comp is StorageComponent)
            {
                this.StorageComp = (StorageComponent)comp;
                flag             = true;
            }
            if (comp is SupportComponent)
            {
                this.SupportComp = (SupportComponent)comp;
                flag             = true;
            }
            if (comp is SupportViewComponent)
            {
                this.SupportViewComp = (SupportViewComponent)comp;
                flag = true;
            }
            if (comp is TacticalCommandComponent)
            {
                this.TacticalCommandComp = (TacticalCommandComponent)comp;
                flag = true;
            }
            if (comp is ChampionPlatformComponent)
            {
                this.ChampionPlatformComp = (ChampionPlatformComponent)comp;
                flag = true;
            }
            if (comp is TeamComponent)
            {
                this.TeamComp = (TeamComponent)comp;
                flag          = true;
            }
            if (comp is TrackingComponent)
            {
                this.TrackingComp = (TrackingComponent)comp;
                flag = true;
            }
            if (comp is TrackingGameObjectViewComponent)
            {
                this.TrackingGameObjectViewComp = (TrackingGameObjectViewComponent)comp;
                flag = true;
            }
            if (comp is TransformComponent)
            {
                this.TransformComp = (TransformComponent)comp;
                flag = true;
            }
            if (comp is TransportComponent)
            {
                this.TransportComp = (TransportComponent)comp;
                flag = true;
            }
            if (comp is TroopComponent)
            {
                this.TroopComp = (TroopComponent)comp;
                flag           = true;
            }
            if (comp is TurretBuildingComponent)
            {
                this.TurretBuildingComp = (TurretBuildingComponent)comp;
                flag = true;
            }
            if (comp is TurretShooterComponent)
            {
                this.TurretShooterComp = (TurretShooterComponent)comp;
                flag = true;
            }
            if (comp is WalkerComponent)
            {
                this.WalkerComp = (WalkerComponent)comp;
                flag            = true;
            }
            if (comp is WallComponent)
            {
                this.WallComp = (WallComponent)comp;
                flag          = true;
            }
            if (comp is BuffComponent)
            {
                this.BuffComp = (BuffComponent)comp;
                flag          = true;
            }
            if (comp is TrapComponent)
            {
                this.TrapComp = (TrapComponent)comp;
                flag          = true;
            }
            if (comp is TrapViewComponent)
            {
                this.TrapViewComp = (TrapViewComponent)comp;
                flag = true;
            }
            if (comp is HousingComponent)
            {
                this.HousingComp = (HousingComponent)comp;
                flag             = true;
            }
            if (comp is ScoutTowerComponent)
            {
                this.ScoutTowerComp = (ScoutTowerComponent)comp;
                flag = true;
            }
            if (comp is SpawnComponent)
            {
                this.SpawnComp = (SpawnComponent)comp;
                flag           = true;
            }
            if (!flag && compCls != null)
            {
                Service.Logger.Error("Invalid component add: " + compCls.Name);
            }
            return(base.AddComponentAndDispatchAddEvent(comp, compCls));
        }
Exemplo n.º 7
0
        public void EnsureBuildingTooltip(SmartEntity building)
        {
            if (building == null || building.SupportViewComp == null || Service.PostBattleRepairController.IsEntityInRepair(building))
            {
                return;
            }
            SupportViewComponent supportViewComp = building.SupportViewComp;
            BuildingComponent    buildingComp    = building.BuildingComp;
            BuildingTypeVO       buildingType    = buildingComp.BuildingType;

            if (!supportViewComp.Enabled)
            {
                return;
            }
            IState currentState = Service.GameStateMachine.CurrentState;

            if (currentState is WarBoardState)
            {
                return;
            }
            bool                      flag                      = currentState is HomeState;
            bool                      editState                 = currentState is EditBaseState;
            bool                      baseLayoutState           = currentState is BaseLayoutToolState;
            int                       num                       = -1;
            int                       timeTotal                 = -1;
            string                    text                      = null;
            IUpgradeableVO            iconAsset                 = null;
            bool                      flag2                     = Service.BuildingController.SelectedBuilding == building;
            SupportViewComponentState supportViewComponentState = SupportViewComponentState.Dormant;
            Contract                  contract                  = Service.ISupportController.FindCurrentContract(buildingComp.BuildingTO.Key);

            if (contract != null)
            {
                if (this.ShouldShowProgress(contract, flag, editState, baseLayoutState, building))
                {
                    int remainingTimeForView = contract.GetRemainingTimeForView();
                    if (remainingTimeForView <= 0 || !Service.ISupportController.IsContractValidForStorage(contract))
                    {
                        text = Service.Lang.Get("STOPPED", new object[0]);
                        supportViewComponentState = SupportViewComponentState.Bubble;
                    }
                    else
                    {
                        num       = remainingTimeForView;
                        timeTotal = contract.TotalTime;
                        if (this.ShouldShowIcon(contract.DeliveryType, flag))
                        {
                            StaticDataController staticDataController = Service.StaticDataController;
                            DeliveryType         deliveryType         = contract.DeliveryType;
                            if (deliveryType != DeliveryType.UpgradeStarship)
                            {
                                if (deliveryType == DeliveryType.UpgradeEquipment)
                                {
                                    iconAsset = staticDataController.Get <EquipmentVO>(contract.ProductUid);
                                    goto IL_19B;
                                }
                                if (deliveryType != DeliveryType.Starship)
                                {
                                    iconAsset = staticDataController.Get <TroopTypeVO>(contract.ProductUid);
                                    goto IL_19B;
                                }
                            }
                            iconAsset = staticDataController.Get <SpecialAttackTypeVO>(contract.ProductUid);
IL_19B:
                            supportViewComponentState = SupportViewComponentState.IconProgress;
                        }
                        else
                        {
                            supportViewComponentState = SupportViewComponentState.Progress;
                        }
                    }
                }
            }
            else
            {
                text = this.GetBubbleText(building, flag, editState, flag2);
                if (text != null)
                {
                    supportViewComponentState = this.GetBubbleViewComponentStateBasedOnBuilding(building);
                }
            }
            if (flag2 && flag && supportViewComponentState == SupportViewComponentState.Dormant && buildingType.Type == BuildingType.Starport)
            {
                supportViewComponentState = SupportViewComponentState.General;
            }
            if (supportViewComponentState != SupportViewComponentState.Dormant)
            {
                bool            flag3 = supportViewComponentState == supportViewComp.State;
                BuildingTooltip buildingTooltip;
                if (flag3)
                {
                    buildingTooltip = supportViewComp.BuildingTooltip;
                }
                else
                {
                    supportViewComp.TeardownElements();
                    UXController            uXController        = Service.UXController;
                    MiscElementsManager     miscElementsManager = uXController.MiscElementsManager;
                    GameObjectViewComponent gameObjectViewComp  = building.GameObjectViewComp;
                    string     str           = gameObjectViewComp.MainGameObject.GetInstanceID().ToString();
                    string     name          = "BuildingTooltip" + str;
                    GameObject worldUIParent = Service.UXController.WorldUIParent;
                    switch (supportViewComponentState)
                    {
                    case SupportViewComponentState.Bubble:
                        if (buildingType.Type == BuildingType.ChampionPlatform)
                        {
                            buildingTooltip = miscElementsManager.CreateBubbleRepairTooltip(name, worldUIParent);
                        }
                        else
                        {
                            buildingTooltip = miscElementsManager.CreateBubbleTooltip(name, worldUIParent);
                        }
                        break;

                    case SupportViewComponentState.BubbleHQ:
                    case SupportViewComponentState.BubbleArmoryUpgrade:
                    case SupportViewComponentState.BubbleShardUpgrade:
                        buildingTooltip = miscElementsManager.CreateHQBubbleTooltip(name, worldUIParent);
                        break;

                    case SupportViewComponentState.Progress:
                        buildingTooltip = miscElementsManager.CreateProgressTooltip(name, worldUIParent);
                        break;

                    case SupportViewComponentState.IconProgress:
                        buildingTooltip = miscElementsManager.CreateIconProgressTooltip(name, worldUIParent);
                        break;

                    default:
                        buildingTooltip = miscElementsManager.CreateGeneralTooltip(name, worldUIParent);
                        break;
                    }
                }
                buildingTooltip.SetSelected(flag2);
                buildingTooltip.SetTitle(this.GetBuildingTitle(buildingType));
                buildingTooltip.SetLevel(buildingType);
                buildingTooltip.SetBubbleText(text);
                buildingTooltip.SetIconAsset(iconAsset);
                buildingTooltip.SetTime(num);
                buildingTooltip.SetProgress(num, timeTotal);
                if (!flag3)
                {
                    supportViewComp.SetupElements(buildingTooltip, supportViewComponentState);
                }
            }
        }
Exemplo n.º 8
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);
        }