private static void CCListPlayerCharacterMasterController(ConCommandArgs args) { StringBuilder sb = new StringBuilder(); sb.AppendLine("Number of PCMC instances : " + PlayerCharacterMasterController.instances.Count); foreach (var masterController in PlayerCharacterMasterController.instances) { sb.AppendLine($" is connected : {masterController.isConnected}"); } if (args.sender == null) { Log.Message(sb.ToString()); } else { Log.MessageNetworked(sb.ToString(), args, Log.LogLevel.MessageClientOnly); } }
private static void CCPermissionEnable(ConCommandArgs args) { if (args.Count == 0) { IsEnabled.Value = !IsEnabled.Value; } else { IsEnabled.Value = args.GetArgBool(0); } var res = IsEnabled.Value ? "enabled. Saving and reloading the permission system" : "disabled"; Log.MessageNetworked($"Permission System is {res}.", args, Log.LogLevel.Info); DebugToolkit.Configuration.Save(); Init(); }
private static void CCRemoveEquipment(ConCommandArgs args) { Inventory inventory = args.sender.master.inventory; if (args.Count >= 1) { NetworkUser player = GetNetUserFromString(args[0]); if (player == null) { Log.Message(Lang.PLAYER_NOTFOUND, args, LogLevel.MessageClientOnly); return; } inventory = (player == null) ? inventory : player.master.inventory; } inventory.SetEquipmentIndex(EquipmentIndex.None); Log.Message(Lang.NOMESSAGE, args); }
private static void AnimatorSpeed(ConCommandArgs args) { var cb = args.senderBody; if (cb) { var value = args.GetArgFloat(0); var animator = GetModelAnimator(cb); if (animator) { if (!animator.enabled) { Debug.Log("Animator is not enabled."); } animator.speed = (float)value; } } }
private static void DCFindObject(ConCommandArgs args) { var component = args.senderMasterObject.GetComponent <DesCloneCommandComponent>(); if (component) { var gameObj = GetGameObject(args.GetArgString(0)); if (gameObj) { component.chosenObject = gameObj; Debug.Log(string.Format("Found GameObject {0} : {1}", gameObj, gameObj.name)); } else { Debug.Log("Couldn't find object!"); } } }
private static void TargetGiveItem(ConCommandArgs args) { var localMaster = PlayerCharacterMasterController.instances[0].master; var component = HasComponent(localMaster); if (component && component.HasBody()) { var inventory = component.targetedBody.inventory; if (inventory) { //https://stackoverflow.com/questions/23563960/how-to-get-enum-value-by-string-or-int ItemIndex itemIndex = (ItemIndex)args.GetArgInt(0); int itemCount = args.GetArgInt(1); inventory.GiveItem(itemIndex, itemCount); Chat.AddMessage("Gave " + itemIndex + " x" + itemCount + " to " + component.targetedBody.GetDisplayName()); } } }
private static void CCUseSeed(ConCommandArgs args) { if (args.Count == 0) { Debug.Log(seed); } string stringSeed = ArgsHelper.GetValue(args.userArgs, 0); if (!ulong.TryParse(stringSeed, out seed)) { Debug.Log("Incorrect arguments given. Try: seed 12345"); } else { Debug.Log("Seed set to " + seed); } }
private static void GetIds(ConCommandArgs args) { string list = "Custom Items IDs: \n"; for (int i = 0; i < ItemLib.CustomItemList.Count; i++) { list += ItemLib.CustomItemList[i].ItemDef.nameToken + " | " + (i + ItemLib.OriginalItemCount) + "\n"; } list += "Custom Equipments IDs : \n"; for (int i = 0; i < ItemLib.CustomEquipmentList.Count; i++) { list += ItemLib.CustomEquipmentList[i].EquipmentDef.nameToken + " | " + (i + ItemLib.OriginalEquipmentCount + ItemLib.TotalItemCount) + "\n"; } Debug.Log(list); }
private static void CCSpawnAs(ConCommandArgs args) { if (args.Count == 0) { Log.Message(MagicVars.SPAWNAS_ARGS); return; } string character = Alias.Instance.GetBodyName(args[0]); if (character == null) { Log.Message(MagicVars.SPAWN_ERROR + args[0]); Log.Message("Please use list_body to print CharacterBodies"); return; } GameObject newBody = BodyCatalog.FindBodyPrefab(character); CharacterMaster master = args.sender.master; if (args.Count > 1) { NetworkUser player = GetNetUserFromString(args[1]); if (player != null) { master = player.master; } else { Log.Message(MagicVars.PLAYER_NOTFOUND); return; } } if (!master.alive) { Log.Message(MagicVars.PLAYER_DEADRESPAWN); return; } master.bodyPrefab = newBody; Log.Message(args.sender.userName + " is spawning as " + character); master.Respawn(master.GetBody().transform.position, master.GetBody().transform.rotation); }
private static void CcBossShared(ConCommandArgs args) { if (args.Count == 0) { Debug.Log(BossItemsShared.Value); return; } var valid = args.TryGetArgBool(0); if (!valid.HasValue) { Debug.Log("Couldn't parse to boolean."); } else { BossItemsShared.Value = valid.Value; Debug.Log($"Boss item sharing set to {BossItemsShared.Value}."); }; }
private static void CcEquipmentShared(ConCommandArgs args) { if (args.Count == 0) { Debug.Log(EquipmentShared.Value); return; } var valid = args.TryGetArgBool(0); if (!valid.HasValue) { Debug.Log("Couldn't parse to boolean."); } else { EquipmentShared.Value = valid.Value; Debug.Log($"Equipment sharing set to {EquipmentShared.Value}."); } }
private static void CcMoneyScalar(ConCommandArgs args) { if (args.Count == 0) { Debug.Log(MoneyScalar.Value); return; } var valid = args.TryGetArgDouble(0); if (!valid.HasValue) { Debug.Log("Couldn't parse to a number."); } else { MoneyScalar.Value = valid.Value; Debug.Log($"Mod status set to {MoneyScalar.Value}."); } }
private static void CcMoneyScalarEnabled(ConCommandArgs args) { if (args.Count == 0) { Debug.Log(MoneyScalarEnabled.Value); return; } var valid = args.TryGetArgBool(0); if (!valid.HasValue) { Debug.Log("Couldn't parse to boolean."); } else { MoneyScalarEnabled.Value = valid.Value; Debug.Log($"Money sharing scalar status set to {MoneyScalarEnabled.Value}."); } }
private static void DCTeleportObject(ConCommandArgs args) { var component = args.senderMasterObject.GetComponent <DesCloneCommandComponent>(); if (component) { if (component.chosenObject) { float[] array = { args.GetArgFloat(0), args.GetArgFloat(1), args.GetArgFloat(2) }; var position = new Vector3(array[0], array[1], array[2]); component.chosenObject.transform.position = position; Debug.Log(string.Format("Teleported {0} : {1} to {2}", component.chosenObject, component.chosenObject.name, position)); } else { Debug.Log("You haven't selected an object yet!"); } } }
private static void CcRandomizeSharedPickups(ConCommandArgs args) { if (args.Count == 0) { Debug.Log(RandomizeSharedPickups.Value); return; } var valid = args.TryGetArgBool(0); if (!valid.HasValue) { Debug.Log("Couldn't parse to boolean."); } else { RandomizeSharedPickups.Value = valid.Value; Debug.Log($"Randomize pickups per player set to {RandomizeSharedPickups.Value}."); } }
private static void CCClearItems(ConCommandArgs args) { if (args.Count == 0) { return; } if (args.senderMasterObject) { Inventory component = args.senderMasterObject.GetComponent <Inventory>(); if (component) { for (ItemIndex itemIndex = ItemIndex.Syringe; itemIndex < ItemIndex.Count; itemIndex++) { component.ResetItem(itemIndex); } component.SetEquipmentIndex(EquipmentIndex.None); } } }
private static void CCSetTime(ConCommandArgs args) { if (args.Count == 0) { Log.Message(Run.instance.fixedTime.ToString(), args, LogLevel.MessageClientOnly); return; } if (TextSerialization.TryParseInvariant(args[0], out float setTime)) { Run.instance.fixedTime = setTime; ResetEnemyTeamLevel(); Log.Message("Fixed_time set to " + setTime, args); } else { Log.Message(Lang.FIXEDTIME_ARGS, args, LogLevel.MessageClientOnly); } }
private static void CCLoad(ConCommandArgs args) { if (args.Count != 1) { Debug.Log("Command failed, requires 1 argument: load <filename>"); return; } if (loadingScene) { return; } string fileName = ArgsHelper.GetValue(args.userArgs, 0); string saveJSON = File.ReadAllText($"{directory}{fileName}.json"); SaveData save = TinyJson.JSONParser.FromJson <SaveData>(saveJSON); instance.StartCoroutine(instance.StartLoading(save)); }
private static void CcBossLootCredit(ConCommandArgs args) { if (args.Count == 0) { Debug.Log(BossLootCredit.Value); return; } var valid = args.TryGetArgInt(0); if (!valid.HasValue) { Debug.Log("Couldn't parse to an integer number."); } else { BossLootCredit.Value = valid.Value; Debug.Log($"Boss loot credit set to {BossLootCredit.Value}."); } }
private static void CcDeadPlayersGetItems(ConCommandArgs args) { if (args.Count == 0) { Debug.Log(DeadPlayersGetItems.Value); return; } var valid = args.TryGetArgBool(0); if (!valid.HasValue) { Debug.Log("Couldn't parse to boolean."); } else { DeadPlayersGetItems.Value = valid.Value; Debug.Log($"Dead player getting shared items set to {DeadPlayersGetItems.Value}"); } }
private static void CcBossLoot(ConCommandArgs args) { if (args.Count == 0) { Debug.Log(OverrideBossLootScalingEnabled.Value); return; } var valid = args.TryGetArgBool(0); if (!valid.HasValue) { Debug.Log("Couldn't parse to boolean."); } else { OverrideBossLootScalingEnabled.Value = valid.Value; Debug.Log($"Boss loot scaling disable set to {OverrideBossLootScalingEnabled.Value}."); } }
private static void CCInitialBot(ConCommandArgs args) { int characterType = 0; if (args.userArgs.Count > 0) { string classString = args.userArgs[0]; if (!Int32.TryParse(classString, out characterType)) { SurvivorIndex index; if (SurvivorDict.TryGetValue(classString.ToLower(), out index)) { characterType = (int)index; } else { characterType = 0; } } // Clamp characterType = Math.Max(Math.Min(characterType, RandomSurvivors.Length - 1), 0); } else { return; } int amount = 0; if (args.userArgs.Count > 1) { string amountString = args.userArgs[1]; Int32.TryParse(amountString, out amount); } else { return; } InitialBots[characterType].Value = amount; Debug.Log("Set StartingBots." + RandomSurvivors[characterType].ToString() + " to " + amount); }
private static void CcPrinterCauldronFix(ConCommandArgs args) { if (args.Count == 0) { Debug.Log(PrinterCauldronFixEnabled.Value); return; } var valid = args.TryGetArgBool(0); if (!valid.HasValue) { Debug.Log("Couldn't parse to boolean."); } else { PrinterCauldronFixEnabled.Value = valid.Value; Debug.Log($"Printer and cauldron fix set to {PrinterCauldronFixEnabled.Value}."); }; }
private static void CCSetTime(ConCommandArgs args) { if (args.Count == 0) { Log.Message(Run.instance.fixedTime); return; } if (TextSerialization.TryParseInvariant(args[0], out float setTime)) { Run.instance.fixedTime = setTime; ResetEnemyTeamLevel(); Log.Message("Fixed_time set to " + setTime); } else { Log.Message("Incorrect arguments. Try: fixed_time 600"); } }
private static void CCSetTime(ConCommandArgs args) { if (args.Count == 0) { Log.MessageNetworked("Run time is " + Run.instance.GetRunStopwatch().ToString(), args, LogLevel.MessageClientOnly); return; } if (TextSerialization.TryParseInvariant(args[0], out float setTime)) { Run.instance.SetRunStopwatch(setTime); ResetEnemyTeamLevel(); Log.MessageNetworked("Run timer set to " + setTime, args); } else { Log.MessageNetworked(Lang.FIXEDTIME_ARGS, args, LogLevel.MessageClientOnly); } }
public static bool HasMorePerm(NetworkUser sender, NetworkUser target, ConCommandArgs args) { var senderElevationLevel = sender ? sender.GetPermissionLevel() : PermissionLevel.Admin + 1; // +1 for server console var targetElevationLevel = target.GetPermissionLevel(); if (senderElevationLevel < targetElevationLevel) { Log.MessageNetworked(string.Format(Lang.PS_ARGUSER_HAS_MORE_PERM, target.userName), args, Log.LogLevel.Error); return(false); } if (senderElevationLevel == targetElevationLevel) { Log.MessageNetworked(string.Format(Lang.PS_ARGUSER_HAS_SAME_PERM, target.userName), args, Log.LogLevel.Error); return(false); } return(true); }
private static void CCTimeScale(ConCommandArgs args) { if (args.Count == 0) { Log.MessageNetworked(Time.timeScale.ToString(), args, LogLevel.MessageClientOnly); return; } if (TextSerialization.TryParseInvariant(args[0], out float scale)) { Time.timeScale = scale; TimescaleNet.Invoke(scale); } else { Log.Message(Lang.TIMESCALE_ARGS, LogLevel.MessageClientOnly); } }
private static void CcInteractablesCredit(ConCommandArgs args) { if (args.Count == 0) { Debug.Log(InteractablesCredit.Value); return; } var valid = args.TryGetArgDouble(0); if (!valid.HasValue) { Debug.Log("Couldn't parse to a number."); } else { InteractablesCredit.Value = valid.Value; Debug.Log($"Interactible credit set to {InteractablesCredit.Value}."); } }
private static void CCSpawnBody(ConCommandArgs args) { string prefabString = ArgsHelper.GetValue(args.userArgs, 0); var character = Character.GetCharacter(prefabString); if (character == null) { Debug.LogFormat("Could not spawn {0}, Try: spawn_ai GolemBody", character.body); return; } GameObject body = BodyCatalog.FindBodyPrefab(character.body); GameObject gameObject = Instantiate <GameObject>(body, args.sender.master.GetBody().transform.position, Quaternion.identity); NetworkServer.Spawn(gameObject); Debug.Log("Attempting to spawn " + character.body); }
private static void SetBuildIdSteam(ConCommandArgs args) { var instance = RoR2Application.instance; if (instance == null) { throw new ConCommandException("RoR2Application is null."); } var client = instance.steamworksClient; if (client == null) { throw new ConCommandException("SteamworksClient is null"); } _buildId = TextSerialization.ToStringInvariant(client.BuildId); client.Lobby?.CurrentLobbyData?.SetData("build_id", _buildId); Debug.Log($"BuildId set to {_buildId}"); }
public static Object Sum(ConCommandArgs args) { return Enumerable.Range(0, args.ValueCount) .Sum(x => args.CanGet<double>(x) ? args.Get<double>(x) : 0d); }
public static Object ArgCount(ConCommandArgs args) { return args.Values.Length; }
public static Object Echo(ConCommandArgs args) { return String.Format("\"{0}\"", String.Join("\" \"", args.Values)); }
public static void LogError(ConCommandArgs args) { Debug.LogError(args); }
public static void LogWarning(ConCommandArgs args) { Debug.LogWarning(args); }
private static void SetValue(ConCommandArgs args) { if (args.ValueCount != 2) throw new Exception("Expected 2 arguments: a member path and a value"); var location = _sLocationParser.Parse(args.Values[0]); if (!location.Success) { throw new Exception(location.Error.ToString()); } var value = _sValueParser.Parse(args.Values[1]); if (!value.Success) { throw new Exception(value.Error.ToString()); } var member = FindMember(args.Domain, location[0]); member.SetValue(ReadValue(args.Domain, value[0])); }
private static String GetValue(ConCommandArgs args) { if (args.ValueCount != 1) throw new Exception("Expected 1 argument: a member path"); var match = _sLocationParser.Parse(args.Values[0]); if (!match.Success) { throw new Exception(match.Error.ToString()); } var member = FindMember(args.Domain, match[0]); return (member.GetValue() ?? "null").ToString(); }