Grass Cutters Together: the project as of moon-sweepers f3666f0

A clean start for the shared repository: the Unity project (Assets, Packages, ProjectSettings), ArtSource, Docs and
Tools as they stood at f3666f0 in the old local repository, with its generated prefabs and scene brought up to date.
Images, audio, models and binaries go through Git LFS (.gitattributes).

Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
This commit is contained in:
NiemandKG
2026-11-06 18:44:40 +06:00
parent 0f0467cd0c
commit d1c3761e58
4190 changed files with 270757 additions and 1 deletions

View File

@ -0,0 +1,94 @@
using UnityEngine;
namespace GrassCutter
{
/// <summary>Carrying props: the holder owns the body and drives it toward a point in front of the camera.</summary>
public class PlayerGrab : MonoBehaviour
{
PlayerAgent _p;
Grabbable _held, _pending;
float _pendingTime;
Quaternion _relRot;
public bool Holding => _held;
public Grabbable Held => _held;
void Awake() { _p = GetComponent<PlayerAgent>(); }
public void TryGrab(Grabbable g)
{
if (_held || !g) return;
_pending = g;
_pendingTime = Time.time;
g.RequestGrab();
}
/// <summary>Server granted us the grab (ownership is ours now or very soon).</summary>
public void OnGrantedGrab(Grabbable g)
{
if (_pending != g && _held) return;
_held = g;
_pending = null;
_relRot = Quaternion.Inverse(transform.rotation) * g.transform.rotation;
Tween.Punch(g.transform, 0.08f, 0.25f);
CameraFx.FovKick(-1.5f);
}
public void Drop()
{
if (!_held) return;
var v = _p.Velocity * 0.6f;
_held.Release(v, Vector3.zero);
_held = null;
}
void Throw()
{
if (!_held) return;
var cam = CameraFx.Cam;
float mass = _held.Body ? _held.Body.mass : 1f;
float power = Mathf.Lerp(10.5f, 6f, Mathf.InverseLerp(0.5f, 6f, mass)) * (TeamState.Instance ? GameDefs.ThrowMul(TeamState.Instance.Level(PerkId.ThrowArm)) : 1f);
var v = (cam ? cam.transform.forward : transform.forward) * power + _p.Velocity * 0.5f + transform.up * 1.2f;
_held.Release(v, Random.insideUnitSphere * 5f);
_held = null;
Sfx.Play("throw_whoosh", 0.7f, 1f, 0.1f);
CameraFx.FovKick(2.5f);
CameraFx.Shake(0.08f);
}
void Update()
{
if (!_p.IsOwner) return;
if (_pending && Time.time - _pendingTime > 1f) _pending = null;
if (!_held) return;
if (!_held.IsSpawned || _held.Consumed) { _held = null; return; }
if (_held.Holder.Value != Grabbable.Nobody && _held.Holder.Value != _p.OwnerClientId) { _held = null; return; }
if (Ctl.UsePressed || Ctl.AltPressed) { Throw(); return; }
// R turns whatever you carry
if (Ctl.RotatePressed)
{
_relRot = Quaternion.Euler(0f, 45f, 0f) * _relRot;
Sfx.Play("ui_hover", 0.4f, 0.9f);
}
}
void FixedUpdate()
{
if (!_held || !_p.IsOwner || !_held.IsOwner) return;
var rb = _held.Body;
if (!rb || rb.isKinematic) return;
var cam = CameraFx.Cam;
if (!cam) return;
var target = cam.transform.position + cam.transform.forward * _held.holdDistance - transform.up * 0.15f;
var delta = target - rb.worldCenterOfMass;
if (delta.magnitude > 3.5f) { Drop(); return; }
rb.linearVelocity = Vector3.ClampMagnitude(delta * 16f, 18f);
var targetRot = transform.rotation * _relRot;
var dq = targetRot * Quaternion.Inverse(rb.rotation);
dq.ToAngleAxis(out float ang, out Vector3 axis);
if (ang > 180f) ang -= 360f;
if (Mathf.Abs(ang) > 0.01f && !float.IsNaN(axis.x)) rb.angularVelocity = axis * (ang * Mathf.Deg2Rad * 12f);
else rb.angularVelocity = Vector3.zero;
}
}
}