public static LanceSpawnerGameLogic CreateLanceSpawner(GameObject parent, string name, string guid, string teamDefinitionGuid, bool spawnUnitsOnActivation, SpawnUnitMethodType spawnMethod, List <string> unitGuids) { GameObject lanceSpawnerGo = new GameObject(name); lanceSpawnerGo.transform.parent = parent.transform; lanceSpawnerGo.transform.localPosition = new Vector3(-674, 300, -280); LanceSpawnerGameLogic lanceSpawnerGameLogic = lanceSpawnerGo.AddComponent <LanceSpawnerGameLogic>(); lanceSpawnerGameLogic.encounterObjectGuid = guid; lanceSpawnerGameLogic.teamDefinitionGuid = teamDefinitionGuid; lanceSpawnerGameLogic.spawnMethod = spawnMethod; lanceSpawnerGameLogic.spawnUnitsOnActivation = spawnUnitsOnActivation; float x = 0; float z = 0; for (int i = 0; i < unitGuids.Count; i++) { CreateUnitSpawnPoint(lanceSpawnerGo, $"UnitSpawnPoint{i + 1}", new Vector3(x, 0, z), unitGuids[i]); x += 24; z += 24; } lanceSpawnerGo.AddComponent <SnapToTerrain>(); return(lanceSpawnerGameLogic); }
public static PlayerLanceSpawnerGameLogic CreatePlayerLanceSpawner(GameObject parent, string name, string guid, string teamDefinitionGuid, bool spawnUnitsOnActivation, SpawnUnitMethodType spawnMethod, List <string> unitGuids, bool includeCameraStart) { GameObject lanceSpawnerGo = new GameObject(name); lanceSpawnerGo.transform.parent = parent.transform; PlayerLanceSpawnerGameLogic lanceSpawnerGameLogic = lanceSpawnerGo.AddComponent <PlayerLanceSpawnerGameLogic>(); lanceSpawnerGameLogic.encounterObjectGuid = guid; lanceSpawnerGameLogic.teamDefinitionGuid = teamDefinitionGuid; lanceSpawnerGameLogic.spawnMethod = spawnMethod; lanceSpawnerGameLogic.spawnUnitsOnActivation = spawnUnitsOnActivation; float x = 0; float z = 0; for (int i = 0; i < unitGuids.Count; i++) { CreateUnitSpawnPoint(lanceSpawnerGo, $"PlayerLanceSpawnPoint{i + 1}", new Vector3(x, 0, z), unitGuids[i]); x += 24; z += 24; } lanceSpawnerGo.AddComponent <SnapToTerrain>(); if (includeCameraStart) { GameObject cameraStartGo = new GameObject("CameraStart"); cameraStartGo.transform.parent = lanceSpawnerGo.FindRecursive("PlayerLanceSpawnPoint1").transform; CameraStart cameraStart = cameraStartGo.AddComponent <CameraStart>(); } return(lanceSpawnerGameLogic); }
public override void Build() { SpawnUnitMethodType spawnMethodType = SpawnUnitMethodType.ViaLeopardDropship; switch (spawnType) { case "Leopard": spawnMethodType = SpawnUnitMethodType.ViaLeopardDropship; break; case "DropPod": spawnMethodType = SpawnUnitMethodType.DropPod; break; case "Instant": spawnMethodType = SpawnUnitMethodType.InstantlyAtSpawnPoint; break; default: Main.LogDebug($"[SpawnBuilder.{contractTypeBuilder.ContractTypeKey}] No support for spawnType '{spawnType}'. Check for spelling mistakes."); break; } string teamId = EncounterRules.PLAYER_TEAM_ID; switch (team) { case "Player1": { teamId = EncounterRules.PLAYER_TEAM_ID; PlayerLanceSpawnerGameLogic playerLanceSpawnerGameLogic = LanceSpawnerFactory.CreatePlayerLanceSpawner(parent, name, guid, teamId, true, spawnMethodType, spawnPointGuids, true); if (position != null) { SetPosition(playerLanceSpawnerGameLogic.gameObject, position); } if (rotation != null) { SetRotation(playerLanceSpawnerGameLogic.gameObject, rotation); } break; } case "Target": { teamId = EncounterRules.TARGET_TEAM_ID; LanceSpawnerGameLogic lanceSpawnerGameLogic = LanceSpawnerFactory.CreateLanceSpawner(parent, name, guid, teamId, true, spawnMethodType, spawnPointGuids); if (position != null) { SetPosition(lanceSpawnerGameLogic.gameObject, position); } if (rotation != null) { SetRotation(lanceSpawnerGameLogic.gameObject, rotation); } break; } case "TargetAlly": { teamId = EncounterRules.TARGETS_ALLY_TEAM_ID; LanceSpawnerGameLogic lanceSpawnerGameLogic = LanceSpawnerFactory.CreateLanceSpawner(parent, name, guid, teamId, true, spawnMethodType, spawnPointGuids); if (position != null) { SetPosition(lanceSpawnerGameLogic.gameObject, position); } if (rotation != null) { SetRotation(lanceSpawnerGameLogic.gameObject, rotation); } break; } case "Employer": { teamId = EncounterRules.EMPLOYER_TEAM_ID; LanceSpawnerGameLogic lanceSpawnerGameLogic = LanceSpawnerFactory.CreateLanceSpawner(parent, name, guid, teamId, true, spawnMethodType, spawnPointGuids); if (position != null) { SetPosition(lanceSpawnerGameLogic.gameObject, position); } if (rotation != null) { SetRotation(lanceSpawnerGameLogic.gameObject, rotation); } break; } default: Main.LogDebug($"[SpawnBuilder.{contractTypeBuilder.ContractTypeKey}] No support for team '{team}'. Check for spelling mistakes."); break; } }
public override void Build() { SpawnUnitMethodType spawnMethodType = SpawnUnitMethodType.ViaLeopardDropship; switch (spawnType) { case "Leopard": spawnMethodType = SpawnUnitMethodType.ViaLeopardDropship; break; case "DropPod": spawnMethodType = SpawnUnitMethodType.DropPod; break; case "Instant": spawnMethodType = SpawnUnitMethodType.InstantlyAtSpawnPoint; break; default: Main.LogDebug($"[SpawnBuilder.{contractTypeBuilder.ContractTypeKey}] No support for spawnType '{spawnType}'. Check for spelling mistakes."); break; } LanceSpawnerGameLogic spawnerGameLogic = null; string teamId = TeamUtils.PLAYER_TEAM_ID; switch (team) { case "Player1": { teamId = TeamUtils.PLAYER_TEAM_ID; spawnerGameLogic = LanceSpawnerFactory.CreatePlayerLanceSpawner(parent, name, guid, teamId, true, spawnMethodType, spawnPointGuids, true); break; } case "Target": { teamId = TeamUtils.TARGET_TEAM_ID; spawnerGameLogic = LanceSpawnerFactory.CreateLanceSpawner(parent, name, guid, teamId, true, spawnMethodType, spawnPointGuids); spawnerGameLogic.alertLanceOnSpawn = this.alertLanceOnSpawn; if (orders != null) { spawnerGameLogic.aiOrderList.contentsBox = orders; } break; } case "TargetAlly": { teamId = TeamUtils.TARGETS_ALLY_TEAM_ID; spawnerGameLogic = LanceSpawnerFactory.CreateLanceSpawner(parent, name, guid, teamId, true, spawnMethodType, spawnPointGuids); spawnerGameLogic.alertLanceOnSpawn = this.alertLanceOnSpawn; if (orders != null) { spawnerGameLogic.aiOrderList.contentsBox = orders; } break; } case "Employer": { teamId = TeamUtils.EMPLOYER_TEAM_ID; spawnerGameLogic = LanceSpawnerFactory.CreateLanceSpawner(parent, name, guid, teamId, true, spawnMethodType, spawnPointGuids); spawnerGameLogic.alertLanceOnSpawn = this.alertLanceOnSpawn; if (orders != null) { spawnerGameLogic.aiOrderList.contentsBox = orders; } break; } case "NeutralToAll": { teamId = TeamUtils.NEUTRAL_TO_ALL_TEAM_ID; spawnerGameLogic = LanceSpawnerFactory.CreateLanceSpawner(parent, name, guid, teamId, true, spawnMethodType, spawnPointGuids); spawnerGameLogic.alertLanceOnSpawn = this.alertLanceOnSpawn; if (orders != null) { spawnerGameLogic.aiOrderList.contentsBox = orders; } break; } case "HostileToAll": { teamId = TeamUtils.HOSTILE_TO_ALL_TEAM_ID; spawnerGameLogic = LanceSpawnerFactory.CreateLanceSpawner(parent, name, guid, teamId, true, spawnMethodType, spawnPointGuids); spawnerGameLogic.alertLanceOnSpawn = this.alertLanceOnSpawn; if (orders != null) { spawnerGameLogic.aiOrderList.contentsBox = orders; } break; } default: Main.Logger.LogError($"[SpawnBuilder.{contractTypeBuilder.ContractTypeKey}] No support for team '{team}'. Check for spelling mistakes."); break; } if (this.position != null) { SetPosition(spawnerGameLogic.gameObject, this.position); } if (this.rotation != null) { SetRotation(spawnerGameLogic.gameObject, this.rotation); } if (this.mountOnTargets != null) { SetMountOnPositions(spawnerGameLogic, this.mountOnTargets); } if (this.spawnPointPositions != null) { SetSpawnPointPositions(spawnerGameLogic); } if (this.spawnPointRotations != null) { SetSpawnPointRotations(spawnerGameLogic); } if (this.defaultDetectionRange > 0) { SetDefaultDetectionRange(spawnerGameLogic, this.defaultDetectionRange); } if (this.tags != null) { spawnerGameLogic.encounterTags.AddRange(this.tags); } }