public static void set(Arg arg) { string @string = arg.GetString(0); if (string.IsNullOrEmpty(@string)) { Debug.Log("Invalid gamemode"); } BaseGameMode baseGameMode = null; GameObjectRef gameObjectRef = null; GameModeManifest gameModeManifest = GameModeManifest.Get(); Debug.Log("total gamemodes : " + gameModeManifest.gameModePrefabs.Count); foreach (GameObjectRef gameModePrefab in gameModeManifest.gameModePrefabs) { BaseGameMode component = gameModePrefab.Get().GetComponent <BaseGameMode>(); if (component.shortname == @string) { baseGameMode = component; gameObjectRef = gameModePrefab; Debug.Log("Found :" + component.shortname + " prefab name is :" + component.PrefabName + ": rpath is " + gameModePrefab.resourcePath + ":"); break; } Debug.Log("search name " + @string + "searched against : " + component.shortname); } if (baseGameMode == null) { Debug.Log("Unknown gamemode : " + @string); return; } BaseGameMode activeGameMode = BaseGameMode.GetActiveGameMode(true); if ((bool)activeGameMode) { if (baseGameMode.shortname == activeGameMode.shortname) { Debug.Log("Same gamemode, resetting"); } if (activeGameMode.permanent) { Debug.LogError("This game mode is permanent, you must reset the server to switch game modes."); return; } activeGameMode.ShutdownGame(); activeGameMode.Kill(); BaseGameMode.SetActiveGameMode(null, true); } BaseEntity baseEntity = GameManager.server.CreateEntity(gameObjectRef.resourcePath, Vector3.zero, Quaternion.identity); if ((bool)baseEntity) { Debug.Log("Spawning new game mode : " + baseGameMode.shortname); baseEntity.Spawn(); } else { Debug.Log("Failed to create new game mode :" + baseGameMode.PrefabName); } }
public void UpdateMaxAuthCapacity() { BaseGameMode activeGameMode = BaseGameMode.GetActiveGameMode(true); if ((bool)activeGameMode && activeGameMode.limitTeamAuths) { SetFlag(Flags.Reserved5, authorizedPlayers.Count >= activeGameMode.GetMaxRelationshipTeamSize()); } }
public virtual float GetRemovalTime() { BaseGameMode activeGameMode = BaseGameMode.GetActiveGameMode(true); if (activeGameMode != null) { return(activeGameMode.CorpseRemovalTime(this)); } return(Server.corpsedespawn); }
public bool ShouldSpawn() { BaseGameMode activeGameMode = BaseGameMode.GetActiveGameMode(true); if (activeGameMode == null) { return(false); } if (gameModeTags.Length == 0) { return(true); } if (activeGameMode.HasAnyGameModeTag(gameModeTags)) { return(true); } return(false); }
public void AssignPoints() { BaseGameMode activeGameMode = BaseGameMode.GetActiveGameMode(true); if (activeGameMode == null || !activeGameMode.IsMatchActive()) { return; } if (activeGameMode.IsTeamGame()) { if (captureTeam != -1 && captureFraction == 1f) { activeGameMode.ModifyTeamScore(captureTeam, scorePerSecond); } } else if (capturedPlayer.IsValid(true)) { activeGameMode.ModifyPlayerGameScore(capturedPlayer.Get(true).GetComponent <BasePlayer>(), "score", scorePerSecond); } }
public static void setteam(Arg arg) { BasePlayer basePlayer = ArgEx.Player(arg); if (basePlayer == null) { return; } BaseGameMode activeGameMode = BaseGameMode.GetActiveGameMode(true); if ((bool)activeGameMode) { int @int = arg.GetInt(0); if (@int >= 0 && @int < activeGameMode.GetNumTeams()) { activeGameMode.ResetPlayerScores(basePlayer); activeGameMode.SetPlayerTeam(basePlayer, @int); basePlayer.Respawn(); } } }
public void UpdateCaptureAmount() { if (base.isClient) { return; } float num = captureFraction; BaseGameMode activeGameMode = BaseGameMode.GetActiveGameMode(true); if (activeGameMode == null) { return; } if (captureTrigger.entityContents == null) { SetFlag(Flags.Busy, false, false, false); } else { if (!activeGameMode.IsMatchActive()) { return; } if (activeGameMode.IsTeamGame()) { int[] array = new int[activeGameMode.GetNumTeams()]; foreach (BaseEntity entityContent in captureTrigger.entityContents) { if (!(entityContent == null) && !entityContent.isClient) { BasePlayer component = entityContent.GetComponent <BasePlayer>(); if (!(component == null) && component.IsAlive() && !component.IsNpc && component.gamemodeteam != -1) { array[component.gamemodeteam]++; } } } int num2 = 0; for (int i = 0; i < array.Length; i++) { if (array[i] > 0) { num2++; } } if (num2 < 2) { int num3 = -1; int num4 = 0; for (int j = 0; j < array.Length; j++) { if (array[j] > num4) { num4 = array[j]; num3 = j; } } if (captureTeam == -1 && captureFraction == 0f) { capturingTeam = num3; } if (captureFraction > 0f && num3 != captureTeam && num3 != capturingTeam) { captureFraction = Mathf.Clamp01(captureFraction - Time.deltaTime / timeToCapture); if (captureFraction == 0f) { captureTeam = -1; } } else if (captureTeam == -1 && captureFraction < 1f && capturingTeam == num3) { DoProgressEffect(); captureFraction = Mathf.Clamp01(captureFraction + Time.deltaTime / timeToCapture); if (captureFraction == 1f) { DoCaptureEffect(); captureTeam = num3; } } } SetFlag(Flags.Busy, num2 > 1); } else { if (!capturingPlayer.IsValid(true) && !capturedPlayer.IsValid(true)) { captureFraction = 0f; } if (captureTrigger.entityContents.Count == 0) { capturingPlayer.Set(null); } if (captureTrigger.entityContents.Count == 1) { foreach (BaseEntity entityContent2 in captureTrigger.entityContents) { BasePlayer component2 = entityContent2.GetComponent <BasePlayer>(); if (component2 == null) { continue; } if (!capturedPlayer.IsValid(true) && captureFraction == 0f) { capturingPlayer.Set(component2); } if (captureFraction > 0f && component2 != capturedPlayer.Get(true) && component2 != capturingPlayer.Get(true)) { captureFraction = Mathf.Clamp01(captureFraction - Time.deltaTime / timeToCapture); if (captureFraction == 0f) { capturedPlayer.Set(null); } } else if (!capturedPlayer.Get(true) && captureFraction < 1f && capturingPlayer.Get(true) == component2) { DoProgressEffect(); captureFraction = Mathf.Clamp01(captureFraction + Time.deltaTime / timeToCapture); if (captureFraction == 1f) { DoCaptureEffect(); capturedPlayer.Set(component2); } } break; } } SetFlag(Flags.Busy, captureTrigger.entityContents.Count > 1); } if (num != captureFraction) { SendNetworkUpdate(); } } }