diff --git a/Assets/PerfectWorld/Scene/Bootstrap.unity b/Assets/PerfectWorld/Scene/Bootstrap.unity index 05360e0fde..141d371899 100644 --- a/Assets/PerfectWorld/Scene/Bootstrap.unity +++ b/Assets/PerfectWorld/Scene/Bootstrap.unity @@ -1,3 +1,3 @@ version https://git-lfs.github.com/spec/v1 -oid sha256:543e09f5571b2d48dd57646eee06f8efbc71e6aaa62d6e8a98a529dec44b7364 -size 322591 +oid sha256:f85e6e6bc4d5b6af2e103cf46a846213439f86c209bed0512839f28b8c23a7c6 +size 326984 diff --git a/Assets/PerfectWorld/Scripts/Managers/EC_HostInputFilter.cs b/Assets/PerfectWorld/Scripts/Managers/EC_HostInputFilter.cs index 658a7992c9..edfce9b093 100644 --- a/Assets/PerfectWorld/Scripts/Managers/EC_HostInputFilter.cs +++ b/Assets/PerfectWorld/Scripts/Managers/EC_HostInputFilter.cs @@ -3,6 +3,7 @@ using BrewMonster.Network; using BrewMonster.Scripts; using CSNetwork.GPDataType; using PerfectWorld.Scripts; +using PerfectWorld.Scripts.Managers; using CSNetwork; using UnityEngine; using static BrewMonster.Scripts.CECHPWork; @@ -610,6 +611,36 @@ namespace BrewMonster return bOK; } + /// + /// HUD / shortcut: walk to and pick up the nearest ground item or money (not mines) within range. + /// + /// Max horizontal distance to search (meters). + /// True if a matter was found and started. + public bool TryPickupNearestGroundMatter(float maxSearchRadiusH = 80f) + { + if (IsDead() || m_pWorkMan == null) + return false; + + if (m_pWorkMan.IsSitting()) + { + UnityGameSession.c2s_CmdStandUp(); + return false; + } + + if (!CanDo(ActionCanDo.CANDO_MOVETO)) + return false; + + EC_ManMatter matterMan = EC_ManMessageMono.Instance?.EC_ManMatter; + if (matterMan == null) + return false; + + CECMatter nearest = matterMan.GetNearestPickupableMatter(GetPos(), maxSearchRadiusH); + if (nearest == null) + return false; + + return PickupObject(nearest.GetMatterID(), false); + } + // Check whether host can gather specified matter / Check whether host can gather specified matter public bool CanGatherMatter(CECMatter pMatter) { diff --git a/Assets/PerfectWorld/Scripts/Managers/EC_ManMatter.cs b/Assets/PerfectWorld/Scripts/Managers/EC_ManMatter.cs index 1275ab4198..6860f41640 100644 --- a/Assets/PerfectWorld/Scripts/Managers/EC_ManMatter.cs +++ b/Assets/PerfectWorld/Scripts/Managers/EC_ManMatter.cs @@ -314,6 +314,31 @@ namespace PerfectWorld.Scripts.Managers } return null; } + + /// + /// Nearest ground item or money matter within horizontal of . + /// Mines (gather nodes) are excluded — use direct click / gather flow for those. + /// + public CECMatter GetNearestPickupableMatter(A3DVECTOR3 hostPos, float maxRadiusH) + { + CECMatter best = null; + float bestDist = float.MaxValue; + foreach (var kv in m_MatterTab) + { + CECMatter m = kv.Value; + if (m == null || !m) + continue; + if (m.IsMine()) + continue; + + float d = m.CalcDist(hostPos, false); + if (d > maxRadiusH || d >= bestDist) + continue; + bestDist = d; + best = m; + } + return best; + } public CECMatter CreateMatter(info_matter info) { diff --git a/Assets/PerfectWorld/Scripts/UI/PickupNearestButtonHandler.cs b/Assets/PerfectWorld/Scripts/UI/PickupNearestButtonHandler.cs new file mode 100644 index 0000000000..877241503e --- /dev/null +++ b/Assets/PerfectWorld/Scripts/UI/PickupNearestButtonHandler.cs @@ -0,0 +1,44 @@ +using UnityEngine; +using UnityEngine.UI; + +namespace BrewMonster.UI +{ + /// + /// HUD button: pick up the nearest ground item or money (host trace + TryPickupNearestGroundMatter). + /// Assign to a Button or leave unassigned to use the component's own Button. + /// + public class PickupNearestButtonHandler : MonoBehaviour + { + [SerializeField] private Button button; + [Tooltip("Horizontal search radius around the player (meters).")] + [SerializeField] private float maxSearchRadius = 80f; + + private void Start() + { + if (button == null) + button = GetComponent