Skip to content
This repository has been archived by the owner on Jan 24, 2023. It is now read-only.

Commit

Permalink
Added option to include self in wireframe and fixed RiskyFunctionMana…
Browse files Browse the repository at this point in the history
…ger callback.
  • Loading branch information
RequiDev committed Sep 28, 2021
1 parent aa0424e commit fb0e6c1
Showing 1 changed file with 35 additions and 6 deletions.
41 changes: 35 additions & 6 deletions ReModCE/Components/WireframeComponent.cs
Original file line number Diff line number Diff line change
Expand Up @@ -28,20 +28,38 @@ internal class WireframeComponent : ModComponent
private ConfigValue<bool> WireframeEnabled;
private ReQuickToggle _wireframeToggle;

private ConfigValue<bool> WireframeIncludeSelf;
private ReQuickToggle _includeSelfToggle;

public WireframeComponent()
{
WireframeEnabled = new ConfigValue<bool>(nameof(WireframeEnabled), false);
WireframeEnabled.OnValueChanged += () =>
{
_wireframeToggle.Toggle(WireframeEnabled);
_wireframeCamera.enabled = WireframeEnabled;
};

RiskyFunctionsManager.Instance.OnRiskyFunctionsChanged += allowed =>
WireframeIncludeSelf = new ConfigValue<bool>(nameof(WireframeIncludeSelf), true);
WireframeIncludeSelf.OnValueChanged += () =>
{
_includeSelfToggle.Toggle(WireframeIncludeSelf);
if (WireframeIncludeSelf)
{
_wireframeCamera.cullingMask |= 1 << LayerMask.NameToLayer("PlayerLocal");
}
else
{
_wireframeToggle.Interactable = allowed;
if (!allowed)
WireframeEnabled.SetValue(false);
};
_wireframeCamera.cullingMask &= ~(1 << LayerMask.NameToLayer("PlayerLocal"));
}
_wireframeCamera.enabled = WireframeEnabled;
};

RiskyFunctionsManager.Instance.OnRiskyFunctionsChanged += allowed =>
{
_wireframeToggle.Interactable = allowed;
if (!allowed)
WireframeEnabled.SetValue(false);
};
}

Expand All @@ -57,10 +75,12 @@ public override void OnUiManagerInit(UiManager uiManager)
var menu = uiManager.MainMenu.GetSubMenu("Visuals");
_wireframeToggle = menu.AddToggle("Wireframe", "Highlight players using wireframe.",
WireframeEnabled.SetValue, WireframeEnabled);
_includeSelfToggle = menu.AddToggle("Include Self (Wireframe)", "Include yourself in wireframe ESP",
WireframeIncludeSelf.SetValue, WireframeIncludeSelf);
}


private static Camera CreateCamera()
private Camera CreateCamera()
{
var refCam = GameObject.Find("Camera (eye)");
if (refCam == null)
Expand All @@ -87,6 +107,15 @@ private static Camera CreateCamera()
camera.fieldOfView = referenceCamera.fieldOfView;
camera.clearFlags = CameraClearFlags.Nothing;
camera.cullingMask = 1 << LayerMask.NameToLayer("Player");

if (WireframeIncludeSelf)
{
_wireframeCamera.cullingMask |= 1 << LayerMask.NameToLayer("PlayerLocal");
}
else
{
_wireframeCamera.cullingMask &= ~(1 << LayerMask.NameToLayer("PlayerLocal"));
}
camera.nearClipPlane /= 4f;

return camera;
Expand Down

0 comments on commit fb0e6c1

Please sign in to comment.