Compare commits
5
Commits
7200980a23
..
main
| Author | SHA1 | Date | |
|---|---|---|---|
|
|
c383b4056c | ||
|
|
d1e62186e4 | ||
|
|
69c3d18a36 | ||
|
|
b70b9b7e7d | ||
|
|
0056b443e4 |
@@ -16,10 +16,6 @@
|
|||||||
<HintPath>$(VINTAGE_STORY)/Lib/protobuf-net.dll</HintPath>
|
<HintPath>$(VINTAGE_STORY)/Lib/protobuf-net.dll</HintPath>
|
||||||
<Private>False</Private>
|
<Private>False</Private>
|
||||||
</Reference>
|
</Reference>
|
||||||
<Reference Include="ClaimLink">
|
|
||||||
<HintPath>$(CLAIMLINK)/ClaimLink.dll</HintPath>
|
|
||||||
<Private>false</Private>
|
|
||||||
</Reference>
|
|
||||||
</ItemGroup>
|
</ItemGroup>
|
||||||
|
|
||||||
<ItemGroup>
|
<ItemGroup>
|
||||||
|
|||||||
@@ -10,13 +10,15 @@ internal static class ClaimLinkVisualizerClient
|
|||||||
private const int HighlightSlotId = 8341;
|
private const int HighlightSlotId = 8341;
|
||||||
private static ICoreClientAPI capi = null!;
|
private static ICoreClientAPI capi = null!;
|
||||||
private static bool visible;
|
private static bool visible;
|
||||||
|
private static ClaimLinkVisualizerConfig config = null!;
|
||||||
|
|
||||||
internal static void Start(ICoreClientAPI api)
|
internal static void Start(ICoreClientAPI api)
|
||||||
{
|
{
|
||||||
capi = api;
|
capi = api;
|
||||||
|
config = api.LoadModConfig<ClaimLinkVisualizerConfig>("claimlinkvisualizer.json") ?? new ClaimLinkVisualizerConfig();
|
||||||
|
api.StoreModConfig(config, "claimlinkvisualizer.json");
|
||||||
|
|
||||||
api.Network
|
api.Network.RegisterChannel(ClaimLinkVisualizerModSystem.ChannelName)
|
||||||
.RegisterChannel(ClaimLinkVisualizerModSystem.ChannelName)
|
|
||||||
.RegisterMessageType<ClaimLinkBufferRequest>()
|
.RegisterMessageType<ClaimLinkBufferRequest>()
|
||||||
.RegisterMessageType<ClaimLinkBufferResponse>()
|
.RegisterMessageType<ClaimLinkBufferResponse>()
|
||||||
.SetMessageHandler<ClaimLinkBufferResponse>(OnBufferResponse);
|
.SetMessageHandler<ClaimLinkBufferResponse>(OnBufferResponse);
|
||||||
@@ -24,7 +26,7 @@ internal static class ClaimLinkVisualizerClient
|
|||||||
api.Input.RegisterHotKey(
|
api.Input.RegisterHotKey(
|
||||||
"claimlinkvisualizertoggle",
|
"claimlinkvisualizertoggle",
|
||||||
"Toggle ClaimLink buffer visualization",
|
"Toggle ClaimLink buffer visualization",
|
||||||
GlKeys.J,
|
GlKeys.R,
|
||||||
HotkeyType.CharacterControls,
|
HotkeyType.CharacterControls,
|
||||||
ctrlPressed: true
|
ctrlPressed: true
|
||||||
);
|
);
|
||||||
@@ -35,8 +37,7 @@ internal static class ClaimLinkVisualizerClient
|
|||||||
{
|
{
|
||||||
visible = !visible;
|
visible = !visible;
|
||||||
if (visible)
|
if (visible)
|
||||||
capi.Network
|
capi.Network.GetChannel(ClaimLinkVisualizerModSystem.ChannelName)
|
||||||
.GetChannel(ClaimLinkVisualizerModSystem.ChannelName)
|
|
||||||
.SendPacket(new ClaimLinkBufferRequest());
|
.SendPacket(new ClaimLinkBufferRequest());
|
||||||
else
|
else
|
||||||
Clear();
|
Clear();
|
||||||
@@ -55,9 +56,9 @@ internal static class ClaimLinkVisualizerClient
|
|||||||
{
|
{
|
||||||
int color = HashToColor(entry.GroupId);
|
int color = HashToColor(entry.GroupId);
|
||||||
foreach (BufferCuboidDto cuboid in entry.Cuboids)
|
foreach (BufferCuboidDto cuboid in entry.Cuboids)
|
||||||
foreach (BlockPos corner in Corners(cuboid))
|
|
||||||
{
|
{
|
||||||
positions.Add(corner);
|
positions.Add(new BlockPos(cuboid.MinX, cuboid.MinY, cuboid.MinZ));
|
||||||
|
positions.Add(new BlockPos(cuboid.MaxX, cuboid.MaxY, cuboid.MaxZ));
|
||||||
colors.Add(color);
|
colors.Add(color);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
@@ -68,7 +69,7 @@ internal static class ClaimLinkVisualizerClient
|
|||||||
positions,
|
positions,
|
||||||
colors,
|
colors,
|
||||||
EnumHighlightBlocksMode.Absolute,
|
EnumHighlightBlocksMode.Absolute,
|
||||||
EnumHighlightShape.Arbitrary
|
EnumHighlightShape.Cubes
|
||||||
);
|
);
|
||||||
}
|
}
|
||||||
|
|
||||||
@@ -80,23 +81,11 @@ internal static class ClaimLinkVisualizerClient
|
|||||||
new List<int>()
|
new List<int>()
|
||||||
);
|
);
|
||||||
|
|
||||||
private static IEnumerable<BlockPos> Corners(BufferCuboidDto c)
|
|
||||||
{
|
|
||||||
yield return new BlockPos(c.MinX, c.MinY, c.MinZ);
|
|
||||||
yield return new BlockPos(c.MaxX, c.MinY, c.MinZ);
|
|
||||||
yield return new BlockPos(c.MinX, c.MaxY, c.MinZ);
|
|
||||||
yield return new BlockPos(c.MinX, c.MinY, c.MaxZ);
|
|
||||||
yield return new BlockPos(c.MaxX, c.MaxY, c.MinZ);
|
|
||||||
yield return new BlockPos(c.MaxX, c.MinY, c.MaxZ);
|
|
||||||
yield return new BlockPos(c.MinX, c.MaxY, c.MaxZ);
|
|
||||||
yield return new BlockPos(c.MaxX, c.MaxY, c.MaxZ);
|
|
||||||
}
|
|
||||||
|
|
||||||
private static int HashToColor(int groupId)
|
private static int HashToColor(int groupId)
|
||||||
{
|
{
|
||||||
unchecked
|
unchecked
|
||||||
{
|
{
|
||||||
uint h = (uint)groupId * 2654435761u;
|
uint h = (uint)groupId * config.ColorHashSeed;
|
||||||
int r = (byte)(h >> 16);
|
int r = (byte)(h >> 16);
|
||||||
int g = (byte)(h >> 8);
|
int g = (byte)(h >> 8);
|
||||||
int b = (byte)h;
|
int b = (byte)h;
|
||||||
|
|||||||
@@ -0,0 +1,6 @@
|
|||||||
|
namespace ClaimLinkVisualizer;
|
||||||
|
|
||||||
|
internal class ClaimLinkVisualizerConfig
|
||||||
|
{
|
||||||
|
public uint ColorHashSeed = 2654435761u;
|
||||||
|
}
|
||||||
@@ -1,6 +1,5 @@
|
|||||||
using Vintagestory.API.Client;
|
using Vintagestory.API.Client;
|
||||||
using Vintagestory.API.Common;
|
using Vintagestory.API.Common;
|
||||||
using Vintagestory.API.Server;
|
|
||||||
|
|
||||||
namespace ClaimLinkVisualizer;
|
namespace ClaimLinkVisualizer;
|
||||||
|
|
||||||
@@ -8,9 +7,6 @@ public class ClaimLinkVisualizerModSystem : ModSystem
|
|||||||
{
|
{
|
||||||
internal const string ChannelName = "claimlinkvisualizer";
|
internal const string ChannelName = "claimlinkvisualizer";
|
||||||
|
|
||||||
public override void StartServerSide(ICoreServerAPI api) =>
|
|
||||||
ClaimLinkVisualizerServer.Start(api);
|
|
||||||
|
|
||||||
public override void StartClientSide(ICoreClientAPI api) =>
|
public override void StartClientSide(ICoreClientAPI api) =>
|
||||||
ClaimLinkVisualizerClient.Start(api);
|
ClaimLinkVisualizerClient.Start(api);
|
||||||
}
|
}
|
||||||
|
|||||||
@@ -1,47 +0,0 @@
|
|||||||
using System.Collections.Generic;
|
|
||||||
using ClaimLink;
|
|
||||||
using Vintagestory.API.MathTools;
|
|
||||||
using Vintagestory.API.Server;
|
|
||||||
|
|
||||||
namespace ClaimLinkVisualizer;
|
|
||||||
|
|
||||||
internal static class ClaimLinkVisualizerServer
|
|
||||||
{
|
|
||||||
internal static void Start(ICoreServerAPI api)
|
|
||||||
{
|
|
||||||
api.Network
|
|
||||||
.RegisterChannel(ClaimLinkVisualizerModSystem.ChannelName)
|
|
||||||
.RegisterMessageType<ClaimLinkBufferRequest>()
|
|
||||||
.RegisterMessageType<ClaimLinkBufferResponse>()
|
|
||||||
.SetMessageHandler<ClaimLinkBufferRequest>((fromPlayer, _) =>
|
|
||||||
SendBuffers(api, fromPlayer)
|
|
||||||
);
|
|
||||||
}
|
|
||||||
|
|
||||||
private static void SendBuffers(ICoreServerAPI api, IServerPlayer toPlayer)
|
|
||||||
{
|
|
||||||
ClaimLinkBufferResponse response = new();
|
|
||||||
|
|
||||||
foreach (var (groupId, cuboids) in ClaimLinkAPI.BufferMap)
|
|
||||||
{
|
|
||||||
ClaimLinkBufferEntryDto entry = new() { GroupId = groupId };
|
|
||||||
foreach (Cuboidi cuboid in cuboids)
|
|
||||||
entry.Cuboids.Add(
|
|
||||||
new BufferCuboidDto
|
|
||||||
{
|
|
||||||
MinX = cuboid.MinX,
|
|
||||||
MinY = cuboid.MinY,
|
|
||||||
MinZ = cuboid.MinZ,
|
|
||||||
MaxX = cuboid.MaxX,
|
|
||||||
MaxY = cuboid.MaxY,
|
|
||||||
MaxZ = cuboid.MaxZ,
|
|
||||||
}
|
|
||||||
);
|
|
||||||
response.Entries.Add(entry);
|
|
||||||
}
|
|
||||||
|
|
||||||
api.Network
|
|
||||||
.GetChannel(ClaimLinkVisualizerModSystem.ChannelName)
|
|
||||||
.SendPacket(response, toPlayer);
|
|
||||||
}
|
|
||||||
}
|
|
||||||
@@ -3,14 +3,13 @@
|
|||||||
"type": "Code",
|
"type": "Code",
|
||||||
"modid": "claimlinkvisualizer",
|
"modid": "claimlinkvisualizer",
|
||||||
"name": "ClaimLinkVisualizer",
|
"name": "ClaimLinkVisualizer",
|
||||||
"side": "Universal",
|
"side": "Client",
|
||||||
"authors": [
|
"authors": [
|
||||||
"anth64"
|
"anth64"
|
||||||
],
|
],
|
||||||
"description": "Visualizes ClaimLink buffer zones client-side.",
|
"description": "Visualizes ClaimLink buffer zones client-side.",
|
||||||
"version": "0.0.1",
|
"version": "0.1.0",
|
||||||
"dependencies": {
|
"dependencies": {
|
||||||
"game": "1.22.5",
|
"game": "1.22.5"
|
||||||
"claimlink": "0.1.0"
|
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
Reference in New Issue
Block a user