public static CommandResponse Parse(string command, BlockType blockType, bool execute = true, int i = -1, int j = -1) { mod = ModContent.GetInstance <TICMod>(); var commandsplit = command.Split(new[] { ' ' }, 2).ToList(); string commandtype = commandsplit[0]; string[] args = new string[0]; if (commandsplit.Count == 2 && !String.IsNullOrEmpty(commandsplit[1])) { args = SplitArgs(commandsplit[1]); } CommandResponse resp = new CommandResponse(false, "Unknown Command Block"); switch (blockType) { case BlockType.Trigger: resp = ParseTrigger(commandtype, args, execute, i, j); break; case BlockType.Influencer: resp = ParseInfluencer(commandtype, args, execute); break; case BlockType.Conditional: resp = ParseConditional(commandtype, args, execute); break; } return(resp); }
private static CommandResponse InfluencerSpawnNPC(string[] args, CommandResponse resp, bool execute) { if (args.Length < 3 || args.Length > 4) { resp.response = $"Takes 3-4 parameters; X Co-ordinate, Y Co-ordinate, NPC ID & Datastore (optional)"; return(resp); } int[] pos = new int[2]; for (int i = 0; i < 2; i++) { var ret = ParseInt(args[i], resp, 0); pos[i] = ret.Item1 * 16; resp = ret.Item2; if (!resp.valid) { return(resp); } } var ret2 = ParseInt(args[2], resp, -65, NPCID.Count); int npcID = ret2.Item1; resp = ret2.Item2; if (!resp.valid || npcID == 0) { resp.response += " and not 0"; return(resp); } NPC npc = new NPC(); npc.SetDefaults(npcID); if (execute) { int index = NPC.NewNPC(pos[0], pos[1], npc.type); Main.npc[index].SetDefaults(npc.netID); if (args.Length == 4) { TICMod mod = ModContent.GetInstance <TICMod>(); mod.npcDataStore.AddItem(args[3], Main.npc[index]); } } resp.success = true; resp.valid = true; resp.response = $"Successfully spawned {npc.GivenOrTypeName}, ID:{npc.netID} @ {pos[0] / 16},{pos[1] / 16}."; return(resp); }
private static CommandResponse InfluencerDrawUIText(string[] args, CommandResponse resp, bool execute) { if (args.Length != 7) { resp.response = $"Takes 7 parameters; R Value, G Value, B Value, Width %, Height %, Time & Message"; return(resp); } int[] colors = new int[3]; for (int i = 0; i < 3; i++) { var ret = ParseInt(args[i], resp, 0, 255); colors[i] = ret.Item1; resp = ret.Item2; if (!resp.valid) { return(resp); } } Color textColor = new Color(colors[0], colors[1], colors[2]); int[] pos = new int[2]; for (int i = 3; i < 5; i++) { var ret = ParseInt(args[i], resp, 0, 100); pos[i - 3] = ret.Item1; resp = ret.Item2; if (!resp.valid) { return(resp); } } var ret1 = ParseInt(args[5], resp); int timeout = ret1.Item1; resp = ret1.Item2; if (!resp.valid) { return(resp); } if (execute) { TICMod mod = ModContent.GetInstance <TICMod>(); if (Main.dedServ) { mod.SendTextDisplayPacket(args[6], textColor, timeout, pos[0], pos[1], false); } else { ModContent.GetInstance <TICMod>().textDisplayer .AddText(args[6], textColor, timeout, pos[0], pos[1], false); } string timeoutText = (timeout < 1) ? "until world restart." : $"for {timeout} seconds."; resp.response = $"Displaying '{args[3]}' as {textColor} at ({pos[0]}%, {pos[1]}%) {timeoutText}"; resp.success = true; } return(resp); }