public void NpcDoAction(string nickname, Action <GameObject> act) { World.EnqueueAction(() => { act(missionNPCs[nickname]); }); }
void InitCommands() { Commands = new ConsoleCommand[] { new("base", (arg) => { if (Game.GameData.BaseExists(arg)) { ForceLand(arg); } else { rpcClient.OnConsoleMessage($"Base does not exist `{arg}`"); } }), new("credits", (x) => rpcClient.OnConsoleMessage($"You have ${Character.Credits}")), new("sethealth", (arg) => { if (PermissionCheck()) { if (int.TryParse(arg, out var h)) { if (World != null) { World.EnqueueAction(() => { World.Players[this].GetComponent <SHealthComponent>().CurrentHealth = h; rpcClient.OnConsoleMessage("OK"); }); } } else { rpcClient.OnConsoleMessage("Invalid argument"); } } }), new("npcspawn", (arg) => { if (PermissionCheck() && World != null) { if (World.Server.GameData.TryGetLoadout(arg.Trim(), out var ld)) { World.NPCs.SpawnNPC(ld, Position + new Vector3(0, 0, 200)).ContinueWith(x => { rpcClient.OnConsoleMessage($"ID = {x.Result}"); }); } else { rpcClient.OnConsoleMessage($"Unknown loadout '{arg}'"); } } }), new ("npcdock", (arg) => { var x = arg.Split(','); if (PermissionCheck() && x.Length == 2 && int.TryParse(x[0].Trim(), out int netid) && World != null) { World.NPCs.DockWith(netid, x[1].Trim()); } }), new ("npcattack", (arg) => { var x = arg.Split(','); if (PermissionCheck() && x.Length == 2 && int.TryParse(x[0].Trim(), out int netid) && World != null) { World.NPCs.Attack(netid, x[1].Trim()); } }) }; }