public override void CallHandler(IPlayer player, int groupId, CmdArgs args) { // ClientAPI.SendChatMessage("Plonk!"); if (args.Length == 0) { ClientAPI.ShowChatMessage(GetHelpMessage()); return; } string opt = args.PopWord(); switch (opt) { case "new": CommandNew(args); break; case "list": CommandList(args); break; case "edit": CommandEdit(args); break; case "delete": CommandDelete(args); break; default: ClientAPI.ShowChatMessage(GetHelpMessage()); break; } }
public override void StartClientSide(ICoreClientAPI api) { renderer = new PlacementRenderer(api); api.Event.RegisterRenderer(renderer, EnumRenderStage.Opaque); api.RegisterCommand("pconfig", "Config Placement Preview System", "[enabled|textured]", (id, args) => { WaypointUtilConfig config = api.ModLoader.GetModSystem <WaypointUtilSystem>().Config; string arg = args.PopWord(); bool?enabled = args.PopBool(); switch (arg) { case "enabled": config.PRShow = enabled ?? !config.PRShow; api.ShowChatMessage("Block preview set to " + config.PRShow); break; case "tinted": config.PRTint = enabled ?? !config.PRTint; api.ShowChatMessage("Block preview tinting set to " + config.PRTint); break; default: break; } api.ModLoader.GetModSystem <ConfigLoader>().SaveConfig(); }); api.Event.LevelFinalize += () => api.Shader.ReloadShaders(); }
private void OnReceivedSchematic(SchematicJsonPacket message) { bool allow = capi.Settings.Bool["allowSaveFilesFromServer"]; if (!allow) { capi.ShowChatMessage("Server tried to send a schematic file, but it was rejected for safety reasons. To accept, set allowSaveFilesFromServer to true in clientsettings.json, or type '.clientconfigcreate allowSavefilesFromServer bool true' but be aware of potential security implications!"); return; } try { string exportFolderPath = capi.GetOrCreateDataPath("WorldEdit"); string outfilepath = Path.Combine(exportFolderPath, Path.GetFileName(message.Filename)); if (!outfilepath.EndsWith(".json")) { outfilepath += ".json"; } using (TextWriter textWriter = new StreamWriter(outfilepath)) { textWriter.Write(message.JsonCode); textWriter.Close(); } capi.ShowChatMessage(string.Format("Schematic file {0} received and saved", message.Filename)); } catch (IOException e) { capi.ShowChatMessage("Server sent a schematic file, but failed to save it: " + e.Message); } }
public CommandPlacementPreview(ICoreClientAPI capi) : base(capi) { Command = "pconfig"; RegisterSubCommand("enabled", new SubCommand((player, groupId, args) => { Config.PRShow = (bool)args.PopBool(!Config.PRShow); capi.ShowChatMessage("Block placement preview set to " + Config.PRShow); }, "Enables/Disables the showing of the placement preview.")); RegisterSubCommand("tinted", new SubCommand((player, groupId, args) => { Config.PRTint = (bool)args.PopBool(!Config.PRTint); capi.ShowChatMessage("Block preview tinting set to " + Config.PRTint); }, "Enables/Disables the tinting of placement preview meshes.")); RegisterSubCommand("tintcolorhex", new SubCommand((player, groupId, args) => { string col = args.PopWord(); if (col?[0] == '#') { var color = ColorUtil.Hex2Doubles(col); Config.PRTintColor = new float[] { (float)(color[0]) * 10.0f, (float)(color[1]) * 10.0f, (float)(color[2]) * 10.0f, }; } }, "Sets the placment preview mesh color to a set hexadecimal value starting with #.")); RegisterSubCommand("tintcolorrgb", new SubCommand((player, groupId, args) => { Config.PRTintColor[0] = (float)args.PopFloat(Config.PRTintColor[0]); Config.PRTintColor[1] = (float)args.PopFloat(Config.PRTintColor[1]); Config.PRTintColor[2] = (float)args.PopFloat(Config.PRTintColor[2]); }, "Sets the placment preview mesh color to set RGB float values r g b, ie '1.0 0.0 0.0' for red.")); RegisterSubCommand("tintdefault", new SubCommand((player, groupId, args) => { Config.PRTintColor = new VSHUDConfig().PRTintColor; }, "Sets the placment preview mesh color to the default bluish purple color.")); RegisterSubCommand("opacity", new SubCommand((player, groupId, args) => { Config.PRTintColor = new VSHUDConfig().PRTintColor; }, "Sets the placment preview mesh opacity.")); RegisterSubCommand("opacitydefault", new SubCommand((player, groupId, args) => { Config.PROpacity = new VSHUDConfig().PROpacity; }, "Sets the placment preview mesh opacity to the default opacity.")); RegisterSubCommand("drawlines", new SubCommand((player, groupId, args) => { Config.PRDrawLines = (bool)args.PopBool(!Config.PRDrawLines); capi.ShowChatMessage("Drawing of preview mesh wireframe set to " + Config.PRDrawLines); }, "Enables/Disables the drawing of the wireframe of the placment preview.")); }
private void OnServerMessage(NetworkApiTestMessage networkMessage) { clientApi.ShowChatMessage("Received following message from server: " + networkMessage.message); clientApi.ShowChatMessage("Sending response."); clientApi.Network.GetChannel("networkapitest").SendPacket(new NetworkApiTestResponse() { response = "RE: Hello World!" }); }
public override void CallHandler(IPlayer player, int groupId, CmdArgs args) { var key = args.PopAll(); var trans = Lang.GetMatchingIfExists(key); if (trans == null) { _api.ShowChatMessage($"key \"{key}\" not found in language files"); } else { _api.ShowChatMessage($"translation for \"{key}\" is: {trans}"); } }
private void onMapCmd(int groupId, CmdArgs args) { string cmd = args.PopWord(); ICoreClientAPI capi = api as ICoreClientAPI; if (cmd == "purgedb") { mapdb.Purge(); capi.ShowChatMessage("Ok, db purged"); } if (cmd == "redraw") { foreach (MultiChunkMapComponent cmp in loadedMapData.Values) { cmp.ActuallyDispose(); } loadedMapData.Clear(); lock (chunksToGenLock) { foreach (Vec2i cord in curVisibleChunks) { chunksToGen.Enqueue(cord.Copy()); } } } }
// the vs mod loader uses this to start our mod for the client side public override void StartClientSide(ICoreClientAPI api) { // this creates a client side command called "hello" with the description "Says Hello!" api.RegisterCommand("hello", "Says hello!", "hello", (int groupId, CmdArgs cmdArgs) => { // this says hello! :) api.ShowChatMessage("Hello!"); }); }
public override void CallHandler(IPlayer player, int groupId, CmdArgs args) { foreach (var mod in _api.ModLoader.Mods) { var systems = args.PopWord() == "systems" ? $" Systems:\n {string.Join(" \n", mod.Systems)}" : string.Empty; var message = $"{mod.FileName}:{mod.SourcePath} ({mod.SourceType}) {systems}"; _api.ShowChatMessage(message); } }
public override void CallHandler(IPlayer player, int groupId, CmdArgs args) { var key = args.PopAll(); foreach (var entry in Lang.Inst.LangEntries.Where(e => e.Key.Contains(key))) { _api.ShowChatMessage($"[{entry.Key}] : {entry.Value}"); } }
public override void CallHandler(IPlayer player, int groupId, CmdArgs args) { var tree = new TreeAttribute(); if (player.CurrentBlockSelection != null) { var blockentity = _api.World?.BlockAccessor?.GetBlockEntity(player.CurrentBlockSelection.Position); blockentity?.ToTreeAttributes(tree); _api.ShowChatMessage(tree.ToJsonToken()); } }
public override void StartClientSide(ICoreClientAPI api) { api.RegisterCommand("fdcfg", "Floaty damage configuration", "state", (id, args) => { switch (args.PopWord()) { case "state": ConfigLoader.Config.FDShow = args.PopBool() ?? !ConfigLoader.Config.FDShow; api.ShowChatMessage(string.Format("Floaty Damage Hud Element Generation Set To {0}", ConfigLoader.Config.FDShow)); break; case "range": ConfigLoader.Config.FDRange = args.PopFloat() ?? ConfigLoader.Config.FDRange; api.ShowChatMessage(string.Format("Floaty damage raycasting range set to {0}.", ConfigLoader.Config.FDRange)); break; default: break; } ConfigLoader.SaveConfig(api); }); }
public override void CallHandler(IPlayer player, int groupId, CmdArgs args) { string arg = args.PopWord()?.ToLowerInvariant(); if (arg != null && SubCommands.ContainsKey(arg)) { SubCommands[arg].Run(player, groupId, args); } else { capi.ShowChatMessage(GetHelpMessage()); } }
public void SetPendingNode(NodePos pos) { if (api.Side == EnumAppSide.Server) { return; } if (pendingNode == null) { pendingNode = pos; capi?.ShowChatMessage(String.Format("Pending {0}:{1}", pos.blockPos, pos.index)); } else { capi?.ShowChatMessage(String.Format("trying to attach {0}:{1}", pos.blockPos, pos.index)); WireConnection connection = new WireConnection(pendingNode, pos); clientChannel.SendPacket(new AddConnectionPacket() { connection = connection }); pendingNode = null; } }
public ClientChatCommandExt(ICoreClientAPI capi) { this.capi = capi; RegisterSubCommand("help", new SubCommand((a, b, c) => { string arg = c.PopWord()?.ToLowerInvariant(); if (arg != null && SubCommands.ContainsKey(arg)) { capi.ShowChatMessage(SubCommands[arg].Description); } else { if (arg == null) { capi.ShowChatMessage(string.Format("Please provide an argument you need help with. Type .help {0} for syntax.", Command)); } else { capi.ShowChatMessage(string.Format("No such argument '{0}' exists.", arg)); } } }, "Gets help for specified subcommand")); }
public void OnServerMessage(SortMessage networkMessage) { if (networkMessage.playerUID == capi.World.Player.PlayerUID) { capi.Gui.PlaySound("tick"); int mode = int.Parse(networkMessage.mode); if (laststring != "Sort By " + ((EnumSortMode)mode).ToString()) { laststring = "Sort By " + ((EnumSortMode)mode).ToString(); capi.ShowChatMessage(laststring); } } }
public override void StartClientSide(ICoreClientAPI capi) { capi.Event.LevelFinalize += () => { dialog = new GuiDialogTailoring(capi, this); }; // TODO: this doesn't ever fire! why? capi.Network.GetChannel("tailor").SetMessageHandler <NetworkApiTailorResponse>((NetworkApiTailorResponse response) => { // capi.Logger.Debug($"CLIENT received NetworkApiTailorResponse! {response.message}"); if (response.message != "") { capi.ShowChatMessage($"NetworkApiTailorResponse error: {response.message}"); } }); }
/// <summary> /// this is what actually calls the injected comms. /// </summary> /// <param name="al">the alias</param> /// <param name="args">the command line args</param> private void AliasCommand(Alias al, string[] args) { var injectedComms = al.Inject(args); if (injectedComms is null) { ClientAPI.ShowChatMessage(Lang.Get("arg-injection-failed")); return; } for (int i = 0; i < injectedComms.Length; i++) { // this is the single most important line in this whole mod. SendChatLine(injectedComms[i]); } }
public override void StartClientSide(ICoreClientAPI api) { var settingsFile = api.RegisterFileManager().RegisterFile("EnvTweaks.config.json", FileScope.Global); EnvTweaksPatches.Api = api; EnvTweaksPatches.Settings = settingsFile.ParseJsonAsObject <ModSettings>(); var syntaxMessage = "[settings|lightning|rain|hail|snow|sounds|shake|fog|clouds] [on|off]"; void Handler(int _, CmdArgs args) { if (args.Length == 0) { api.ShowChatMessage($"Environmental Tweaks: {syntaxMessage}"); return; } var option = args.PopWord(); var state = args.PopWord("off").ToLowerInvariant() == "on"; switch (option) { case "settings": var sb = new StringBuilder(); sb.AppendLine("Environmental Tweaks:\n"); sb.AppendLine($"Lightning Effects: {EnvTweaksPatches.Settings.AllowLightning}"); sb.AppendLine($"Weather Sounds: {EnvTweaksPatches.Settings.AllowWeatherSounds}"); sb.AppendLine($"Rainfall Particles: {EnvTweaksPatches.Settings.AllowRain}"); sb.AppendLine($"Hail Particles: {EnvTweaksPatches.Settings.AllowHail}"); sb.AppendLine($"Snow Particles: {EnvTweaksPatches.Settings.AllowSnow}"); sb.AppendLine($"Camera Shake: {EnvTweaksPatches.Settings.AllowCameraShake}"); sb.AppendLine($"Fog Effects: {EnvTweaksPatches.Settings.AllowFog}"); sb.AppendLine($"Fog Effects: {EnvTweaksPatches.Settings.AllowFog}"); sb.AppendLine($"Show Clouds: {EnvTweaksPatches.Settings.AllowClouds}"); api.SendChatMessage(".clearchat"); api.ShowChatMessage(sb.ToString()); break; case "lightning": api.ShowChatMessage($"Lightning Effects: {state}"); EnvTweaksPatches.Settings.AllowLightning = state; break; case "sounds": api.ShowChatMessage($"Weather Sounds: {state}"); EnvTweaksPatches.Settings.AllowWeatherSounds = state; break; case "rain": api.ShowChatMessage($"Rainfall Particles: {state}"); EnvTweaksPatches.Settings.AllowRain = state; break; case "hail": api.ShowChatMessage($"Hail Particles: {state}"); EnvTweaksPatches.Settings.AllowHail = state; break; case "snow": api.ShowChatMessage($"Snow Particles: {state}"); EnvTweaksPatches.Settings.AllowSnow = state; break; case "shake": api.ShowChatMessage($"Camera Shake: {state}"); EnvTweaksPatches.Settings.AllowCameraShake = state; break; case "fog": api.ShowChatMessage($"Fog Effects: {state}"); EnvTweaksPatches.Settings.AllowFog = state; break; case "clouds": api.ShowChatMessage($"Show Clouds: {state}"); EnvTweaksPatches.Settings.AllowClouds = state; break; default: api.ShowChatMessage($"Environmental Tweaks: {syntaxMessage}"); break; } settingsFile.SaveAsJson(EnvTweaksPatches.Settings); } api.RegisterCommand("EnvTweaks", "Change settings for Environmental Tweaks.", syntaxMessage, Handler); api.RegisterCommand("et", "Change settings for Environmental Tweaks.", syntaxMessage, Handler); }
public void CmdLightUtil(int groupId, CmdArgs args) { string arg = args.PopWord(); switch (arg) { case "lightlevel": bool?cnd = args.PopBool(); if (cnd != null) { config.LightLevels = (bool)cnd; } else { config.LightLevels = !config.LightLevels; } break; case "type": int?type = args.PopInt(); if (type != null) { config.LightLevelType = (EnumLightLevelType)type; } capi.ShowChatMessage("Light Util Type Set To " + Enum.GetName(typeof(EnumLightLevelType), config.LightLevelType)); break; case "radius": int?rad = args.PopInt(); if (rad != null) { config.LightRadius = (int)rad; } capi.ShowChatMessage("Light Util Radius Set To " + config.LightRadius); break; case "alpha": float?alpha = args.PopFloat(); config.LightLevelAlpha = alpha != null ? (float)alpha : config.LightLevelAlpha; capi.ShowChatMessage("Light Util Opacity Set To " + config.LightLevelAlpha); break; case "red": int?red = args.PopInt(); if (red != null) { config.LightLevelRed = (int)red; } capi.ShowChatMessage("Red Level Set To " + config.LightLevelRed); break; case "above": bool?ab = args.PopBool(); if (ab != null) { config.LightLevels = (bool)ab; } else { config.LUShowAbove = !config.LUShowAbove; } capi.ShowChatMessage("Show Above Set To " + config.LUShowAbove); break; case "nutrients": bool?ac = args.PopBool(); config.Nutrients = ac ?? !config.Nutrients; capi.ShowChatMessage("Show Farmland Nutrient Set To " + config.Nutrients); break; case "mxnutrients": bool?ad = args.PopBool(); config.MXNutrients = ad ?? !config.MXNutrients; capi.ShowChatMessage(string.Format("Farmland Nutrient Display Set To {0}.", config.MXNutrients ? "Max" : "Min")); break; default: capi.ShowChatMessage("Syntax: .lightutil [lightlevel|type|radius|alpha|red|above|nutrients(enable farmland nutrient display)|mxnutrients(toggle whether to show the min or max nutrient)]"); break; } configLoader.SaveConfig(); }
public override bool OnHeldInteractStep(float secondsUsed, ItemSlot slot, EntityAgent byEntity, BlockSelection blockSel, EntitySelection entitySel) { if (finishedKnocking || blockSel == null) { return(true); } if (byEntity.World is IClientWorldAccessor) { // byEntity.Api.Logger.Debug("" + blockSel.); ModelTransform tf = new ModelTransform(); tf.EnsureDefaultValues(); float knockStep = secondsUsed % knockDuration; tf.Origin.Set(0, -1, 0); tf.Rotation.Z = Math.Min(30, knockStep * speed); if (knockStep > knockDuration - 0.1f) { // First knock determines which block you're selecting to knock if (numberOfKnocks == 0) { selectedBlock = blockSel.Position; } else // On subsequent knocks, check to see if the block being knocked is the same. If not, reset the knocking process { if (selectedBlock != blockSel.Position) { selectedBlock = blockSel.Position; numberOfKnocks = 1; } } // Executes once per knock if (!reachedKnock) { IPlayer byPlayer = (byEntity as EntityPlayer).Player; reachedKnock = true; numberOfKnocks += 1; // Once max knocks is reached, execute this code if (numberOfKnocks >= maxKnocks) { ICoreClientAPI clientAPI = (ICoreClientAPI)byEntity.Api; numberOfKnocks = 0; finishedKnocking = true; tf.Rotation.Z = 0; byEntity.World.PlaySoundAt(new AssetLocation("sounds/block/chop1"), byPlayer, byPlayer); SpawnParticle(10, byEntity); BlockPos plrpos = byPlayer.Entity.Pos.AsBlockPos; float oreDensity = 0; int maxDistance = 32; string oreType = GetOreType(slot.Itemstack.Item.Code.GetName()); // Searches the radius around the selected block, returning an 'intensity' dependent on how many blocks it finds and how close they are api.World.BlockAccessor.WalkBlocks( plrpos.AddCopy(-maxDistance, -maxDistance, -maxDistance), plrpos.AddCopy(maxDistance, maxDistance, maxDistance), (block, pos) => oreDensity += (block.BlockMaterial.Equals(EnumBlockMaterial.Ore) && block.LastCodePart(1).ToString().Contains(oreType)) ? 1 / pos.DistanceTo(blockSel.Position) : 0 ); // (block, pos) => oreDensity += (!block.Code.Path.Contains("quartz") && block.BlockMaterial.Equals(EnumBlockMaterial.Ore)) ? 1 / pos.DistanceTo(blockSel.Position) : 0 /* Look into this method later, could be more efficient * api.World.BlockAccessor.SearchBlocks( * plrpos.AddCopy(-64, -64, -64), * plrpos.AddCopy(64, 64, 64), * (block, pos) => quantityLogs += !block.BlockMaterial.Equals(EnumBlockMaterial.Ore) ? 0 : 1 * ); */ // Reduced the durability of the Knocker by 1 int durability = slot.Itemstack.Attributes.GetInt("durability", 5000); durability -= 1; slot.Itemstack.Attributes.SetInt("durability", durability); float correctOreDensity = CorrectOreDensity(oreType, oreDensity); clientAPI.ShowChatMessage(slot.Itemstack.GetName()); clientAPI.ShowChatMessage("Ore Intensity: " + GetIntensityLevel(correctOreDensity) + " (" + correctOreDensity + ")"); } else { byEntity.World.PlaySoundAt(new AssetLocation("sounds/block/chop3"), byPlayer, byPlayer); SpawnParticle(1, byEntity); } } } else { reachedKnock = false; } byEntity.Controls.UsingHeldItemTransformAfter = tf; } return(true); }
public override void StartClientSide(ICoreClientAPI api) { this.capi = api; api.RegisterCommand("obj", "", "", (p, a) => { var bs = api.World.Player.CurrentBlockSelection; var es = api.World.Player.CurrentEntitySelection; MeshData mesh = null; string name = a.PopWord(); if (bs != null) { var asset = api.World.BlockAccessor.GetBlock(bs.Position).Shape.Base; name = name ?? asset.GetSafeName(); api.Tesselator.TesselateShape(api.World.GetBlock(0), (api.TesselatorManager as ShapeTesselatorManager).shapes[asset], out mesh); } else if (es != null) { Shape loadedShape = es.Entity.Properties.Client.LoadedShape; var texPos = es.Entity.Properties.Client.Renderer as ITexPositionSource; if (texPos == null) { return; } name = name ?? es.Entity.Code.GetSafeName(); api.Tesselator.TesselateShape("", loadedShape, out mesh, texPos); } if (mesh != null) { lock (MassFileExportSystem.toExport) { MassFileExportSystem.toExport.Push(new ExportableMesh(mesh, Path.Combine(GamePaths.DataPath, name + ".obj"), name + ".obj")); } } }); api.RegisterCommand("objworld", "", "", (p, a) => { string arg = a.PopWord("cache"); switch (arg) { case "cache": ConfigLoader.Config.CreateChunkObjs = a.PopBool() ?? !ConfigLoader.Config.CreateChunkObjs; capi.ShowChatMessage(string.Format("Chunk Tesselator .obj Caching {0}.", ConfigLoader.Config.CreateChunkObjs ? "Enabled" : "Disabled")); break; case "clear": MassFileExportSystem.Clear <ExportableChunkPart>(); break; default: break; } ConfigLoader.SaveConfig(capi); }); api.RegisterCommand("meshdata", "", "", (p, a) => { var bs = api.World.Player.CurrentBlockSelection; var es = api.World.Player.CurrentEntitySelection; string name = a.PopWord(); MeshData mesh = null; if (bs != null) { var asset = api.World.BlockAccessor.GetBlock(bs.Position).Shape.Base; name = name ?? asset.GetSafeName(); api.Tesselator.TesselateShape(api.World.GetBlock(0), (api.TesselatorManager as ShapeTesselatorManager).shapes[asset], out mesh); } else if (es != null) { name = name ?? es.Entity.Code.GetSafeName(); api.Tesselator.TesselateShape(api.World.GetBlock(0), es.Entity.Properties.Client.LoadedShape, out mesh); } if (mesh != null) { lock (MassFileExportSystem.toExport) { MassFileExportSystem.toExport.Push(new ExportableJsonObject(mesh, Path.Combine(GamePaths.DataPath, name))); } } }); }
private void cmdWeatherClient(int groupId, CmdArgs args) { string text = getWeatherInfo <WeatherSystemClient>(capi.World.Player); capi.ShowChatMessage(text); }
public void CmdMeasuringTape(int groupId, CmdArgs args) { WaypointUtilSystem wUtil = capi.ModLoader.GetModSystem <WaypointUtilSystem>(); string arg = args.PopWord(); switch (arg) { case "start": if (capi.World.Player.CurrentBlockSelection != null) { start = capi.World.Player.CurrentBlockSelection.Position; //capi.ShowChatMessage("Okay, start set to: " + start); MakeHighlights(); } else { capi.ShowChatMessage("Please look at a block."); } break; case "end": if (capi.World.Player.CurrentBlockSelection != null) { end = capi.World.Player.CurrentBlockSelection.Position; //capi.ShowChatMessage("Okay, end set to: " + end); MakeHighlights(); } else { capi.ShowChatMessage("Please look at a block."); } break; case "startwp": int?swpID = args.PopInt(); if (swpID != null) { start = wUtil.Waypoints[(int)swpID].Position.AsBlockPos; MakeHighlights(); } else { capi.ShowChatMessage("Please enter a waypoint id."); } break; case "endwp": int?ewpID = args.PopInt(); if (ewpID != null) { end = wUtil.Waypoints[(int)ewpID].Position.AsBlockPos; MakeHighlights(); } else { capi.ShowChatMessage("Please enter a waypoint id."); } break; case "calc": string type = args.PopWord(); switch (type) { case "block": capi.ShowChatMessage("Block Distance: " + Math.Round(start.DistanceTo(end) + 1)); break; case "euclidian": capi.ShowChatMessage("Euclidian Distance: " + start.DistanceTo(end)); break; case "manhattan": capi.ShowChatMessage("Manhattan Distance: " + start.ManhattenDistance(end)); break; case "horizontal": capi.ShowChatMessage("Horizontal Distance: " + Math.Sqrt(start.HorDistanceSqTo(end.X, end.Z))); break; case "horizontalmanhattan": capi.ShowChatMessage("Horizontal Manhattan Distance: " + start.HorizontalManhattenDistance(end)); break; default: capi.ShowChatMessage("Syntax: .measure calc [block|euclidian|manhattan|horizontal|horizontalmanhattan]"); break; } break; default: capi.ShowChatMessage("Syntax: .measure [start|end|calc]"); break; } }
public void CmdLightUtil(int groupId, CmdArgs args) { string arg = args.PopWord(); switch (arg) { case "lightlevel": bool?cnd = args.PopBool(); if (cnd != null) { config.LightLevels = (bool)cnd; } else { config.LightLevels = !config.LightLevels; } break; case "type": int?type = args.PopInt(); if (type != null) { config.LightLevelType = (EnumLightLevelType)type; } capi.ShowChatMessage("Light Util Type Set To " + Enum.GetName(typeof(EnumLightLevelType), config.LightLevelType)); break; case "radius": int?rad = args.PopInt(); if (rad != null) { config.LightRadius = (int)rad; } capi.ShowChatMessage("Light Util Radius Set To " + config.LightRadius); break; case "alpha": float?alpha = args.PopFloat(); config.LightLevelAlpha = alpha != null ? (float)alpha : config.LightLevelAlpha; capi.ShowChatMessage("Light Util Opacity Set To " + config.LightLevelAlpha); break; case "red": int?red = args.PopInt(); if (red != null) { config.LightLevelRed = (int)red; } capi.ShowChatMessage("Red Level Set To " + config.LightLevelRed); break; case "above": bool?ab = args.PopBool(); if (ab != null) { config.LightLevels = (bool)ab; } else { config.LUShowAbove = !config.LUShowAbove; } capi.ShowChatMessage("Show Above Set To " + config.LUShowAbove); break; default: capi.ShowChatMessage("Syntax: .lightutil [lightlevel|type|radius|alpha|red|above]"); break; } configLoader.SaveConfig(); }
public override void StartClientSide(ICoreClientAPI api) { renderer = new PlacementRenderer(api); api.Event.RegisterRenderer(renderer, EnumRenderStage.Opaque); api.Input.RegisterHotKey("placementpreviewtoggle", "Toggle Placement Preview", GlKeys.Quote); api.Input.SetHotKeyHandler("placementpreviewtoggle", (a) => { VSHUDConfig config = api.ModLoader.GetModSystem <WaypointUtils>().Config; config.PRShow = !config.PRShow; api.ModLoader.GetModSystem <ConfigLoader>().SaveConfig(); return(true); }); api.RegisterCommand("pconfig", "Config Placement Preview System", "[enabled|tinted|tintcolorhex|tintcolorrgb|tintdefault|opacity]", (id, args) => { VSHUDConfig config = api.ModLoader.GetModSystem <WaypointUtils>().Config; string arg = args.PopWord(); bool?enabled; switch (arg) { case "enabled": enabled = args.PopBool(); config.PRShow = enabled ?? !config.PRShow; api.ShowChatMessage("Block preview set to " + config.PRShow); break; case "tinted": enabled = args.PopBool(); config.PRTint = enabled ?? !config.PRTint; api.ShowChatMessage("Block preview tinting set to " + config.PRTint); break; case "tintcolorhex": string col = args.PopWord(); if (col?[0] == '#') { var color = ColorUtil.Hex2Doubles(col); config.PRTintColor = new float[] { (float)(color[0]) * 10.0f, (float)(color[1]) * 10.0f, (float)(color[2]) * 10.0f, }; } break; case "opacity": config.PROpacity = args.PopFloat() ?? config.PROpacity; break; case "opacitydefault": config.PROpacity = new VSHUDConfig().PROpacity; break; case "tintcolorrgb": config.PRTintColor[0] = args.PopFloat() ?? config.PRTintColor[0]; config.PRTintColor[1] = args.PopFloat() ?? config.PRTintColor[1]; config.PRTintColor[2] = args.PopFloat() ?? config.PRTintColor[2]; break; case "tintdefault": config.PRTintColor = new VSHUDConfig().PRTintColor; break; default: break; } api.ModLoader.GetModSystem <ConfigLoader>().SaveConfig(); }); api.Event.LevelFinalize += () => api.Shader.ReloadShaders(); }
public CommandFloatyWaypoints(ICoreClientAPI capi, WaypointUtils utils) : base(capi) { Command = "wpcfg"; RegisterSubCommand("deathdebug", new SubCommand((player, groupId, args) => { Config.DebugDeathWaypoints = args.PopBool() ?? !Config.DebugDeathWaypoints; capi.ShowChatMessage(string.Format("Death waypoint debbuging set to {0}", Config.DebugDeathWaypoints)); }, "Debug sending of death waypoint string, true/false.")); RegisterSubCommand("dotrange", new SubCommand((player, groupId, args) => { double?dr = args.PopDouble(); Config.DotRange = dr != null ? (double)dr : Config.DotRange; capi.ShowChatMessage("Dot Range Set To " + Config.DotRange + " Meters."); }, "Sets the dot range of floaty waypoints, any decimal value.")); RegisterSubCommand("titlerange", new SubCommand((player, groupId, args) => { double?tr = args.PopDouble(); Config.TitleRange = tr != null ? (double)tr : Config.TitleRange; capi.ShowChatMessage("Title Range Set To " + Config.TitleRange + " Meters."); }, "Sets the title range of floaty waypoints, any decimal value.")); RegisterSubCommand("perblockwaypoints", new SubCommand((player, groupId, args) => { bool?pb = args.PopBool(); Config.PerBlockWaypoints = pb != null ? (bool)pb : !Config.PerBlockWaypoints; capi.ShowChatMessage("Per Block Waypoints Set To " + Config.PerBlockWaypoints + "."); }, "Whether or not floaty waypoints are clamped to block positions, true/false.")); RegisterSubCommand("pdw", new SubCommand((player, groupId, args) => { utils.PurgeWaypointsByStrings("Player Death Waypoint", "*Player Death Waypoint*"); }, "Purges death waypoints.")); RegisterSubCommand("plt", new SubCommand((player, groupId, args) => { utils.PurgeWaypointsByStrings("Limits Test"); }, "Purges waypoints created by the testlimits debug command.")); RegisterSubCommand("open", new SubCommand((player, groupId, args) => { utils.ViewWaypoints(new KeyCombination()); }, "Opens floaty waypoints uis.")); RegisterSubCommand("waypointprefix", new SubCommand((player, groupId, args) => { bool?wp = args.PopBool(); Config.WaypointPrefix = wp != null ? (bool)wp : !Config.WaypointPrefix; capi.ShowChatMessage("Waypoint Prefix Set To " + Config.WaypointPrefix + "."); }, "Whether or not waypoints are prefixed with \"Waypoint:\", true/false")); RegisterSubCommand("waypointid", new SubCommand((player, groupId, args) => { bool?wi = args.PopBool(); Config.WaypointID = wi != null ? (bool)wi : !Config.WaypointID; capi.ShowChatMessage("Waypoint ID Set To " + Config.WaypointID + "."); }, "Whether or not floaty waypoints are prefixed with their ID, true/false")); RegisterSubCommand("purge", new SubCommand((player, groupId, args) => { string s = args.PopWord(); if (s == "reallyreallyconfirm") { utils.Purge(); } else { capi.ShowChatMessage(Lang.Get("Are you sure you want to do that? It will remove ALL your waypoints, type \"reallyreallyconfirm\" to confirm.")); } }, "Deletes ALL your waypoints.")); RegisterSubCommand("enableall", new SubCommand((player, groupId, args) => { Config.DisabledColors.Clear(); }, "Enables all waypoint colors.")); RegisterSubCommand("save", new SubCommand((player, groupId, args) => { ConfigLoader.SaveConfig(capi); }, "Force save configuration file.")); RegisterSubCommand("export", new SubCommand((player, groupId, args) => { string filePath = Path.Combine(GamePaths.DataPath, args.PopWord() ?? "waypoints"); lock (MassFileExportSystem.toExport) { MassFileExportSystem.toExport.Push(new ExportableJsonObject(utils.WaypointsRel, filePath)); } }, "Exports waypoints as a JSON file located in your game data folder.")); RegisterSubCommand("import", new SubCommand((player, groupId, args) => { string path1 = Path.Combine(GamePaths.DataPath, args.PopWord() ?? "waypoints") + ".json"; if (File.Exists(path1)) { using (TextReader reader = new StreamReader(path1)) { DummyWaypoint[] relative = JsonConvert.DeserializeObject <DummyWaypoint[]>(reader.ReadToEnd(), new JsonSerializerSettings() { NullValueHandling = NullValueHandling.Ignore }); VSHUDTaskSystem.Actions.Enqueue(new Vintagestory.API.Common.Action(() => { for (int j = 0; j < relative.Length; j++) { var val = relative[j]; if (utils.WaypointsRel.Any(w => val.Position.AsBlockPos.X == w.Position.AsBlockPos.X && val.Position.AsBlockPos.Y == w.Position.AsBlockPos.Y && val.Position.AsBlockPos.Z == w.Position.AsBlockPos.Z )) { continue; } string str = string.Format(CultureInfo.InvariantCulture, "/waypoint addati {0} ={1} ={2} ={3} {4} #{5} {6}", val.Icon, val.Position.X, val.Position.Y, val.Position.Z, val.Pinned, ColorUtil.Int2Hex(val.Color), val.Title); capi.SendChatMessage(str); } capi.SendMyWaypoints(); })); reader.Close(); } } }, "Imports waypoints from a JSON file located in your game data folder, default name waypoints.json, if not, provide filename excluding .json.")); RegisterSubCommand("testlimits", new SubCommand((player, groupId, args) => { int amount = args.PopInt() ?? 30; int maxY = args.PopInt() ?? 10; double radius = (args.PopInt() ?? 1000); VSHUDTaskSystem.Actions.Enqueue(new Vintagestory.API.Common.Action(() => { for (int i = 0; i < amount; i++) { double x = (capi.World.Rand.NextDouble() - 0.5) * radius, z = (capi.World.Rand.NextDouble() - 0.5) * radius, y = capi.World.BlockAccessor.GetRainMapHeightAt((int)x, (int)z); double r = x * x + z * z; if (r <= (radius * 0.5) * (radius * 0.5)) { Vec3d pos = capi.World.Player.Entity.Pos.XYZ.AddCopy(new Vec3d(x, y, z)); bool deathWaypoint = capi.World.Rand.NextDouble() > 0.8; string icon = deathWaypoint ? "rocks" : WaypointUtils.iconKeys[(int)(capi.World.Rand.NextDouble() * (WaypointUtils.iconKeys.Length - 1))]; string title = deathWaypoint ? "Limits Test Player Death Waypoint" : "Limits Test Waypoint"; string str = string.Format(CultureInfo.InvariantCulture, "/waypoint addati {0} ={1} ={2} ={3} {4} #{5} {6}", icon, pos.X, pos.Y, pos.Z, deathWaypoint, ColorStuff.RandomHexColorVClamp(capi, 0.5, 0.8), title); capi.SendChatMessage(str); } else { i--; } } capi.SendMyWaypoints(); })); }, "Creates and uploads many waypoints to the server to debug the limits of VSHUD's floaty waypoint rendering system, inputs 3 integers (amount, maxY, radius).")); RegisterSubCommand("pillars", new SubCommand((player, groupId, args) => { Config.ShowPillars = args.PopBool() ?? !Config.ShowPillars; capi.ShowChatMessage("Waypoint Pillars Set To " + Config.ShowPillars + "."); }, "Toggles the rendering of the pillars that accompany the floaty waypoint UIs. True/False")); RegisterSubCommand("shuffle", new SubCommand((player, groupId, args) => { lock (FloatyWaypointManagement.WaypointElements) { if (FloatyWaypointManagement.WaypointElements != null && FloatyWaypointManagement.WaypointElements.Count > 1) { HudElementWaypoint[] wps = new HudElementWaypoint[FloatyWaypointManagement.WaypointElements.Count]; FloatyWaypointManagement.WaypointElements.TryPopRange(wps); wps.Shuffle(new LCGRandom(468963)); FloatyWaypointManagement.WaypointElements.PushRange(wps); } } }, "Shuffles the internal floaty waypoint UI stack to debug if changes are handled correctly.")); RegisterSubCommand("echo", new SubCommand((player, groupId, args) => { Config.Echo = (bool)args.PopBool(!Config.Echo); capi.ShowChatMessage(string.Format("Waypoint creation echoing set to {0}.", Config.Echo)); }, "Toggles the logging to chat of waypoint creation/deletion. Useful if you have a mod that creates many waypoints. True/False")); }