Added many other

This commit is contained in:
2026-08-06 18:56:32 +03:00
parent 9f2fd08ee5
commit d9d7ee49d2
2144 changed files with 1115424 additions and 1284 deletions
@@ -0,0 +1,64 @@
using Unity.Netcode;
using UnityEngine;
using UnityEngine.InputSystem;
public sealed class PlayerHandController : NetworkBehaviour, IPlayerSystem
{
[SerializeField] private Transform itemSocket;
private bool isInitialized;
public Transform ItemSocket => itemSocket;
public void Initialize(PlayerFacade facade)
{
if (itemSocket == null)
{
Transform candidate = transform.Find("HandItemSocket");
if (candidate != null)
itemSocket = candidate;
}
isInitialized = itemSocket != null;
}
private void Update()
{
if (!isInitialized || !IsOwner || Keyboard.current == null)
return;
if (!NetworkHandItemInteractable.TryGetHeldItem(
OwnerClientId,
out NetworkHandItemInteractable heldItem))
{
return;
}
if (Mouse.current != null && Mouse.current.leftButton.wasPressedThisFrame)
heldItem.RequestUse();
if (Keyboard.current.gKey.wasPressedThisFrame)
heldItem.RequestThrow();
}
private void OnGUI()
{
if (!IsOwner ||
!NetworkHandItemInteractable.TryGetHeldItem(
OwnerClientId,
out NetworkHandItemInteractable heldItem))
{
return;
}
GUIStyle style = new(GUI.skin.label)
{
alignment = TextAnchor.MiddleCenter,
fontSize = 15,
normal = { textColor = Color.white }
};
Rect area = new(0f, Screen.height * 0.68f, Screen.width, 28f);
GUI.Label(area, $"{heldItem.ItemName} [LMB] Use [G] Throw", style);
}
}