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 bool OnRemoveCommand(string userName, string[] pieces) { var player = FrogtownShared.GetPlayerWithName(userName); ItemWithCount itemWithCount = null; try { itemWithCount = ParseItemWithCount(pieces); } catch (ArgumentException e) { SendFailedLookupMessage(); return(true); } int countPlayerHas = player.master.inventory.GetItemCount((ItemIndex)itemWithCount.index); itemWithCount.count = Math.Min(Math.Max(itemWithCount.count, 1), countPlayerHas); FrogtownShared.SendChat(string.Format("countPlayerHas = {0}\r\nitemWithCount.count = {1}", countPlayerHas, itemWithCount.count)); if (itemWithCount.count > 0) { player.master.inventory.GiveItem((ItemIndex)itemWithCount.index, -itemWithCount.count); FrogtownShared.SendChat(string.Format("Took {0} items from {1}.", itemWithCount.count, userName)); } return(true); }
private bool OnGiveCommand(string userName, string[] pieces) { var player = FrogtownShared.GetPlayerWithName(userName); ItemWithCount itemWithCount = null; try { itemWithCount = ParseItemWithCount(pieces); if (itemWithCount.index < 0 || itemWithCount.index >= (int)ItemIndex.Count) { SendFailedLookupMessage(); return(true); } } catch (ArgumentException e) { SendFailedLookupMessage(); return(true); } itemWithCount.count = Math.Max(itemWithCount.count, 1); player.master.inventory.GiveItem((ItemIndex)itemWithCount.index, itemWithCount.count); FrogtownShared.SendChat(string.Format("Gave {0} items to {1}.", itemWithCount.count, userName)); return(true); }
void Awake() { FrogtownShared.AddChatCommand("change_char", OnCharCommand); FrogtownShared.AddChatCommand("give_item", OnGiveCommand); FrogtownShared.AddChatCommand("remove_item", OnRemoveCommand); FrogtownShared.AddChatCommand("clear_items", OnClearItemsCommand); }
private bool OnClearItemsCommand(string userName, string[] pieces) { var player = FrogtownShared.GetPlayerWithName(userName); foreach (ItemIndex itemIndex in ItemCatalog.allItems) { int count = player.master.inventory.GetItemCount(itemIndex); OnRemoveCommand(userName, new[] { pieces[0], itemIndex.ToString(), count.ToString() }); } FrogtownShared.SendChat("Took all items from " + userName + "."); return(true); }
public void Awake() { frogtownInstalled = Chainloader.Plugins.Any(x => MetadataHelper.GetMetadata(x).GUID == "com.frogtown.shared"); if (frogtownInstalled) { modDetails = new FrogtownModDetails("com.orangutan.markteleporter") { description = "Marks the teleporter.", githubAuthor = "OrangutanGaming", githubRepo = "RoR2-MarkTeleporter", thunderstoreFullName = "OrangutanGaming-MarkTeleporter" }; try { FrogtownShared.RegisterMod(modDetails); } catch (ArgumentException) { // Spams Awake event when disabled for some reason causing this to error due to it already being registered } } SceneDirector.PlaceTeleporter += (orig, self) => { orig(self); var prefab = Resources.Load <GameObject>("Prefabs/PositionIndicators/TeleporterChargingPositionIndicator"); _teleporterPositionIndicator = Instantiate(prefab, TeleporterInteraction.instance.transform.position, Quaternion.identity); _teleporterPositionIndicator.GetComponent <PositionIndicator>().targetTransform = TeleporterInteraction.instance.transform; _teleporterPositionIndicator.GetComponent <ChargeIndicatorController>().isCharged = true; }; }
private void SendFailedLookupMessage() { FrogtownShared.SendChat("Failed to lookup item."); }
private void On_ServerStageBegin(Stage stage) { FrogtownShared.SendChat(stage.sceneDef.sceneName); }
private void On_CmdPing(On.RoR2.PingerController.orig_CmdPing orig, PingerController self, PingerController.PingInfo incomingPing) { orig(self, incomingPing); FrogtownShared.SendChat(string.Format("Origin: {0}", FormatVector3String(incomingPing.origin))); FrogtownShared.SendChat(string.Format("Normal: {0}", FormatVector3String(incomingPing.normal))); }