public void SetTrapState(TrapComponent comp, TrapState state) { SmartEntity smartEntity = (SmartEntity)comp.Entity; TrapViewComponent trapViewComp = smartEntity.TrapViewComp; TrapState currentState = comp.CurrentState; if (currentState != state) { comp.CurrentState = state; IState currentState2 = Service.Get <GameStateMachine>().CurrentState; if (TrapUtils.IsCurrentPlayerInDefensiveBattle(currentState2)) { smartEntity.BuildingComp.BuildingTO.CurrentStorage = ((state == TrapState.Armed) ? 1 : 0); } Service.Get <TrapViewController>().UpdateTrapVisibility((SmartEntity)comp.Entity); switch (state) { case TrapState.Spent: Service.Get <EventManager>().SendEvent(EventId.TrapDisarmed, comp); break; case TrapState.Active: Service.Get <EventManager>().SendEvent(EventId.TrapTriggered, comp); break; case TrapState.Destroyed: comp.CurrentState = TrapState.Spent; Service.Get <EventManager>().SendEvent(EventId.TrapDestroyed, comp); break; } } Service.Get <TrapViewController>().SetTrapViewState(trapViewComp, state); }
public void SetTrapViewState(TrapViewComponent view, TrapState state) { if (view != null) { if (view.PendingStates.Count == 0) { view.Anim.SetInteger("trapAnimState", (int)state); } view.PendingStates.Add(state); this.RegisterObservers(); } }
public void UpdateTrapVisibility(SmartEntity entity) { if (entity.TrapViewComp == null) { return; } TrapViewComponent trapViewComp = entity.TrapViewComp; IState currentState = Service.GameStateMachine.CurrentState; bool flag = currentState is BattleStartState || currentState is BattlePlayState || currentState is BattlePlaybackState || currentState is BattleEndState; bool flag2 = GameUtils.IsVisitingBase(); bool flag3 = TrapUtils.IsCurrentPlayerInDefensiveBattle(currentState); bool flag4 = (flag && !flag3) || flag2; trapViewComp.Anim.SetLayerWeight(1, (float)((!flag4) ? 1 : 0)); trapViewComp.Anim.SetLayerWeight(0, (float)((!flag4) ? 0 : 1)); bool active = false; if (!flag2) { switch (entity.TrapComp.CurrentState) { case TrapState.Spent: active = (!flag || flag3 || entity.TrapComp.PreviousState == TrapState.Active); break; case TrapState.Armed: active = (!flag || flag3); break; case TrapState.Active: active = true; break; case TrapState.Destroyed: active = flag; break; } } trapViewComp.Contents.SetActive(active); }
public void SetTrapState(TrapComponent comp, TrapState state) { SmartEntity smartEntity = (SmartEntity)comp.Entity; TrapViewComponent trapViewComp = smartEntity.TrapViewComp; TrapState currentState = comp.CurrentState; if (currentState != state) { comp.CurrentState = state; IState currentState2 = Service.GameStateMachine.CurrentState; if (TrapUtils.IsCurrentPlayerInDefensiveBattle(currentState2)) { smartEntity.BuildingComp.BuildingTO.CurrentStorage = ((state != TrapState.Armed) ? 0 : 1); } Service.TrapViewController.UpdateTrapVisibility((SmartEntity)comp.Entity); if (state != TrapState.Active) { if (state != TrapState.Spent) { if (state == TrapState.Destroyed) { comp.CurrentState = TrapState.Spent; Service.EventManager.SendEvent(EventId.TrapDestroyed, comp); } } else { Service.EventManager.SendEvent(EventId.TrapDisarmed, comp); } } else { Service.EventManager.SendEvent(EventId.TrapTriggered, comp); } } Service.TrapViewController.SetTrapViewState(trapViewComp, state); }
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); }
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)); }
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)); }
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); }