Skip to content

Commit

Permalink
Change set box item amount to use a radius + Add HelpMarker to ImGuiE…
Browse files Browse the repository at this point in the history
…xtensions
  • Loading branch information
CodeName-Anti committed Sep 1, 2024
1 parent 13aef2b commit 2e90ac8
Show file tree
Hide file tree
Showing 3 changed files with 24 additions and 14 deletions.
2 changes: 1 addition & 1 deletion HTogether/HTogether.csproj
Original file line number Diff line number Diff line change
Expand Up @@ -4,7 +4,7 @@
<TargetFramework>net472</TargetFramework>
<AssemblyName>HTogether</AssemblyName>
<Product>HTogether</Product>
<Version>1.0.2</Version>
<Version>1.0.3</Version>
<AllowUnsafeBlocks>true</AllowUnsafeBlocks>
<LangVersion>latest</LangVersion>
<RestoreAdditionalProjectSources>
Expand Down
23 changes: 10 additions & 13 deletions HTogether/Modules/Test/TestingModule.cs
Original file line number Diff line number Diff line change
Expand Up @@ -22,34 +22,31 @@ public override void RenderGUIElements()
GameObject.FindObjectsByType<BoxData>(FindObjectsSortMode.None).Do(b => b.gameObject.layer = BoxDataPatch.InitialLayer);
}

ImGui.TextColored(Color.red.ToSysVec(), "Look directly at box without escape menu open");
ImGui.TextColored(Color.red.ToSysVec(), "while being far enough away to not pick it up");

ImGui.SliderInt("Box Item Amount", ref amount, 0, 10000);

if (ImGui.Button("Set amount"))
{
SetBoxAmount();
}

ImGui.SameLine();
ImGuiExtensions.HelpMarker("Sets the item amount of the boxes in a small radius.");
}

private void SetBoxAmount()
{
if (!LobbyController.Instance.LocalplayerController.isServer && HTogether.LockdownFeatures)
return;

Camera main = Camera.main;
if (!Physics.Raycast(main.transform.position, main.transform.forward, out RaycastHit hitInfo))
return;

GameObject obj = hitInfo.transform.gameObject;
Collider[] colliders = Physics.OverlapSphere(LobbyController.Instance.LocalplayerController.transform.position, 1.8f);

BoxData data = obj.GetComponentInParent<BoxData>();

if (data == null)
return;
foreach (Collider collider in colliders)
{
if (!collider.TryGetComponent<BoxData>(out BoxData data))
continue;

data.numberOfProducts = amount;
data.numberOfProducts = amount;
}
}

}
13 changes: 13 additions & 0 deletions HTogether/Utils/ImGuiExtensions.cs
Original file line number Diff line number Diff line change
Expand Up @@ -10,6 +10,7 @@
using System.Runtime.InteropServices;
using System.Reflection;
using System;
using IconFonts;

namespace HTogether.Utils;

Expand Down Expand Up @@ -117,4 +118,16 @@ public static unsafe ImFontPtr LoadIconFontFromResources(this ImFontAtlasPtr fon
}
}

public static void HelpMarker(string description)
{
ImGui.TextDisabled(FontAwesome6.CircleQuestion);
if (ImGui.BeginItemTooltip())
{
ImGui.PushTextWrapPos(ImGui.GetFontSize() * 35.0f);
ImGui.TextUnformatted(description);
ImGui.PopTextWrapPos();
ImGui.EndTooltip();
}
}

}

0 comments on commit 2e90ac8

Please sign in to comment.