private bool OnCharCommand(string userName, string[] pieces) { if (pieces.Length >= 2) { int prefabIndex = -1; if (!Int32.TryParse(pieces[1], out prefabIndex)) { prefabIndex = BodyCatalog.FindBodyIndexCaseInsensitive(pieces[1]); } if (prefabIndex != -1) { GameObject prefab = BodyCatalog.GetBodyPrefab(prefabIndex); if (prefab != null) { if (FrogtownShared.ChangePrefab(userName, prefab)) { FrogtownShared.SendChat(userName + " morphed into " + prefab.name); } else { FrogtownShared.SendChat(userName + " couldn't morph into " + prefab.name); } } else { FrogtownShared.SendChat("Prefab not found"); } } } return(true); }
private static void ShowEndgameText(ConCommandArgs args) { if (args.GetArgString(0).ToLower() == "custom") { flavorText = args.GetArgString(1); } else { var bodyIndex = BodyCatalog.FindBodyIndexCaseInsensitive(args.GetArgString(0)); if (bodyIndex < 0) { Debug.Log("Couldn't find body index!"); return; } var survivorIndex = SurvivorCatalog.GetSurvivorIndexFromBodyIndex(bodyIndex); if (survivorIndex < 0) { Debug.Log("Couldn't find survivor index!"); return; } SurvivorDef survivorDef = SurvivorCatalog.GetSurvivorDef(survivorIndex); if (!survivorDef) { Debug.Log("SurvivorDef not found!"); return; } bool isWinQuote = true; if (args.Count == 2) { if (args.GetArgString(1).ToLower() == "fail") { isWinQuote = false; } } flavorText = GetOutroText(survivorDef, isWinQuote); } Debug.Log("Outro Text: " + flavorText); Debug.Log(Language.GetString(flavorText)); RoR2.Console.instance.SubmitCmd(null, "set_scene outro", false); }
private static string JoinAs(NetworkUser sender, string[] args) { if (args.Length != 1 && args.Length != 2) { return("join as requires either 1 or 2 arguments"); } NetworkUser player = args.Length == 1 ? sender : GetNetUserFromString(args[1]); if (player == null) { return("Unable to find player with given name"); } string survivorOrBodyName = args[0]; string displayName; SurvivorDef survivor = GetAvailibleSurvivorForPlayerByName(player, survivorOrBodyName); BodyIndex spawnAsBodyIndex = BodyIndex.None; if (survivor != null) { spawnAsBodyIndex = BodyCatalog.FindBodyIndex(survivor.bodyPrefab); displayName = Language.GetString(survivor.displayNameToken); } else if (DropInConfig.AllowJoinAsAllBodies.Value) { BodyIndex bodyIndex = BodyCatalog.FindBodyIndexCaseInsensitive(survivorOrBodyName.EndsWith("Body", StringComparison.InvariantCultureIgnoreCase) ? survivorOrBodyName : survivorOrBodyName + "Body"); if (bodyIndex == BodyIndex.None) { return("Unable to find survivor or body with given name"); } spawnAsBodyIndex = bodyIndex; displayName = BodyCatalog.GetBodyName(bodyIndex); } else { return("Unable to find survivor with the given name"); } JoinAsResult joinAsResult; try { joinAsResult = SpawnPlayerWithBody(player, spawnAsBodyIndex); } catch (Exception ex) { Debug.LogException(ex); Logger.LogError(ex); return($"An exception occured spawning {player.userName} as {displayName}"); } switch (joinAsResult) { case JoinAsResult.Success: return($"Spawning {player.userName} as {displayName}"); case JoinAsResult.DeadAndNotAllowRespawn: return($"{player.userName} will be spawned as {displayName} next stage"); default: return("Unknown join as result"); } }