first commit

This commit is contained in:
2025-07-06 00:23:46 +02:00
commit 38f50c8819
1788 changed files with 112878 additions and 0 deletions

View File

@@ -0,0 +1,44 @@
using System.Reflection;
using NitroxClient.GameLogic.Bases;
using NitroxClient.GameLogic.Settings;
using NitroxClient.Helpers;
using NitroxModel.DataStructures;
using NitroxModel.Helper;
using UnityEngine;
namespace NitroxPatcher.Patches.Dynamic;
/// <summary>
/// Changes the piece color during the placing process if the current base is desynced.
/// </summary>
public sealed partial class Builder_Update_Patch : NitroxPatch, IDynamicPatch
{
public static readonly MethodInfo TARGET_METHOD = Reflect.Method(() => Builder.Update());
private static readonly Color DESYNCED_COLOR = Color.magenta;
public static void Postfix()
{
if (!Builder.canPlace || !BuildingHandler.Main || !NitroxPrefs.SafeBuilding.Value)
{
return;
}
BaseGhost baseGhost = Builder.ghostModel.GetComponent<BaseGhost>();
GameObject parentBase;
if (baseGhost && baseGhost.targetBase)
{
parentBase = baseGhost.targetBase.gameObject;
}
// In case it's a simple Constructable
else
{
parentBase = Builder.placementTarget;
}
if (parentBase && parentBase.TryGetNitroxId(out NitroxId parentId) &&
BuildingHandler.Main.EnsureTracker(parentId).IsDesynced())
{
Builder.canPlace = false;
Builder.ghostStructureMaterial.SetColor(ShaderPropertyID._Tint, DESYNCED_COLOR);
}
}
}