Snapshot for release 2026.10.28.3 (internal db7f094)
This commit is contained in:
parent
636adfcef2
commit
e6642d0e10
102 changed files with 4821 additions and 782 deletions
|
|
@ -191,6 +191,11 @@ internal static class DungeonLight
|
|||
public const string Usage =
|
||||
"/rv light [on|off] | 0-100 (strength) | dungeons|indoors|everywhere | color RRGGBB|white|torch|moon | show | status";
|
||||
|
||||
/// <summary>What /rv light says after a change: the light's settings now (and why it can't light on an old engine).</summary>
|
||||
public static string Summary(bool on, int strength, LightScope scope, uint colorArgb, bool engineHasApi) =>
|
||||
$"Dungeon light {(on ? "on" : "off")}: strength {strength}%, {ScopeWord(scope)}, {ColorName(colorArgb)}."
|
||||
+ (engineHasApi ? "" : " Needs a newer RynthCore (plugin API 91) to light anything.");
|
||||
|
||||
/// <summary>One line for chat and the Light tab: what the light is doing here and why.</summary>
|
||||
public static string StatusLine(in LightStatus s)
|
||||
{
|
||||
|
|
|
|||
|
|
@ -40,6 +40,8 @@
|
|||
<Compile Include="..\Shared\SafeImGui.cs" Link="Shared\SafeImGui.cs" />
|
||||
<Compile Include="..\Shared\RynthUi\RynthUi.cs" Link="Shared\RynthUi\RynthUi.cs" />
|
||||
<Compile Include="..\Shared\RynthUi\RynthIcons.cs" Link="Shared\RynthUi\RynthIcons.cs" />
|
||||
<!-- How a chat command answers (2026-10-28): the shared reply queue and colours. -->
|
||||
<Compile Include="..\Shared\CommandReply.cs" Link="Shared\CommandReply.cs" />
|
||||
</ItemGroup>
|
||||
<ItemGroup>
|
||||
<PackageReference Include="ImGui.NET" Version="1.91.6.1" />
|
||||
|
|
|
|||
|
|
@ -170,9 +170,10 @@ public sealed partial class RynthVisionPlugin
|
|||
if (_hostsWindow && Host.SetPanelOpen(VisionManifest.Title, RynthPanelOpen.Open) >= 0)
|
||||
{
|
||||
RequestTab(VisionTab.Light);
|
||||
LightChat("Vision window shown, on its Light tab.");
|
||||
return;
|
||||
}
|
||||
LightChat("The Vision window's Light tab needs a newer RynthCore (plugin API 91); " + DungeonLight.Usage);
|
||||
LightChat("The Vision window's Light tab needs a newer RynthCore (plugin API 91); " + DungeonLight.Usage, ok: false);
|
||||
return;
|
||||
case LightCommandKind.Status:
|
||||
LightChat("Dungeon light: " + DungeonLight.StatusLine(CurrentLightStatus(Host.HasAmbientLight)));
|
||||
|
|
@ -181,21 +182,18 @@ public sealed partial class RynthVisionPlugin
|
|||
LightChat(DungeonLight.Usage);
|
||||
return;
|
||||
default:
|
||||
LightChat(cmd.Error + " " + DungeonLight.Usage);
|
||||
LightChat(cmd.Error + " " + DungeonLight.Usage, ok: false);
|
||||
return;
|
||||
}
|
||||
s.Save();
|
||||
MarkSettingsChanged();
|
||||
string summary = $"Dungeon light {(s.LightOn ? "on" : "off")}: strength {s.LightStrength}%, " +
|
||||
$"{DungeonLight.ScopeWord((LightScope)s.LightScope)}, {DungeonLight.ColorName(s.LightColorArgb)}.";
|
||||
if (!Host.HasAmbientLight)
|
||||
summary += " Needs a newer RynthCore (plugin API 91) to light anything.";
|
||||
LightChat(summary);
|
||||
LightChat(DungeonLight.Summary(s.LightOn, s.LightStrength, (LightScope)s.LightScope, s.LightColorArgb, Host.HasAmbientLight));
|
||||
}
|
||||
|
||||
private void LightChat(string text)
|
||||
/// <summary>/rv light's answer: the log, and chat through the reply queue (Plugins/Shared/CommandReply.cs).</summary>
|
||||
private void LightChat(string text, bool ok = true)
|
||||
{
|
||||
Host.Log("[RynthVision] " + text);
|
||||
if (Host.HasWriteToChat) Host.WriteToChat("[RynthVision] " + text, 1);
|
||||
_reply.Say(ok, text);
|
||||
}
|
||||
}
|
||||
|
|
|
|||
|
|
@ -69,7 +69,7 @@ public sealed partial class RynthVisionPlugin
|
|||
});
|
||||
|
||||
/// <summary>"Log terrain types here": on the tick (it may open the terrain data). Any thread.</summary>
|
||||
internal void QueueInspectTerrain() => _uiActions.Enqueue(InspectTerrain);
|
||||
internal void QueueInspectTerrain(bool toChat = false) => _uiActions.Enqueue(() => InspectTerrain(toChat));
|
||||
|
||||
/// <summary>Asks the window to show <paramref name="tab"/> on its next draw. Any thread.</summary>
|
||||
private void RequestTab(VisionTab tab) => Volatile.Write(ref _tabRequest, (int)tab);
|
||||
|
|
|
|||
|
|
@ -3,6 +3,7 @@ using System.Collections.Generic;
|
|||
using System.Diagnostics;
|
||||
using RynthCore.Plugin.RynthAi.Raycasting;
|
||||
using RynthCore.Plugin.RynthVision.Overlays;
|
||||
using RynthCore.Plugin.Shared;
|
||||
using RynthCore.PluginCore;
|
||||
using RynthCore.TerrainData;
|
||||
|
||||
|
|
@ -49,8 +50,12 @@ public sealed partial class RynthVisionPlugin : RynthPluginBase
|
|||
private bool _debug;
|
||||
private int _dbgTick;
|
||||
|
||||
// What /rv says, queued and written by the tick (Plugins/Shared/CommandReply.cs).
|
||||
private CommandReply _reply = null!;
|
||||
|
||||
public override int Initialize()
|
||||
{
|
||||
_reply = new CommandReply("[RynthVision]", (t, c) => Host.WriteToChat(t, c), t => Host.Log(t));
|
||||
// The Vision window draws with ImGui.NET bound to the engine's cimgui, in its look.
|
||||
RynthCore.Plugin.Shared.ImGuiNativeBinding.Ensure(msg => Host.Log("[RynthVision] " + msg));
|
||||
RynthCore.Plugin.Shared.RynthUi.RynthUi.Init(Host);
|
||||
|
|
@ -87,6 +92,7 @@ public sealed partial class RynthVisionPlugin : RynthPluginBase
|
|||
{
|
||||
// The window's, /rv's and the light's changes first: this tick draws with them.
|
||||
TickUi();
|
||||
_reply.Flush();
|
||||
|
||||
// One pose for the light and every overlay this tick.
|
||||
bool inWorld = Host.TryGetPlayerPose(out uint cellId, out float x, out float y, out float z,
|
||||
|
|
@ -174,26 +180,35 @@ public sealed partial class RynthVisionPlugin : RynthPluginBase
|
|||
|
||||
string arg = text.Length > 3 ? text.Substring(3).Trim().ToLowerInvariant() : string.Empty;
|
||||
|
||||
// Every /rv answers in chat (2026-10-28, VisionCommands.cs; Plugins/Shared/CommandReply.cs). RynthVision
|
||||
// can't tell a typed /rv from a meta's, so each one does.
|
||||
VisionVerb verb = VisionCommands.Parse(arg, out string lightArgs);
|
||||
|
||||
// "/rv light ..." (Light/DungeonLight.ParseCommand): applied and answered in chat on the tick.
|
||||
if (arg == "light" || arg.StartsWith("light ", StringComparison.Ordinal))
|
||||
if (verb == VisionVerb.Light)
|
||||
{
|
||||
QueueLightCommand(arg.Substring(5));
|
||||
QueueLightCommand(lightArgs);
|
||||
return;
|
||||
}
|
||||
|
||||
// The settings are the tick's (the Vision window reads the copy it publishes): toggles go through
|
||||
// its queue, like the window's own changes.
|
||||
Action<VisionSettings>? toggle;
|
||||
switch (arg)
|
||||
switch (verb)
|
||||
{
|
||||
case "radar": toggle = static st => st.ShowRadarRing = !st.ShowRadarRing; break;
|
||||
case "slopes": toggle = static st => st.ShowUnclimbableSlopes = !st.ShowUnclimbableSlopes; break;
|
||||
case "water": toggle = static st => st.ShowImpassableWater = !st.ShowImpassableWater; break;
|
||||
case "watertypes": QueueInspectTerrain(); return;
|
||||
case "debug": _debug = !_debug; Host.Log($"[RynthVision] debug = {_debug}"); return;
|
||||
case "": toggle = null; break;
|
||||
case VisionVerb.Radar: toggle = static st => st.ShowRadarRing = !st.ShowRadarRing; break;
|
||||
case VisionVerb.Slopes: toggle = static st => st.ShowUnclimbableSlopes = !st.ShowUnclimbableSlopes; break;
|
||||
case VisionVerb.Water: toggle = static st => st.ShowImpassableWater = !st.ShowImpassableWater; break;
|
||||
case VisionVerb.WaterTypes: QueueInspectTerrain(toChat: true); return;
|
||||
case VisionVerb.Debug:
|
||||
_debug = !_debug;
|
||||
Host.Log($"[RynthVision] debug = {_debug}");
|
||||
_reply.Ok(VisionCommands.Debug(_debug));
|
||||
return;
|
||||
case VisionVerb.Status: toggle = null; break;
|
||||
default:
|
||||
Host.Log($"[RynthVision] Unknown option '{arg}'. Use radar | slopes | water | watertypes | debug | light.");
|
||||
_reply.Fail(VisionCommands.Unknown(arg));
|
||||
return;
|
||||
}
|
||||
|
||||
|
|
@ -203,6 +218,13 @@ public sealed partial class RynthVisionPlugin : RynthPluginBase
|
|||
_settings.Save();
|
||||
MarkSettingsChanged();
|
||||
Host.Log($"[RynthVision] radar={_settings.ShowRadarRing} slopes={_settings.ShowUnclimbableSlopes} water={_settings.ShowImpassableWater}");
|
||||
_reply.Ok(verb switch
|
||||
{
|
||||
VisionVerb.Radar => VisionCommands.Switched(verb, _settings.ShowRadarRing),
|
||||
VisionVerb.Slopes => VisionCommands.Switched(verb, _settings.ShowUnclimbableSlopes),
|
||||
VisionVerb.Water => VisionCommands.Switched(verb, _settings.ShowImpassableWater),
|
||||
_ => VisionCommands.State(_settings.ShowRadarRing, _settings.ShowUnclimbableSlopes, _settings.ShowImpassableWater),
|
||||
});
|
||||
});
|
||||
}
|
||||
|
||||
|
|
@ -245,20 +267,28 @@ public sealed partial class RynthVisionPlugin : RynthPluginBase
|
|||
/// which indices belong in VisionSettings.WaterTerrainTypes. An explicit
|
||||
/// request, so it opens the terrain data if the overlays haven't.
|
||||
/// </summary>
|
||||
internal void InspectTerrain()
|
||||
internal void InspectTerrain() => InspectTerrain(toChat: false);
|
||||
|
||||
/// <summary><paramref name="toChat"/>: /rv watertypes, which answers in chat as well as the log.</summary>
|
||||
internal void InspectTerrain(bool toChat)
|
||||
{
|
||||
if (!_terrain.IsReady && !InitTerrain())
|
||||
{
|
||||
if (toChat) _reply.Fail($"Terrain data unavailable: {_terrain.Status}.");
|
||||
return;
|
||||
}
|
||||
if (!Host.TryGetPlayerPose(out uint cellId, out float px, out float py, out _, out _, out _, out _, out _) ||
|
||||
(cellId & 0xFFFF) >= 0x100 || (cellId >> 16) == 0)
|
||||
{
|
||||
Host.Log("[RynthVision] Stand outdoors to inspect terrain types.");
|
||||
if (toChat) _reply.Fail("Stand outdoors to inspect terrain types.");
|
||||
return;
|
||||
}
|
||||
LandblockData? lb = _terrain.LoadLandblock(cellId >> 16);
|
||||
if (lb == null)
|
||||
{
|
||||
Host.Log("[RynthVision] No terrain data for this landblock.");
|
||||
if (toChat) _reply.Fail("No terrain data for this landblock.");
|
||||
return;
|
||||
}
|
||||
|
||||
|
|
@ -272,5 +302,6 @@ public sealed partial class RynthVisionPlugin : RynthPluginBase
|
|||
seen.Add(TerrainSampler.GetTerrainType(lb, ix, iy));
|
||||
|
||||
Host.Log($"[RynthVision] At cell ({cx},{cy}) terrain type = {hereType}. Landblock types: {string.Join(", ", seen)}");
|
||||
if (toChat) _reply.Ok($"At cell ({cx},{cy}) terrain type = {hereType}. Landblock types: {string.Join(", ", seen)}");
|
||||
}
|
||||
}
|
||||
|
|
|
|||
61
Plugins/RynthCore.Plugin.RynthVision/VisionCommands.cs
Normal file
61
Plugins/RynthCore.Plugin.RynthVision/VisionCommands.cs
Normal file
|
|
@ -0,0 +1,61 @@
|
|||
// ============================================================================
|
||||
// RynthVision - VisionCommands.cs
|
||||
// The /rv chat command's words and what it answers (2026-10-28: every
|
||||
// command answers in chat, Plugins/Shared/CommandReply.cs). "/rv light ..."
|
||||
// is Light/DungeonLight.cs's. Pure, so RynthVision.Tests checks every verb.
|
||||
// ============================================================================
|
||||
|
||||
using RynthCore.Plugin.Shared;
|
||||
|
||||
namespace RynthCore.Plugin.RynthVision;
|
||||
|
||||
internal enum VisionVerb { Status, Radar, Slopes, Water, WaterTypes, Debug, Light, Unknown }
|
||||
|
||||
internal static class VisionCommands
|
||||
{
|
||||
public const string Usage = "/rv [radar | slopes | water] (show or hide) | watertypes | debug | light ... (/rv light help)";
|
||||
|
||||
/// <summary>The words after "/rv" (lower case): the verb, and for light what follows it.</summary>
|
||||
public static VisionVerb Parse(string arg, out string lightArgs)
|
||||
{
|
||||
lightArgs = string.Empty;
|
||||
string a = (arg ?? string.Empty).Trim().ToLowerInvariant();
|
||||
if (a == "light" || a.StartsWith("light ", System.StringComparison.Ordinal))
|
||||
{
|
||||
lightArgs = a.Substring(5);
|
||||
return VisionVerb.Light;
|
||||
}
|
||||
return a switch
|
||||
{
|
||||
"" => VisionVerb.Status,
|
||||
"radar" => VisionVerb.Radar,
|
||||
"slopes" => VisionVerb.Slopes,
|
||||
"water" => VisionVerb.Water,
|
||||
"watertypes" => VisionVerb.WaterTypes,
|
||||
"debug" => VisionVerb.Debug,
|
||||
_ => VisionVerb.Unknown,
|
||||
};
|
||||
}
|
||||
|
||||
/// <summary>The overlay a verb switches: its name in chat.</summary>
|
||||
public static string OverlayName(VisionVerb verb) => verb switch
|
||||
{
|
||||
VisionVerb.Radar => "Radar ring",
|
||||
VisionVerb.Slopes => "Unclimbable slopes",
|
||||
VisionVerb.Water => "Impassable water",
|
||||
_ => verb.ToString(),
|
||||
};
|
||||
|
||||
/// <summary>"/rv radar": the overlay's new state.</summary>
|
||||
public static string Switched(VisionVerb verb, bool on) => $"{OverlayName(verb)} {CommandReply.OnOff(on)}.";
|
||||
|
||||
/// <summary>"/rv" alone: the overlays' state and the usage.</summary>
|
||||
public static string State(bool radar, bool slopes, bool water) =>
|
||||
$"Radar ring {CommandReply.OnOff(radar)}, unclimbable slopes {CommandReply.OnOff(slopes)}, impassable water {CommandReply.OnOff(water)}. {Usage}";
|
||||
|
||||
/// <summary>"/rv debug": the pose stream's new state.</summary>
|
||||
public static string Debug(bool on) => $"Debug {CommandReply.OnOff(on)} (the player's pose and the overlays' landblock lines go to the log).";
|
||||
|
||||
/// <summary>A word /rv doesn't know.</summary>
|
||||
public static string Unknown(string arg) => $"Unknown '/rv {(arg ?? string.Empty).Trim()}'. Usage: {Usage}";
|
||||
}
|
||||
Loading…
Reference in a new issue