Round 6 fixes: held tools, headlamp glare, ladder openings, level horizon, roof hulls, rain hits, idle motion, belt packs, meadow variety
- Held tools sit lower and further right; the hammer faces forward and strikes about the camera's right - Headlamp leaves held items, treats and vending machines alone (rendering layer NoLamp); other lights keep lighting them - Hay grounded on the floor in world space (it floated) - Deck fence opens at each ladder, rail colliders split around it; ladders moved to 2 m off the edge middle, clear of the intakes; climbing goes over a rail only if one is in the way - Crew stand to the soil's up (Planet.Level): flat round the base, the ball's up past it, so the horizon stays level on a small planet - Convex roof hulls for the crew cabin, garage, pitched roof and windmill tower; cabin box lowered to the eaves - Rain and acid rain hits differ by surface: soil, grass, wood, metal - Idle motion: dishes pan, sways sway, sensors turn, eyes blink, windmill turns in the breeze, reels and parked rotors tick over - Belt: take tools off at the supply wall; hold E at a vending machine for a pack of 3 on the belt, LMB has one - New meadow pieces: boulders, slab stones, crystals, mushrooms, stump, bulb plants - -demofix checks for all of the above; loc rows in all 11 tables Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
This commit is contained in:
@ -34,7 +34,8 @@ namespace GrassCutter
|
||||
public void Move(Vector3 delta)
|
||||
{
|
||||
var pos = transform.position;
|
||||
var up = Planet.Up(pos);
|
||||
// the body stands the way the crew member stands (the soil's up: see Planet.Level)
|
||||
var up = transform.up;
|
||||
float rise = Vector3.Dot(delta, up);
|
||||
var flat = delta - up * rise;
|
||||
bool was = isGrounded;
|
||||
|
||||
@ -61,6 +61,7 @@ namespace GrassCutter
|
||||
var bank = AssetBank.I;
|
||||
var phone = Instantiate(bank.Model("SM_Phone"), _pivot);
|
||||
phone.name = "PhoneBody";
|
||||
DayNight.KeepOutOfLamp(phone);
|
||||
foreach (var r in phone.GetComponentsInChildren<Renderer>(true))
|
||||
{
|
||||
if (r.name == "Screen") { _screenR = r; r.sharedMaterial = bank.Mat("M_PhoneScreen"); }
|
||||
|
||||
@ -341,9 +341,8 @@ namespace GrassCutter
|
||||
/// </summary>
|
||||
void KeepUpright(bool snap = false)
|
||||
{
|
||||
var want = Planet.Up(transform.position);
|
||||
var ts = Ts;
|
||||
if (ts && !Flying && !_vehicle && ts.OnDeck(transform.position)) want = Vector3.up;
|
||||
// the soil's own up (the deck stands on the flat round the base, so it is straight up there too)
|
||||
var want = Planet.Level(transform.position);
|
||||
_stand = snap || _stand == Vector3.zero ? want : Vector3.Slerp(_stand, want, 1f - Mathf.Exp(-6f * Time.deltaTime)).normalized;
|
||||
_frame = Quaternion.FromToRotation(_frame * Vector3.up, _stand) * _frame;
|
||||
}
|
||||
@ -543,7 +542,9 @@ namespace GrassCutter
|
||||
_climbFrom = transform.position;
|
||||
_climbTo = hit.point + up * 0.05f + fwd * 0.45f;
|
||||
_climbT = 0f;
|
||||
_climbOver = true;
|
||||
// over the railing if there is one in the way; up through the opening at a ladder there isn't
|
||||
var waist = up * 0.5f;
|
||||
_climbOver = Physics.Linecast(transform.position + Vector3.Project(_climbTo - transform.position, up) + waist, _climbTo + waist, 1 << Physics.IgnoreRaycastLayer, QueryTriggerInteraction.Ignore);
|
||||
Body.enabled = false;
|
||||
Sfx.Play("splash_small", 0.5f, 1.3f);
|
||||
Sfx.Play("jump", 0.5f, 0.85f);
|
||||
|
||||
@ -58,7 +58,70 @@ namespace GrassCutter
|
||||
|
||||
void Awake() { _p = GetComponent<PlayerAgent>(); }
|
||||
|
||||
public bool Owns(ToolId t) => _p.Owns(t);
|
||||
public bool Owns(ToolId t) => GameDefs.IsTool(t) && _p.Owns(t);
|
||||
|
||||
// ───────────────────────── treat packs ─────────────────────────
|
||||
|
||||
readonly int[] _packs = new int[2];
|
||||
|
||||
/// <summary>How many are left in the pack of this treat on the belt (0: none there).</summary>
|
||||
public int PackLeft(TreatId k) => _packs[(int)k];
|
||||
|
||||
/// <summary>Room for a pack of this treat: a free slot, or the one already on the belt not yet full.</summary>
|
||||
public bool PackRoom(TreatId k) => _belt.Contains(GameDefs.PackOf(k)) ? _packs[(int)k] + Treats.PackSize <= Treats.PackMost : _belt.Count < _p.BeltSlots.Value;
|
||||
|
||||
/// <summary>A pack from a vending machine goes on the belt (onto the one there, or into a free slot).</summary>
|
||||
public bool AddPack(TreatId k, int n)
|
||||
{
|
||||
if (!PackRoom(k)) return false;
|
||||
var id = GameDefs.PackOf(k);
|
||||
if (!_belt.Contains(id)) _belt.Add(id);
|
||||
_packs[(int)k] = Mathf.Min(Treats.PackMost, _packs[(int)k] + n);
|
||||
_changed = true;
|
||||
BeltChanged?.Invoke();
|
||||
return true;
|
||||
}
|
||||
|
||||
/// <summary>The belt's contents changed without the hand changing (a pack topped up or used).</summary>
|
||||
public event Action BeltChanged;
|
||||
|
||||
/// <summary>One from the pack in hand: the can or the cigar comes up, the boost starts, the pack runs down.</summary>
|
||||
void UsePack()
|
||||
{
|
||||
var k = GameDefs.PackTreat(Current);
|
||||
if (_packs[(int)k] <= 0 || TreatHand.Busy || !TreatHand.I) return;
|
||||
_packs[(int)k]--;
|
||||
_changed = true;
|
||||
// far from any machine: the others see the boost, not a machine's show
|
||||
_p.TreatRpc((byte)k, new Vector3(0f, -100000f, 0f), Nozzle);
|
||||
TreatHand.I.Play(k);
|
||||
if (_packs[(int)k] <= 0)
|
||||
{
|
||||
int i = _belt.IndexOf(Current);
|
||||
_belt.Remove(Current);
|
||||
var next = ToolId.None;
|
||||
foreach (var t in _belt) if (GameDefs.IsTool(t)) { next = t; break; }
|
||||
if (next == ToolId.None && _belt.Count > 0) next = _belt[Mathf.Clamp(i, 0, _belt.Count - 1)];
|
||||
Current = ToolId.None;
|
||||
Select(next);
|
||||
}
|
||||
BeltChanged?.Invoke();
|
||||
}
|
||||
|
||||
/// <summary>Take a tool off the belt: it stays yours (the supply wall has it), the slot is free for something else.</summary>
|
||||
public void Unequip(ToolId t)
|
||||
{
|
||||
if (!_belt.Remove(t)) return;
|
||||
_changed = true;
|
||||
if (Current == t)
|
||||
{
|
||||
var next = ToolId.None;
|
||||
foreach (var b in _belt) if (GameDefs.IsTool(b)) { next = b; break; }
|
||||
if (next == ToolId.None && _belt.Count > 0) next = _belt[0];
|
||||
Select(next);
|
||||
}
|
||||
BeltChanged?.Invoke();
|
||||
}
|
||||
public float Bin(ToolId t) => GameDefs.IsBlade(t) ? _bins[(int)t] : 0f;
|
||||
public float CurrentCap => Ts && GameDefs.IsBlade(Current) ? Ts.ToolCap(Current) : 0f;
|
||||
|
||||
@ -100,12 +163,13 @@ namespace GrassCutter
|
||||
|
||||
public void Select(ToolId t)
|
||||
{
|
||||
if (t == Current || (t != ToolId.None && !Owns(t))) return;
|
||||
if (t == Current || (t != ToolId.None && !Owns(t) && !(GameDefs.IsPack(t) && _belt.Contains(t)))) return;
|
||||
Current = t;
|
||||
_changed = true;
|
||||
if (_p.IsOwner)
|
||||
{
|
||||
_p.ToolNet.Value = (byte)t;
|
||||
// a pack in hand shows as empty hands to the others: the can or cigar comes up when it is used
|
||||
_p.ToolNet.Value = (byte)(GameDefs.IsPack(t) ? ToolId.None : t);
|
||||
_p.Tank.Value = Bin(t);
|
||||
}
|
||||
StopCut();
|
||||
@ -138,6 +202,7 @@ namespace GrassCutter
|
||||
HandleSwitching();
|
||||
if (_changed && Time.time >= _reportAt) ReportNow();
|
||||
|
||||
if (GameDefs.IsPack(Current) && Ctl.UsePressed && !_p.Driving.Value && !_p.Grab.Holding && !Ctl.UIOpen) UsePack();
|
||||
bool blocked = _p.Driving.Value || _p.Grab.Holding || Ctl.UIOpen || !GameDefs.IsBlade(Current) || TreatHand.Busy;
|
||||
if (blocked) { BladeOn = false; StopCut(); return; }
|
||||
|
||||
@ -161,7 +226,9 @@ namespace GrassCutter
|
||||
_changed = false;
|
||||
_reportAt = Time.time + 5f;
|
||||
var belt = new int[_belt.Count];
|
||||
for (int i = 0; i < belt.Length; i++) belt[i] = (int)_belt[i];
|
||||
// a pack is kept as 1000 + 100 x its treat + how many are left in it
|
||||
for (int i = 0; i < belt.Length; i++)
|
||||
belt[i] = GameDefs.IsPack(_belt[i]) ? 1000 + 100 * (int)GameDefs.PackTreat(_belt[i]) + _packs[(int)GameDefs.PackTreat(_belt[i])] : (int)_belt[i];
|
||||
_p.ReportToolsRpc(_bins, belt, (int)Current);
|
||||
}
|
||||
|
||||
@ -176,8 +243,18 @@ namespace GrassCutter
|
||||
_ownedSeen = _p.Owned.Value;
|
||||
for (int i = 0; i < bins.Length && i < _bins.Length; i++) _bins[i] = bins[i];
|
||||
_belt.Clear();
|
||||
_packs[0] = _packs[1] = 0;
|
||||
foreach (int t in belt)
|
||||
if (_belt.Count < _p.BeltSlots.Value && Owns((ToolId)t) && !_belt.Contains((ToolId)t)) _belt.Add((ToolId)t);
|
||||
{
|
||||
if (_belt.Count >= _p.BeltSlots.Value) break;
|
||||
if (t >= 1000)
|
||||
{
|
||||
int k = Mathf.Clamp((t - 1000) / 100, 0, 1), n = Mathf.Clamp((t - 1000) % 100, 0, Treats.PackMost);
|
||||
var id = GameDefs.PackOf((TreatId)k);
|
||||
if (n > 0 && !_belt.Contains(id)) { _belt.Add(id); _packs[k] = n; }
|
||||
}
|
||||
else if (Owns((ToolId)t) && !_belt.Contains((ToolId)t)) _belt.Add((ToolId)t);
|
||||
}
|
||||
var hand = _belt.Contains((ToolId)current) ? (ToolId)current : _belt.Count > 0 ? _belt[0] : ToolId.None;
|
||||
Current = ToolId.None;
|
||||
Select(hand);
|
||||
|
||||
@ -57,6 +57,7 @@ namespace GrassCutter
|
||||
if (src)
|
||||
{
|
||||
go = Instantiate(src, r.pivot);
|
||||
DayNight.KeepOutOfLamp(go);
|
||||
go.transform.localPosition = Vector3.zero;
|
||||
go.transform.localRotation = Flip * src.transform.localRotation;
|
||||
}
|
||||
|
||||
@ -22,12 +22,28 @@ namespace GrassCutter
|
||||
// a sweep turns the whole rig around this point, by this much either way of the middle of the stroke
|
||||
public Vector3 pivot;
|
||||
public float arc, middle;
|
||||
// the model turned about its own handle, so the business end faces where it should
|
||||
public float spin;
|
||||
}
|
||||
|
||||
class Rig
|
||||
{
|
||||
public Hold hold;
|
||||
public Transform root, bladeA, bladeB;
|
||||
public Transform mesh;
|
||||
public Quaternion meshRot;
|
||||
public Vector3 handle;
|
||||
}
|
||||
|
||||
/// <summary>Every tool sits this much lower and further right than its pose says: out of the middle of the view.</summary>
|
||||
static readonly Vector3 Shift = new Vector3(0.045f, -0.05f, 0f);
|
||||
|
||||
/// <summary>Turns a tool about its handle (the longest side of its mesh), on top of its pose's own spin.</summary>
|
||||
public static void Spin(ToolId id, float degrees)
|
||||
{
|
||||
var vm = FindAnyObjectByType<ViewModel>();
|
||||
if (vm && vm._rigs.TryGetValue(id, out var r) && r.mesh)
|
||||
r.mesh.localRotation = r.meshRot * Quaternion.AngleAxis(r.hold.spin + degrees, r.handle);
|
||||
}
|
||||
|
||||
static readonly Hold[] Holds =
|
||||
@ -57,8 +73,8 @@ namespace GrassCutter
|
||||
pos = new Vector3(0.32f, -0.1f, 0.36f), euler = new Vector3(9f, -22f, 0f),
|
||||
usePos = new Vector3(0.32f, -0.11f, 0.36f), useEuler = new Vector3(11f, -22f, 0f),
|
||||
pivot = new Vector3(0.1f, -0.6f, -0.1f), arc = 28f, middle = 5f },
|
||||
// the hammer stands up beside the view, face to the left, ready to come down on what's being built
|
||||
new Hold { id = ToolId.Hammer, motion = Motion.Strike, scale = 0.42f,
|
||||
// the hammer stands up beside the view, face forward, ready to come down on what's being built
|
||||
new Hold { id = ToolId.Hammer, motion = Motion.Strike, scale = 0.42f, spin = 270f,
|
||||
pos = new Vector3(0.27f, -0.2f, 0.42f), euler = new Vector3(-68f, -10f, -8f),
|
||||
usePos = new Vector3(0.27f, -0.2f, 0.42f), useEuler = new Vector3(-68f, -10f, -8f) },
|
||||
};
|
||||
@ -102,7 +118,17 @@ namespace GrassCutter
|
||||
if (t.name == "BladeA") r.bladeA = t;
|
||||
else if (t.name == "BladeB") r.bladeB = t;
|
||||
}
|
||||
var mf = model ? model.GetComponentInChildren<MeshFilter>() : null;
|
||||
if (mf && mf.sharedMesh)
|
||||
{
|
||||
var size = mf.sharedMesh.bounds.size;
|
||||
r.mesh = mf.transform;
|
||||
r.meshRot = mf.transform.localRotation;
|
||||
r.handle = size.x >= size.y && size.x >= size.z ? Vector3.right : size.y >= size.z ? Vector3.up : Vector3.forward;
|
||||
if (h.spin != 0f) r.mesh.localRotation = r.meshRot * Quaternion.AngleAxis(h.spin, r.handle);
|
||||
}
|
||||
SetLayer(r.root, Layers.ViewModel);
|
||||
DayNight.KeepOutOfLamp(r.root.gameObject);
|
||||
r.root.gameObject.SetActive(false);
|
||||
}
|
||||
}
|
||||
@ -266,8 +292,8 @@ namespace GrassCutter
|
||||
: _strike < 0.12f ? Mathf.Lerp(-26f, 50f, Mathf.Pow((_strike - 0.06f) / 0.06f, 2f))
|
||||
: _strike < 0.2f ? 50f + Mathf.Sin((_strike - 0.12f) / 0.08f * Mathf.PI * 3f) * 4f * (1f - (_strike - 0.12f) / 0.08f)
|
||||
: Mathf.Lerp(50f, 0f, Mathf.SmoothStep(0f, 1f, (_strike - 0.2f) / 0.36f));
|
||||
rot = Quaternion.AngleAxis(a, Vector3.forward) * rot;
|
||||
pos += new Vector3(-0.05f, -0.035f, 0.06f) * (Mathf.Max(0f, a) / 50f) + new Vector3(0.015f, 0.03f, -0.02f) * (Mathf.Max(0f, -a) / 26f);
|
||||
rot = Quaternion.AngleAxis(a, Vector3.right) * rot;
|
||||
pos += new Vector3(0f, -0.04f, 0.06f) * (Mathf.Max(0f, a) / 50f) + new Vector3(0f, 0.03f, -0.03f) * (Mathf.Max(0f, -a) / 26f);
|
||||
}
|
||||
|
||||
// a new tool comes up from below with a turn of the wrist, and settles with a little overshoot
|
||||
@ -275,7 +301,7 @@ namespace GrassCutter
|
||||
float away = Mathf.Max(low, _hide);
|
||||
pos += new Vector3(0.04f * low, -0.35f * away, 0f);
|
||||
rot = Quaternion.Euler(25f * away, -10f * low, -35f * low) * rot;
|
||||
rig.root.localPosition = pos;
|
||||
rig.root.localPosition = pos + Shift;
|
||||
rig.root.localRotation = rot;
|
||||
rig.root.gameObject.SetActive(_hide < 0.99f);
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user