private static void AddBuildingProjectileAssets(Map map, List <IAssetVO> assets, IDataController dc) { int i = 0; int count = map.Buildings.Count; while (i < count) { BuildingTypeVO buildingTypeVO = dc.Get <BuildingTypeVO>(map.Buildings[i].Uid); if (!string.IsNullOrEmpty(buildingTypeVO.TurretUid)) { TurretTypeVO turretTypeVO = dc.Get <TurretTypeVO>(buildingTypeVO.TurretUid); ProjectileUtils.AddProjectileAssets(turretTypeVO.ProjectileType, assets, dc); } if (buildingTypeVO.TrapUid != null) { TrapTypeVO trapTypeVO = dc.Get <TrapTypeVO>(buildingTypeVO.TrapUid); if (trapTypeVO.TurretTED != null && !string.IsNullOrEmpty(trapTypeVO.TurretTED.TurretUid)) { TurretTypeVO turretTypeVO2 = dc.Get <TurretTypeVO>(trapTypeVO.TurretTED.TurretUid); ProjectileUtils.AddProjectileAssets(turretTypeVO2.ProjectileType, assets, dc); } if (trapTypeVO.ShipTED != null && !string.IsNullOrEmpty(trapTypeVO.ShipTED.SpecialAttackName)) { ProjectileUtils.AddSpecialAttackProjectileAssets(trapTypeVO.ShipTED.SpecialAttackName, assets, dc); } } i++; } }
protected void UpdateDps(int sliderIndex) { BuildingUpgradeCatalog buildingUpgradeCatalog = Service.Get <BuildingUpgradeCatalog>(); IDataController dataController = Service.Get <IDataController>(); BuildingTypeVO maxLevel = buildingUpgradeCatalog.GetMaxLevel(this.buildingInfo.UpgradeGroup); TurretTypeVO turretTypeVO = dataController.Get <TurretTypeVO>(maxLevel.TurretUid); if (turretTypeVO.ProjectileType.IsBeam) { int beamDamage = turretTypeVO.ProjectileType.BeamDamage; int beamDamage2 = this.turretInfo.ProjectileType.BeamDamage; this.sliders[1].DescLabel.Text = this.lang.Get("BEAM_DAMAGE", new object[] { beamDamage2 }); this.sliders[sliderIndex].CurrentLabel.Text = string.Empty; this.sliders[sliderIndex].CurrentSlider.Value = ((beamDamage == 0) ? 0f : ((float)beamDamage2 / (float)beamDamage)); if (this.useUpgradeGroup && this.nextBuildingInfo != null) { BuildingTypeVO nextLevel = buildingUpgradeCatalog.GetNextLevel(this.buildingInfo); int beamDamage3 = dataController.Get <TurretTypeVO>(nextLevel.TurretUid).ProjectileType.BeamDamage; this.sliders[sliderIndex].NextLabel.Text = this.lang.Get("PLUS", new object[] { this.lang.ThousandsSeparated(beamDamage3 - beamDamage2) }); this.sliders[sliderIndex].NextSlider.Value = ((beamDamage == 0) ? 0f : ((float)beamDamage3 / (float)beamDamage)); return; } } else { int dPS = this.turretInfo.DPS; int dPS2 = turretTypeVO.DPS; this.sliders[1].DescLabel.Text = this.lang.Get("DAMAGE_DPS", new object[] { "" }); this.sliders[sliderIndex].CurrentLabel.Text = this.lang.ThousandsSeparated(dPS); this.sliders[sliderIndex].CurrentSlider.Value = ((dPS2 == 0) ? 0f : ((float)dPS / (float)dPS2)); if (this.useUpgradeGroup && this.nextBuildingInfo != null) { BuildingTypeVO nextLevel2 = buildingUpgradeCatalog.GetNextLevel(this.buildingInfo); int dPS3 = dataController.Get <TurretTypeVO>(nextLevel2.TurretUid).DPS; this.sliders[sliderIndex].NextLabel.Text = this.lang.Get("PLUS", new object[] { this.lang.ThousandsSeparated(dPS3 - dPS) }); this.sliders[sliderIndex].NextSlider.Value = ((dPS2 == 0) ? 0f : ((float)dPS3 / (float)dPS2)); } } }
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(); }
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); }
public int GetTrapDamageForUIDisplay(TrapTypeVO trapType) { TrapEventType eventType = trapType.EventType; if (eventType == TrapEventType.SpecialAttack) { SpecialAttackTypeVO specialAttackTypeVO = Service.Get <IDataController>().Get <SpecialAttackTypeVO>(trapType.ShipTED.SpecialAttackName); return(specialAttackTypeVO.DPS); } if (eventType != TrapEventType.Turret) { return(0); } TurretTypeVO turretTypeVO = Service.Get <IDataController>().Get <TurretTypeVO>(trapType.TurretTED.TurretUid); return(turretTypeVO.DPS); }
public TrackingComponent(TurretTypeVO turrentType, bool trackPitch) { this.MaxVelocity = 0.25f; float num = (float)Service.Get <Rand>().SimRange(0, 360) * 3.14159274f / 180f; this.TargetEntity = null; this.TargetTransform = null; this.TargetX = 0; this.TargetZ = 0; this.TargetYaw = num; this.Mode = TrackingMode.Disabled; this.Yaw = num; this.TrackPitch = trackPitch; if (trackPitch) { this.TargetPitch = 0f; this.Pitch = 0f; } }
public static uint GetTrapAttackRadius(TrapTypeVO trapType) { IDataController dataController = Service.Get <IDataController>(); TrapEventType eventType = trapType.EventType; if (eventType == TrapEventType.SpecialAttack) { string specialAttackName = trapType.ShipTED.SpecialAttackName; SpecialAttackTypeVO specialAttackTypeVO = dataController.Get <SpecialAttackTypeVO>(specialAttackName); ProjectileTypeVO projectileType = specialAttackTypeVO.ProjectileType; return((uint)projectileType.SplashRadius); } if (eventType == TrapEventType.Turret) { string turretUid = trapType.TurretTED.TurretUid; TurretTypeVO turretTypeVO = dataController.Get <TurretTypeVO>(turretUid); return(turretTypeVO.MaxAttackRange); } return(0u); }
public EatResponse OnEvent(EventId id, object cookie) { if (id != EventId.BuildingViewReady) { return(EatResponse.NotEaten); } EntityViewParams entityViewParams = cookie as EntityViewParams; Entity entity = entityViewParams.Entity; BuildingComponent buildingComponent = entity.Get <BuildingComponent>(); if (buildingComponent == null) { return(EatResponse.NotEaten); } GameObjectViewComponent gameObjectViewComponent = entity.Get <GameObjectViewComponent>(); TurretTypeVO turretTypeVO = null; if (buildingComponent.BuildingType.Type == BuildingType.Turret) { turretTypeVO = Service.Get <IDataController>().Get <TurretTypeVO>(buildingComponent.BuildingType.TurretUid); } if (turretTypeVO == null || string.IsNullOrEmpty(turretTypeVO.TrackerName)) { Animation component = gameObjectViewComponent.MainGameObject.GetComponent <Animation>(); if (component != null) { AssetMeshDataMonoBehaviour component2 = gameObjectViewComponent.MainGameObject.GetComponent <AssetMeshDataMonoBehaviour>(); entity.Add <BuildingAnimationComponent>(new BuildingAnimationComponent(component, component2 ? component2.ListOfParticleSystems : null)); } } else { TrackingComponent trackingComp = entity.Get <TrackingComponent>(); TrackingGameObjectViewComponent component3 = new TrackingGameObjectViewComponent(gameObjectViewComponent.MainGameObject, turretTypeVO, trackingComp); entity.Add <TrackingGameObjectViewComponent>(component3); } return(EatResponse.NotEaten); }
protected override void SetSelectedBuilding(Entity newSelectedBuilding) { base.SetSelectedBuilding(newSelectedBuilding); this.turretInfo = Service.Get <IDataController>().Get <TurretTypeVO>(this.buildingInfo.TurretUid); }
public static ProjectorConfig GenerateBuildingConfig(BuildingTypeVO vo, UXSprite frameSprite) { ProjectorConfig projectorConfig = ProjectorUtils.GenerateGeometryConfig(vo, frameSprite, false); BuildingType type = vo.Type; if (type != BuildingType.Barracks) { if (type != BuildingType.Turret && type != BuildingType.Storage) { if (type != BuildingType.Armory) { projectorConfig.AnimationName = "Active"; } else { projectorConfig.AnimationName = "Idle"; } } else { projectorConfig.AnimationName = null; } } else { projectorConfig.AnimationName = "IdleClosed"; } BuildingType type2 = vo.Type; switch (type2) { case BuildingType.ChampionPlatform: projectorConfig.AttachmentAssets = new string[] { vo.AssetName }; return(projectorConfig); case BuildingType.Housing: case BuildingType.Squad: IL_8F: if (type2 == BuildingType.Turret) { if (!string.IsNullOrEmpty(vo.TurretUid)) { TurretTypeVO turretTypeVO = Service.StaticDataController.Get <TurretTypeVO>(vo.TurretUid); projectorConfig.TrackerName = turretTypeVO.TrackerName; } return(projectorConfig); } if (type2 != BuildingType.Trap) { return(projectorConfig); } projectorConfig.SnapshotFrameDelay = 4; return(projectorConfig); case BuildingType.Starport: projectorConfig.Metered = true; projectorConfig.MeterValue = 1f; return(projectorConfig); } goto IL_8F; }
private void Initialize(SmartEntity entity, ShooterComponent shooterComp, StateComponent stateComponent, TransformComponent transformComponent, HealthType healthType) { this.Entity = entity; this.shooterController = Service.Get <ShooterController>(); this.ShooterComp = shooterComp; this.StateComponent = stateComponent; this.TransformComponent = transformComponent; this.IdleState = new IdleState(this); this.TurnState = new TurnState(this); this.WarmupState = new WarmupState(this); this.PreFireState = new PreFireState(this); this.PostFireState = new PostFireState(this); this.CooldownState = new CooldownState(this); this.shooterController.Reload(shooterComp); base.SetLegalTransition <IdleState, TurnState>(); base.SetLegalTransition <IdleState, WarmupState>(); base.SetLegalTransition <TurnState, IdleState>(); base.SetLegalTransition <TurnState, WarmupState>(); base.SetLegalTransition <WarmupState, IdleState>(); base.SetLegalTransition <WarmupState, PreFireState>(); base.SetLegalTransition <PreFireState, IdleState>(); base.SetLegalTransition <PreFireState, PostFireState>(); base.SetLegalTransition <PostFireState, IdleState>(); base.SetLegalTransition <PostFireState, PreFireState>(); base.SetLegalTransition <PostFireState, CooldownState>(); base.SetLegalTransition <CooldownState, IdleState>(); base.SetLegalTransition <CooldownState, WarmupState>(); if (entity.TroopComp != null && entity.TroopComp.TroopType.Type == TroopType.Champion && entity.TeamComp.TeamType == TeamType.Defender) { entity.StateComp.CurState = EntityState.Disable; entity.StateComp.ForceUpdateAnimation = true; } this.SetState(this.IdleState); this.healthType = healthType; this.ownerTeam = this.Entity.TeamComp.TeamType; this.lastLookAtX = (this.lastLookAtZ = 0); this.shotIndex = 0; TroopComponent troopComp = this.Entity.TroopComp; BuildingComponent buildingComp = this.Entity.BuildingComp; if (troopComp != null) { this.gunSequences = troopComp.TroopShooterVO.Sequences; return; } if (buildingComp != null) { string uid = null; BuildingType type = buildingComp.BuildingType.Type; if (type != BuildingType.Turret) { if (type == BuildingType.Trap) { uid = this.Entity.TrapComp.Type.TurretTED.TurretUid; } } else { uid = buildingComp.BuildingType.TurretUid; } TurretTypeVO turretTypeVO = Service.Get <IDataController>().Get <TurretTypeVO>(uid); this.gunSequences = turretTypeVO.Sequences; return; } Service.Get <StaRTSLogger>().Error("Attaching AttackFMS to Unsupported Entity. No Troop, Building, or Trap Componenet found."); }
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); }
public static ProjectorConfig GenerateBuildingConfig(BuildingTypeVO vo, UXSprite frameSprite) { ProjectorConfig projectorConfig = ProjectorUtils.GenerateGeometryConfig(vo, frameSprite, false); BuildingType type = vo.Type; if (type <= BuildingType.Turret) { if (type == BuildingType.Barracks) { projectorConfig.AnimationName = "IdleClosed"; goto IL_5A; } if (type != BuildingType.Turret) { goto IL_4F; } } else if (type != BuildingType.Storage) { if (type != BuildingType.Armory) { goto IL_4F; } projectorConfig.AnimationName = "Idle"; goto IL_5A; } projectorConfig.AnimationName = null; goto IL_5A; IL_4F: projectorConfig.AnimationName = "Active"; IL_5A: type = vo.Type; if (type <= BuildingType.Starport) { if (type != BuildingType.ChampionPlatform) { if (type == BuildingType.Starport) { projectorConfig.Metered = true; projectorConfig.MeterValue = 1f; } } else { projectorConfig.AttachmentAssets = new string[] { vo.AssetName }; } } else if (type != BuildingType.Turret) { if (type == BuildingType.Trap) { projectorConfig.SnapshotFrameDelay = 4; } } else if (!string.IsNullOrEmpty(vo.TurretUid)) { TurretTypeVO turretTypeVO = Service.Get <IDataController>().Get <TurretTypeVO>(vo.TurretUid); projectorConfig.TrackerName = turretTypeVO.TrackerName; } return(projectorConfig); }