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:
@ -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);
|
||||
|
||||
Reference in New Issue
Block a user