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,66 @@
using System.Collections.Generic;
using Unity.Netcode;
using UnityEngine;
namespace GrassCutter
{
/// <summary>
/// A solar panel feeds its network with what the sun gives it: a fixed panel less when the sun is low, a tracker its full
/// power all day, nothing at night. Keeping power for the dark takes a battery.
/// </summary>
public class SolarPanel : PowerNode
{
public readonly NetworkVariable<float> Output = new NetworkVariable<float>();
Transform _head;
Quaternion _rest;
PanelDef Def => GameDefs.Panel(Piece.piece);
public override float Radius => Def.radius;
public override float Sunlight
{
get
{
float h = Sun.Height(Planet.Up(transform.position));
float kw = Def.kw * (Def.tracker ? Mathf.Clamp01(h * 8f) : Mathf.Clamp01(h * 1.4f)) * (TeamState.Instance ? WeatherFx.SolarOf(TeamState.Instance.WeatherNow) : 1f);
if (IsServer) Write(Output, kw);
return kw;
}
}
public override string Prompt => Loc.F("{0}: {1:0.#} of {2:0.#} kW, reaches {3:0} m. {4}", Piece.Def.name, Output.Value, Def.kw, Def.radius, Network);
void Awake()
{
_head = Build(transform, GetComponent<BuildPiece>().piece);
_rest = Quaternion.Inverse(transform.rotation) * _head.rotation;
var box = gameObject.AddComponent<BoxCollider>();
box.center = Vector3.up * 1.5f;
box.size = new Vector3(1.2f, 3f, 1.2f);
}
void Update()
{
// the tracker's panel follows the sun, on every peer
if (!Def.tracker || !_head) return;
var up = Planet.Up(transform.position);
var aim = Sun.Height(up) > 0f ? Sun.Dir : up;
_head.rotation = Quaternion.RotateTowards(_head.rotation, Quaternion.FromToRotation(Vector3.up, aim) * _rest, 12f * Time.deltaTime);
}
/// <summary>The model, shared with the ghost. Returns the part that carries the cells.</summary>
public static Transform Build(Transform root, PieceId id)
{
var inst = Instantiate(AssetBank.I.Model(id == PieceId.SolarS ? "SM_SolarPost" : id == PieceId.SolarM ? "SM_SolarPair" : "SM_SolarTracker"), root);
inst.transform.localPosition = Vector3.zero;
Transform head = inst.transform;
foreach (var t in inst.GetComponentsInChildren<Transform>())
{
t.gameObject.layer = root.gameObject.layer;
if (t.name == "Head") head = t;
}
return head;
}
}
}