public SmartEntity CreateChampionEntity(TroopTypeVO championType, IntPosition position) { SmartEntity smartEntity = this.CreateWalkerBaseEntity(position, championType.SizeX, championType.SizeY); smartEntity.TransformComp.Rotation = 90f; smartEntity.Add(new ChampionComponent(championType)); smartEntity.Add(new WalkerComponent(championType.AssetName, championType)); Service.Get <EntityViewManager>().LoadEntityAsset(smartEntity); return(smartEntity); }
public void AddTurretComponentsToEntity(SmartEntity buildingEntity, TurretTypeVO turretType) { if (buildingEntity.TrackingComp == null) { buildingEntity.Add(new TrackingComponent(turretType, turretType.ProjectileType.Arcs)); } TransformComponent transformComp = buildingEntity.TransformComp; ShooterComponent shooterComponent = new ShooterComponent(turretType); shooterComponent.AttackFSM = new AttackFSM(Service.Get <BattleController>(), buildingEntity, buildingEntity.StateComp, shooterComponent, transformComp, HealthType.Damaging); buildingEntity.Add(shooterComponent); TurretShooterComponent component = new TurretShooterComponent(); buildingEntity.Add(component); }
private void UpdateTroopShield(SmartEntity Entity) { if (Entity.TroopShieldComp == null && Entity.TroopShieldHealthComp != null && !Entity.TroopShieldHealthComp.IsDead() && Entity.StateComp.CurState != EntityState.Dying && !Entity.StateComp.IsRunning) { Entity.Add(new TroopShieldComponent(Entity, Entity.TroopComp.TroopType.ShieldCooldown)); } }
private void SetPathToTarget() { SmartEntity smartEntity = (SmartEntity)this.transform.Entity; this.pathingComp.CurrentPath = this.path; smartEntity.Add <PathingComponent>(this.pathingComp); this.pathingComp.InitializePathView(); this.pathingComp = null; this.path = null; }
public SmartEntity NewEntity() { SmartEntity smartEntity = new SmartEntity(); smartEntity.ID = this.entityCount; smartEntity.Add <StateComponent>(new StateComponent(smartEntity)); this.entities.Add(smartEntity.ID, smartEntity); this.entityCount += 1u; return(smartEntity); }
public SmartEntity SpawnChampion(TroopTypeVO troopType, TeamType teamType, IntPosition boardPosition) { TroopSpawnMode spawnMode = (teamType == TeamType.Defender) ? TroopSpawnMode.LeashedToBuilding : TroopSpawnMode.Unleashed; SmartEntity smartEntity = this.SpawnTroop(troopType, teamType, boardPosition, spawnMode, true, teamType == TeamType.Defender); if (smartEntity != null) { smartEntity.Add(new ChampionComponent(troopType)); } return(smartEntity); }
public void SwapTrapToTurret(SmartEntity entity) { entity.HealthComp.ArmorType = ArmorType.Turret; string turretUid = entity.TrapComp.Type.TurretTED.TurretUid; TurretTypeVO turretTypeVO = Service.Get <IDataController>().Get <TurretTypeVO>(turretUid); Service.Get <EntityFactory>().AddTurretComponentsToEntity(entity, turretTypeVO); if (entity.TrackingGameObjectViewComp == null) { TrackingGameObjectViewComponent component = new TrackingGameObjectViewComponent(entity.GameObjectViewComp.MainGameObject, turretTypeVO, entity.TrackingComp); entity.Add <TrackingGameObjectViewComponent>(component); } Service.Get <SpatialIndexController>().ResetTurretScannedFlagForBoard(); }
private void TryAddBuffStack(SmartEntity target, BuffTypeVO buffType, ArmorType armorType, BuffVisualPriority visualPriority, SmartEntity originator) { if (target == null || buffType == null || !buffType.WillAffect(armorType)) { return; } BuffComponent buffComponent = target.BuffComp; if (buffComponent == null) { buffComponent = new BuffComponent(); target.Add(buffComponent); } else if (buffComponent.IsBuffPrevented(buffType)) { return; } buffComponent.AddBuffStack(buffType, armorType, visualPriority, originator); buffComponent.RemoveBuffsCanceledBy(buffType); }
public SmartEntity SpawnTroop(TroopTypeVO troopType, TeamType teamType, IntPosition boardPosition, TroopSpawnMode spawnMode, bool sendPlacedEvent, bool forceAllow, VisitorType visitorType) { Entity spawnBuilding = null; BoardCell boardCell = null; if (!this.FinalizeSafeBoardPosition(troopType, ref spawnBuilding, ref boardPosition, ref boardCell, teamType, spawnMode, forceAllow)) { return(null); } SmartEntity smartEntity = Service.EntityFactory.CreateTroopEntity(troopType, teamType, boardPosition, spawnBuilding, spawnMode, true, true); if (smartEntity == null) { return(null); } SpawnComponent component = new SpawnComponent(visitorType); smartEntity.Add(component); BoardItemComponent boardItemComp = smartEntity.BoardItemComp; BoardItem boardItem = boardItemComp.BoardItem; if (Service.BoardController.Board.AddChild(boardItem, boardCell.X, boardCell.Z, null, false, !forceAllow && troopType.Type != TroopType.Champion) == null) { return(null); } Service.EntityController.AddEntity(smartEntity); Service.TroopAbilityController.OnTroopSpawned(smartEntity); if (troopType.Type != TroopType.Champion || teamType == TeamType.Attacker) { base.EnsureBattlePlayState(); } if (sendPlacedEvent) { Service.EventManager.SendEvent(EventId.TroopPlacedOnBoard, smartEntity); } return(smartEntity); }
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 bool StartPathingWorkerOrPatrol(SmartEntity entity, SmartEntity target, BoardCell <Entity> startCell, BoardCell <Entity> endCell, int size, bool attemptNoWall) { if (this.IsPathingOngoing()) { return(false); } this.boardController.Board.RefreshClearanceMap(); this.boardController.Board.RefreshClearanceMapNoWall(); WalkerComponent walkerComp = entity.WalkerComp; this.pathingComp = entity.PathingComp; if (this.pathingComp == null) { this.pathingComp = new PathingComponent(walkerComp.SpeedVO.MaxSpeed, target); } else { this.pathingComp.Reset(); this.pathingComp.MaxSpeed = walkerComp.SpeedVO.MaxSpeed; this.pathingComp.Target = target; } bool ignoreWall = false; uint pathSearchWidth = 1u; if (entity.TroopComp != null) { pathSearchWidth = entity.TroopComp.TroopType.PathSearchWidth; } if (entity.DroidComp != null) { ignoreWall = true; } if (entity.TeamComp != null) { ignoreWall = entity.TeamComp.IsDefender(); } this.pathingComp.CurrentPath = new Path(startCell, endCell, endCell, -1, new PathTroopParams { TroopWidth = size, DPS = 0, MinRange = 0u, MaxRange = 1u, MaxSpeed = walkerComp.SpeedVO.MaxSpeed, PathSearchWidth = pathSearchWidth, IsMelee = true, IsOverWall = false, IsHealer = false, CrushesWalls = false, IsTargetShield = false, TargetInRangeModifier = 1u }, new PathBoardParams { IgnoreWall = ignoreWall, Destructible = false }); bool flag; this.pathingComp.CurrentPath.CalculatePath(out flag); if (!flag & attemptNoWall) { this.boardController.Board.RefreshClearanceMapNoWall(); this.pathingComp.CurrentPath = new Path(startCell, endCell, endCell, -1, new PathTroopParams { TroopWidth = size, DPS = 0, MinRange = 0u, MaxRange = 1u, MaxSpeed = walkerComp.SpeedVO.MaxSpeed, PathSearchWidth = pathSearchWidth, IsMelee = true, IsOverWall = false, IsHealer = false, CrushesWalls = false, IsTargetShield = false, TargetInRangeModifier = 1u }, new PathBoardParams { IgnoreWall = true, Destructible = false }); this.pathingComp.CurrentPath.CalculatePath(out flag); } if (flag) { entity.Add <PathingComponent>(this.pathingComp); this.pathingComp.InitializePathView(); } else { this.pathingComp.CurrentPath = null; } this.pathingComp = null; return(flag); }
public SmartEntity CreateTroopEntity(TroopTypeVO troopType, TeamType teamType, IntPosition boardPosition, Entity spawnBuilding, TroopSpawnMode spawnMode, bool isShooter, bool requestAsset) { SmartEntity smartEntity = this.CreateWalkerBaseEntity(boardPosition, troopType.SizeX, troopType.SizeY); TeamComponent component = new TeamComponent(teamType); smartEntity.Add(component); if (teamType == TeamType.Defender) { DefenderComponent component2; if (spawnMode == TroopSpawnMode.LeashedToBuilding) { DamageableComponent damageableComponent = spawnBuilding.Get <DamageableComponent>(); component2 = new DefenderComponent(boardPosition.x, boardPosition.z, damageableComponent, true, damageableComponent.GetLastSpawnIndex()); } else { component2 = new DefenderComponent(boardPosition.x, boardPosition.z, null, spawnMode == TroopSpawnMode.LeashedToSpawnPoint, 0); } smartEntity.Add(component2); } else { smartEntity.Add(new AttackerComponent()); } TroopComponent troopComponent = new TroopComponent(troopType); smartEntity.Add(troopComponent); smartEntity.Add(new BuffComponent()); smartEntity.Add(new HealthViewComponent()); if (isShooter) { ShooterComponent component3 = new ShooterComponent(troopType); smartEntity.Add(component3); } Service.Get <EventManager>().SendEvent(EventId.TroopCreated, smartEntity); if (isShooter) { smartEntity.ShooterComp.TargetingDelayed = (teamType == TeamType.Attacker); HealthType healthType = troopType.IsHealer ? HealthType.Healing : HealthType.Damaging; smartEntity.ShooterComp.AttackFSM = new AttackFSM(Service.Get <BattleController>(), smartEntity, smartEntity.StateComp, smartEntity.ShooterComp, smartEntity.TransformComp, healthType); if (troopType.IsHealer) { smartEntity.Add(new PathingComponent()); smartEntity.Add(new HealerComponent()); } else { smartEntity.Add(new KillerComponent()); } SecondaryTargetsComponent component4 = new SecondaryTargetsComponent(); smartEntity.Add(component4); } HealthComponent component5 = new HealthComponent(troopType.Health, troopComponent.TroopType.ArmorType); smartEntity.Add(component5); if (troopType.ShieldHealth > 0) { TroopShieldHealthComponent component6 = new TroopShieldHealthComponent(troopType.ShieldHealth, ArmorType.Shield); smartEntity.Add(component6); } if (requestAsset) { Service.Get <EntityViewManager>().LoadEntityAsset(smartEntity); } return(smartEntity); }
private SmartEntity CreateBuildingEntity(BuildingTypeVO buildingType, Building building, bool createCollider, bool requestAsset, bool addSupport) { int x = building.X; int z = building.Z; bool flag = buildingType.Type == BuildingType.Blocker; SmartEntity smartEntity = this.NewEntity(); TeamComponent component = new TeamComponent(TeamType.Defender); smartEntity.Add(component); int num = 0; if (!flag && buildingType.SizeX > 1 && buildingType.SizeY > 1) { num = 1; } TransformComponent transformComponent = new TransformComponent(Units.GridToBoardX(x), Units.GridToBoardZ(z), 1.57079637f, true, Units.GridToBoardX(buildingType.SizeX - num), Units.GridToBoardZ(buildingType.SizeY - num)); smartEntity.Add(transformComponent); SizeComponent sizeComponent = Units.SizeCompFromGrid(buildingType.SizeX, buildingType.SizeY); smartEntity.Add(sizeComponent); if (buildingType.Type != BuildingType.Clearable) { smartEntity.Add(new DamageableComponent(transformComponent)); } BuildingComponent buildingComponent = new BuildingComponent(buildingType, building); smartEntity.Add(buildingComponent); smartEntity.Add(new BuffComponent()); smartEntity.Add(new HealthViewComponent()); FilterComponent filter = CollisionFilters.BUILDING; if (buildingType.Type == BuildingType.Trap) { filter = CollisionFilters.TRAP; } else if (buildingType.Type == BuildingType.Wall) { filter = CollisionFilters.WALL; } else if (buildingType.Type == BuildingType.Clearable) { filter = CollisionFilters.CLEARABLE; } else if (buildingType.Type == BuildingType.ChampionPlatform) { filter = CollisionFilters.PLATFORM; } BoardItem <Entity> boardItem = new BoardItem <Entity>(sizeComponent, smartEntity, filter); smartEntity.Add(new BoardItemComponent(boardItem)); if (buildingType.Type == BuildingType.Turret) { TurretTypeVO turretType = Service.Get <IDataController>().Get <TurretTypeVO>(buildingType.TurretUid); this.AddTurretComponentsToEntity(smartEntity, turretType); } if (buildingType.Type == BuildingType.Trap) { this.AddTrapComponentsToEntity(smartEntity, buildingType); } if (buildingType.Type == BuildingType.ShieldGenerator) { this.AddShieldComponentsToEntity(smartEntity, buildingType); } HealthComponent component2 = new HealthComponent(buildingType.Health, buildingComponent.BuildingType.ArmorType); smartEntity.Add(component2); if (addSupport) { smartEntity.Add <SupportComponent>(new SupportComponent()); } if (buildingType.Type == BuildingType.ChampionPlatform) { smartEntity.Add <ChampionPlatformComponent>(new ChampionPlatformComponent()); } if (buildingType.Type == BuildingType.Housing) { smartEntity.Add <HousingComponent>(new HousingComponent()); } switch (buildingType.Type) { case BuildingType.HQ: smartEntity.Add <HQComponent>(new HQComponent()); break; case BuildingType.Barracks: smartEntity.Add <BarracksComponent>(new BarracksComponent()); break; case BuildingType.Factory: smartEntity.Add <FactoryComponent>(new FactoryComponent()); break; case BuildingType.FleetCommand: smartEntity.Add <FleetCommandComponent>(new FleetCommandComponent()); break; case BuildingType.HeroMobilizer: smartEntity.Add <TacticalCommandComponent>(new TacticalCommandComponent()); break; case BuildingType.Squad: smartEntity.Add <SquadBuildingComponent>(new SquadBuildingComponent()); break; case BuildingType.Starport: smartEntity.Add <StarportComponent>(new StarportComponent()); break; case BuildingType.DroidHut: smartEntity.Add <DroidHutComponent>(new DroidHutComponent()); break; case BuildingType.Wall: smartEntity.Add <WallComponent>(new WallComponent()); break; case BuildingType.Turret: smartEntity.Add <TurretBuildingComponent>(new TurretBuildingComponent()); break; case BuildingType.TroopResearch: smartEntity.Add <OffenseLabComponent>(new OffenseLabComponent()); break; case BuildingType.DefenseResearch: smartEntity.Add <DefenseLabComponent>(new DefenseLabComponent()); break; case BuildingType.Resource: if (building.LastCollectTime == 0u) { building.LastCollectTime = ServerTime.Time; } smartEntity.Add <GeneratorComponent>(new GeneratorComponent()); break; case BuildingType.Storage: smartEntity.Add <StorageComponent>(new StorageComponent()); break; case BuildingType.Clearable: smartEntity.Add <ClearableComponent>(new ClearableComponent()); break; case BuildingType.Cantina: smartEntity.Add <CantinaComponent>(new CantinaComponent()); break; case BuildingType.NavigationCenter: smartEntity.Add <NavigationCenterComponent>(new NavigationCenterComponent()); break; case BuildingType.ScoutTower: smartEntity.Add <ScoutTowerComponent>(new ScoutTowerComponent()); break; case BuildingType.Armory: smartEntity.Add <ArmoryComponent>(new ArmoryComponent()); break; } if (buildingType.IsLootable) { LootComponent component3 = new LootComponent(); smartEntity.Add <LootComponent>(component3); } if (requestAsset) { Service.Get <EntityViewManager>().LoadEntityAsset(smartEntity); } return(smartEntity); }
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); }