mirror of
https://github.com/JogmansonReal/Radicade.git
synced 2026-10-27 07:59:03 -07:00
Radicade Public Code
This commit is contained in:
@@ -0,0 +1,40 @@
|
||||
using UnityEngine;
|
||||
|
||||
internal static class ToolCollisionLayerRestore
|
||||
{
|
||||
private static int _failures;
|
||||
|
||||
internal static void Restore(Tool tool)
|
||||
{
|
||||
if (tool == null) return;
|
||||
try
|
||||
{
|
||||
if (tool.MEDCLKFANNC) return;
|
||||
int layer = (int)tool.EHNBBIAIJIK;
|
||||
if (layer < 0 || layer > 31)
|
||||
throw new InvalidOperationException("Invalid default collision layer " + layer);
|
||||
|
||||
foreach (var collider in tool.GetComponentsInChildren<Collider>(true))
|
||||
{
|
||||
if (collider == null || collider.isTrigger) continue;
|
||||
if (collider.GetComponentInParent<Tool>() != tool) continue;
|
||||
var owner = collider.gameObject;
|
||||
if (!ShouldRestore(owner.layer, (int)tool.HeldCollisionLayer,
|
||||
(int)tool.EquippedCollisionLayer, (int)tool.AttachedCollisionLayer)) continue;
|
||||
if (owner.layer == layer) continue;
|
||||
owner.layer = layer;
|
||||
}
|
||||
}
|
||||
catch (Exception ex)
|
||||
{
|
||||
if (++_failures <= 5)
|
||||
RadicadeEacBypassPlugin.LogSource.LogWarning("[ToolGuard] collision-layer restore failed: " + ex);
|
||||
}
|
||||
}
|
||||
|
||||
private static bool ShouldRestore(int layer, int held, int equipped, int attached)
|
||||
{
|
||||
return layer == held || layer == equipped || layer == attached
|
||||
|| layer is 0 or 10 or 11 or 13 or 17 or 18 or 23 or 24 or 27;
|
||||
}
|
||||
}
|
||||
Reference in New Issue
Block a user