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,564 @@
using System;
using UnityEngine;
namespace GrassCutter
{
/// <summary>What a player can hold: six hand tools from nail scissors to the two-handed scythe, each with its own
/// grass container, and the hammer that opens the build menu.</summary>
public enum ToolId : byte { NailScissors = 0, GardenShears = 1, Sickle = 2, Scythe = 3, LongScythe = 4, WideScythe = 5, Hammer = 6, LawnMower = 7, None = 255 }
/// <summary>Personal gear on the supply wall; shares the owned mask with the tools.</summary>
public enum GearId : byte { Jetpack = 8, Boots = 9, NightVision = 10 }
public enum CargoKind : byte { Grass = 0, Hay = 1, Brick = 2 }
public enum VehicleKind : byte { Push, Rider, Pickup, Tractor, Combine, Hauler, Mulcher, Baler, Count }
public enum TuneId : byte { Motors, Hopper, Turbo, Cruise, Cutter, Release, Lights, Count }
public enum PerkTree : byte { Containers = 0, Cutting = 1, Suit = 2, Logistics = 3, Economy = 4 }
public enum PerkId : byte
{
// CONTAINERS
BinScissors, BinShears, BinSickle, BinScythe, BinLongScythe, BinWideScythe, Compactor, AutoBaler,
// CUTTING
WiderBlades, LongHandles, DeepSwath, WhetSteel,
// SUIT
ServoBoots, SpringStep, FieldFrame,
// LOGISTICS
QuickTwine, BundleLine, ThrowArm, ExpressDepot,
// ECONOMY
EarthPrices, RegionBonus, SupplyDeals, GreenExchange,
Count
}
public enum PieceCat : byte { Services, Logistics, Production, Power, Structures, Decor, Count }
public enum PieceId : byte { Depot, Belt, Splitter, Merger, Square, Hex, Dryer, Press, SolarS, SolarM, SolarL, Garage, Binder, RobotI, RobotII, Reaper, Catcher, Pole, BatteryS, BatteryL, UnloadBay, DronePad, Intake,
Wall, WindowWall, DoorWall, Railing, Fence, Floor, FlatRoof, Roof, Stairs, Steps, Pillar, Planter, Lamppost, Bench, Crates, Flagpole, Count }
/// <summary>How a structure finds its place: anywhere, on the edge of a deck, or on top of the walls (a storey up).</summary>
public enum Fit : byte { Free, Edge, Top }
public class ToolDef
{
public ToolId id;
public string nameEn, descEn, icon, model;
public string name { get => Loc.T(nameEn); set => nameEn = value; }
public string desc { get => Loc.T(descEn); set => descEn = value; }
public float width; // metres
public float capacity; // kilos
public long price;
}
public class PerkDef
{
public PerkId id;
public PerkTree tree;
public string nameEn, descEn, icon;
public string name { get => Loc.T(nameEn); set => nameEn = value; }
public string desc { get => Loc.T(descEn); set => descEn = value; }
public int col, row;
/// <summary>Price of each level, in order.</summary>
public long[] prices = { 0 };
public bool big; // a big step: drawn bigger
public PerkId[] requires = new PerkId[0];
public int requireLevel = 1;
public System.Func<int, string> effect;
public int maxLevel => prices.Length;
public long PriceFor(int currentLevel) => prices[Mathf.Clamp(currentLevel, 0, prices.Length - 1)];
public string EffectFor(int level) => effect != null ? effect(level) : desc;
}
public class PieceDef
{
public PieceId id;
public PieceCat cat;
public string nameEn, descEn, icon, model, prefab;
public string name { get => Loc.T(nameEn); set => nameEn = value; }
public string desc { get => Loc.T(descEn); set => descEn = value; }
public double price;
public int sizeX = 1, sizeZ = 1;
/// <summary>How much bigger than its file the model is built.</summary>
public float scale = 1f;
/// <summary>Kilowatts a machine draws while it works.</summary>
public float kw;
/// <summary>Company equipment: never in the build menu.</summary>
public bool company;
}
/// <summary>What a machine turns into what, batch by batch.</summary>
public class RecipeDef
{
public float grass, hay, seconds, makes;
public CargoKind product;
}
public class VehicleDef
{
public VehicleKind kind;
public string nameEn, descEn, icon;
public string name { get => Loc.T(nameEn); set => nameEn = value; }
public string desc { get => Loc.T(descEn); set => descEn = value; }
public double price;
/// <summary>Strip it cuts, kilos it holds, bundles on the bed. A pickup cuts nothing.</summary>
public float width, hopper;
public int bed;
public float speed, accel, turn;
/// <summary>The crew are tall in the head: how far the seat sits below where the model has it, to keep them under the roof.</summary>
public float seatDrop;
public float seatAhead;
/// <summary>Feeds its hopper onto a belt as bundles from a chute on its right, wherever a belt starts beside it.</summary>
public bool bales;
}
/// <summary>One upgrade a machine can take, level by level.</summary>
public class TuneDef
{
public TuneId id;
public string nameEn;
public string name { get => Loc.T(nameEn); set => nameEn = value; }
public long[] prices;
public System.Func<int, string> effect;
}
/// <summary>What drives itself: rings of sectors it works (0 = all of them), strip, walking speed, hopper.</summary>
/// <summary>What a piece's upgrade levels change.</summary>
public enum UpgradeKind { None, Belt, Machine, Robot, Silo }
public class RobotDef
{
public PieceId piece;
public string nameEn;
public string name { get => Loc.T(nameEn); set => nameEn = value; }
public int reach;
public float width, speed, hopper;
}
public class PanelDef
{
public float kw, radius;
public bool tracker;
}
public class BatteryDef
{
public float kwh, kw, radius;
}
public static class GameDefs
{
// ───────────────────────── world ─────────────────────────
/// <summary>The soil around the base (the deck top is y = 0; the deck stands on stilts above the meadow).</summary>
public const float WaterY = -1.2f;
/// <summary>The whole of Herbaria-7: 163 842 sectors of about 600 m² each. Easier games play on a smaller ball (<see cref="Planet.Radius"/>).</summary>
public const float PlanetRadius = 2797f;
public const float TileSize = 6f;
/// <summary>The meadow is this tall, everywhere, until it is cut.</summary>
public const float GrassHeight = 0.42f;
/// <summary>Kilos of grass on a square metre of meadow.</summary>
public const float GrassDensity = 0.25f;
/// <summary>Herbaria-7: 163 830 hex sectors of about 600 m² (the base and the planet size live here).</summary>
public const int Sectors = 163830;
/// <summary>About 600 m² on the whole planet, a quarter of that on half of it, a ninth on a third.</summary>
public static float SectorArea => 4f * Mathf.PI * Planet.Radius * Planet.Radius / HexGrid.Cells;
public static double PlanetKg => Sectors * (double)SectorArea * GrassDensity;
public static double PlanetArea => Sectors * (double)SectorArea;
/// <summary>A sector mown clean pays on top of its grass.</summary>
public static double SectorBonus(int bounty) => 10d + bounty * 15d;
public const double StakePay = 100d, PointPay = 250d;
// ───────────────────────── tools ─────────────────────────
public static readonly ToolDef[] Tools =
{
new ToolDef { id = ToolId.NailScissors, name = Loc.N("Nail Scissors"), icon = "icon_tool_scissors", model = "SM_Tool_NailScissors", width = 0.12f, capacity = 0.5f, price = 0,
desc = Loc.N("Company issue. For a whole planet. Earth is counting on you.") },
new ToolDef { id = ToolId.GardenShears, name = Loc.N("Garden Shears"), icon = "icon_tool_shears", model = "SM_Tool_GardenShears", width = 0.18f, capacity = 0.75f, price = 5,
desc = Loc.N("A proper pair of shears. Your wrist says thank you.") },
new ToolDef { id = ToolId.Sickle, name = Loc.N("Sickle"), icon = "icon_tool_sickle", model = "SM_Tool_Sickle", width = 0.24f, capacity = 1f, price = 10,
desc = Loc.N("A one-handed hooked blade with a small grass sack.") },
new ToolDef { id = ToolId.Scythe, name = Loc.N("Scythe"), icon = "icon_tool_scythe", model = "SM_Tool_Scythe", width = 0.43f, capacity = 3f, price = 25,
desc = Loc.N("The real thing: long strokes and a proper basket on the back.") },
new ToolDef { id = ToolId.LongScythe, name = Loc.N("Long Scythe"), icon = "icon_tool_longscythe", model = "SM_Tool_LongScythe", width = 0.65f, capacity = 6f, price = 75,
desc = Loc.N("A longer blade, a wider strip, a bigger basket.") },
new ToolDef { id = ToolId.WideScythe, name = Loc.N("Two-Handed Scythe"), icon = "icon_tool_widescythe", model = "SM_Tool_WideScythe", width = 0.988f, capacity = 12f, price = 150,
desc = Loc.N("Almost a metre of steel. Earth will be green by Christmas.") },
new ToolDef { id = ToolId.Hammer, name = Loc.N("Build Hammer"), icon = "icon_tool_hammer", model = "SM_Tool_Hammer", price = 50,
desc = Loc.N("Opens the build menu. Q category, wheel piece, R rotate, RMB remove.") },
new ToolDef { id = ToolId.LawnMower, name = Loc.N("Lawn Mower"), icon = "icon_tool_lawnmower", model = "SM_Tool_LawnMower", width = 1.1f, capacity = 30f, price = 400,
desc = Loc.N("A wide-deck push mower. Hold the mouse and walk: it cuts the strip under it as you go.") },
};
/// <summary>How many tool ids there are, and the order the supply wall and the belt list them: blades by size, then the hammer.</summary>
public const int ToolCount = 8;
public static readonly ToolId[] ToolOrder = { ToolId.NailScissors, ToolId.GardenShears, ToolId.Sickle, ToolId.Scythe, ToolId.LongScythe, ToolId.WideScythe, ToolId.LawnMower, ToolId.Hammer };
public static ToolDef Tool(ToolId id) => Tools[(int)id];
public static bool IsBlade(ToolId t) => t <= ToolId.WideScythe || t == ToolId.LawnMower;
/// <summary>Pushed along the ground instead of swung: cuts under its deck while you walk.</summary>
public static bool IsMower(ToolId t) => t == ToolId.LawnMower;
/// <summary>Scythes and shears have a basket perk each; the mower's bag only grows with the compactor.</summary>
public static bool HasBinPerk(ToolId t) => t <= ToolId.WideScythe;
public static PerkId BinPerk(ToolId t) => (PerkId)((int)PerkId.BinScissors + (int)t);
public const int MaxBeltSlots = 6;
/// <summary>Price of the next belt slot when you already have this many.</summary>
public static long BeltSlotPrice(int have) => 15L << Mathf.Clamp(have - 1, 0, MaxBeltSlots);
public const long JetpackPrice = 300, BootsPrice = 250, NightVisionPrice = 350;
public static long GearPrice(GearId g) => g == GearId.Boots ? BootsPrice : g == GearId.NightVision ? NightVisionPrice : JetpackPrice;
public const float JetDash = 11f, JetCooldown = 2.5f;
/// <summary>Herbaria-7 pulls weakly: this is how fast the crew and loose bundles fall, and how hard you jump.
/// The gravity boots bring back Earth's pull (the player's own gravity and jump).</summary>
public const float LowGravity = 7.6f, LowJump = 5.4f;
// ───────────────────────── upgrade matrix ─────────────────────────
static PerkDef Bin(PerkId id, string name, string desc, int col, params long[] prices) => new PerkDef
{
id = id, tree = PerkTree.Containers, name = name, icon = "icon_perk_backpack", col = col, row = 0, prices = prices,
desc = desc,
effect = l => Loc.F("Container x{0:0}", BinMul(l)),
};
public static readonly PerkDef[] Perks =
{
// ── CONTAINERS ──
Bin(PerkId.BinScissors, Loc.N("Nail Scissors Basket"), Loc.N("A bigger basket for the Nail Scissors."), 0, 10, 25, 60),
Bin(PerkId.BinShears, Loc.N("Garden Shears Basket"), Loc.N("A bigger basket for the Garden Shears."), 1, 15, 40, 100),
Bin(PerkId.BinSickle, Loc.N("Sickle Basket"), Loc.N("A bigger basket for the Sickle."), 2, 20, 50, 120),
Bin(PerkId.BinScythe, Loc.N("Scythe Basket"), Loc.N("A bigger basket for the Scythe."), 3, 30, 80, 190),
Bin(PerkId.BinLongScythe, Loc.N("Long Scythe Basket"), Loc.N("A bigger basket for the Long Scythe."), 4, 45, 110, 260),
Bin(PerkId.BinWideScythe, Loc.N("Two-Handed Scythe Basket"), Loc.N("A bigger basket for the Two-Handed Scythe."), 5, 55, 140, 320),
new PerkDef { id = PerkId.Compactor, tree = PerkTree.Containers, name = Loc.N("Grass Compactor"), icon = "icon_perk_pressure", col = 2, row = 1, prices = new long[] { 150, 450, 1200 },
desc = Loc.N("Tread it down harder. Every tool holds more."), effect = l => Loc.F("All tools +{0}%", l * 15) },
new PerkDef { id = PerkId.AutoBaler, tree = PerkTree.Containers, name = Loc.N("Auto-Binder"), icon = "icon_piece_filler", col = 3, row = 2, prices = new long[] { 2000 }, big = true, requires = new[] { PerkId.Compactor }, requireLevel = 2,
desc = Loc.N("A full basket ties itself into a bundle and drops it at your feet.") },
// ── CUTTING ──
new PerkDef { id = PerkId.WiderBlades, tree = PerkTree.Cutting, name = Loc.N("Wider Blades"), icon = "icon_perk_suction", col = 0, row = 0, prices = new long[] { 40, 140, 400 },
desc = Loc.N("A wider strip with every tool."), effect = l => Loc.F("Strip width +{0:0}%", WidthBonus(l) * 100f) },
new PerkDef { id = PerkId.LongHandles, tree = PerkTree.Cutting, name = Loc.N("Long Handles"), icon = "icon_perk_nozzle", col = 1, row = 0, prices = new long[] { 70, 220 },
desc = Loc.N("Reach further without taking a step."), effect = l => Loc.F("Reach +{0:0.##} m", l * 0.75f) },
new PerkDef { id = PerkId.DeepSwath, tree = PerkTree.Cutting, name = Loc.N("Deep Swath"), icon = "icon_perk_flow", col = 2, row = 0, prices = new long[] { 90, 280 },
desc = Loc.N("The blade bites deeper into the grass."), effect = l => Loc.F("Strip width +{0:0}%", l * 6) },
new PerkDef { id = PerkId.WhetSteel, tree = PerkTree.Cutting, name = Loc.N("Whetstone Steel"), icon = "icon_perk_blast", col = 1, row = 1, prices = new long[] { 1500 }, big = true, requires = new[] { PerkId.WiderBlades, PerkId.LongHandles, PerkId.DeepSwath }, requireLevel = 2,
desc = Loc.N("A razor edge: +10% width and depth, +0.5 m reach.") },
// ── SUIT ──
new PerkDef { id = PerkId.ServoBoots, tree = PerkTree.Suit, name = Loc.N("Servo Boots"), icon = "icon_perk_sneakers", col = 0, row = 0, prices = new long[] { 50, 160, 450 },
desc = Loc.N("Move faster."), effect = l => Loc.F("Speed +{0}%", l * 7) },
new PerkDef { id = PerkId.SpringStep, tree = PerkTree.Suit, name = Loc.N("Spring Step"), icon = "icon_perk_boots", col = 2, row = 0, prices = new long[] { 80, 250 },
desc = Loc.N("Jump higher."), effect = l => Loc.F("Jump +{0}%", l * 20) },
new PerkDef { id = PerkId.FieldFrame, tree = PerkTree.Suit, name = Loc.N("Field Frame"), icon = "icon_perk_fins", col = 1, row = 1, prices = new long[] { 1200 }, big = true, requires = new[] { PerkId.ServoBoots, PerkId.SpringStep }, requireLevel = 2,
desc = Loc.N("A light exoskeleton: +8% speed, +15% jump.") },
// ── LOGISTICS ──
new PerkDef { id = PerkId.QuickTwine, tree = PerkTree.Logistics, name = Loc.N("Quick Twine"), icon = "icon_perk_release", col = 0, row = 0, prices = new long[] { 30, 100, 300 },
desc = Loc.N("Tie bundles faster."), effect = l => Loc.F("Bundle time -{0}%", l switch { 1 => 25, 2 => 44, _ => 58 }) },
new PerkDef { id = PerkId.BundleLine, tree = PerkTree.Logistics, name = Loc.N("Bundle Line"), icon = "icon_perk_remote", col = 1, row = 0, prices = new long[] { 60, 200 },
desc = Loc.N("Grab bundles from further away."), effect = l => Loc.F("Pick-up reach +{0:0.#} m", l * 1.5f) },
new PerkDef { id = PerkId.ThrowArm, tree = PerkTree.Logistics, name = Loc.N("Throwing Arm"), icon = "icon_perk_beltspeed", col = 2, row = 0, prices = new long[] { 80, 240 },
desc = Loc.N("Throw bundles further."), effect = l => Loc.F("Throw +{0}%", l * 25) },
new PerkDef { id = PerkId.ExpressDepot, tree = PerkTree.Logistics, name = Loc.N("Express Depot"), icon = "icon_perk_dockpump", col = 1, row = 1, prices = new long[] { 900 }, big = true, requires = new[] { PerkId.QuickTwine }, requireLevel = 2,
desc = Loc.N("Bundles tie twice as fast and machines unload at the depot twice as fast.") },
// ── ECONOMY ──
new PerkDef { id = PerkId.EarthPrices, tree = PerkTree.Economy, name = Loc.N("Earth Prices"), icon = "icon_perk_contracts", col = 0, row = 0, prices = new long[] { 120, 400, 1100 },
desc = Loc.N("Earth is desperate for grass. Make it pay."), effect = l => Loc.F("Payout +{0}%", l * 6) },
new PerkDef { id = PerkId.RegionBonus, tree = PerkTree.Economy, name = Loc.N("Sector Bounty"), icon = "icon_perk_purity", col = 2, row = 0, prices = new long[] { 200, 600 },
desc = Loc.N("More cash for every sector mown clean."), effect = l => Loc.F("+{0} per sector", UIK.Money(l * 15d)) },
new PerkDef { id = PerkId.SupplyDeals, tree = PerkTree.Economy, name = Loc.N("Supply Deals"), icon = "icon_perk_overclock", col = 0, row = 1, prices = new long[] { 250, 700 },
desc = Loc.N("Tools at the supply wall get cheaper."), effect = l => Loc.F("Tools -{0}%", l * 5) },
new PerkDef { id = PerkId.GreenExchange, tree = PerkTree.Economy, name = Loc.N("Green Exchange"), icon = "icon_star", col = 1, row = 2, prices = new long[] { 2500 }, big = true, requires = new[] { PerkId.EarthPrices }, requireLevel = 2,
desc = Loc.N("A seat on the Earth grass exchange: +10% on every payout.") },
};
public static PerkDef Perk(PerkId id) => Perks[(int)id];
// ───────────────────────── build pieces ─────────────────────────
public static readonly PieceDef[] Pieces =
{
new PieceDef { id = PieceId.Depot, cat = PieceCat.Services, company = true, name = Loc.N("Grass Depot"), icon = "icon_piece_hopper", model = "SM_Hopper", prefab = "Piece_Depot", sizeX = 2, sizeZ = 2,
desc = Loc.N("Everything that goes in here is paid for and shipped to Earth.") },
new PieceDef { id = PieceId.Belt, cat = PieceCat.Logistics, name = Loc.N("Belt"), icon = "icon_piece_belt", model = "SM_Belt", prefab = "Piece_Belt", price = 0.5,
desc = Loc.N("A straight run: click where it starts, click where it ends.") },
new PieceDef { id = PieceId.Splitter, cat = PieceCat.Logistics, name = Loc.N("Splitter"), icon = "icon_piece_splitter", model = "SM_BeltSplitter", prefab = "Piece_Splitter", price = 5,
desc = Loc.N("Deals bundles to the belts joined to it, left, right and straight on. E makes it a sorter: one kind goes left.") },
new PieceDef { id = PieceId.Merger, cat = PieceCat.Logistics, name = Loc.N("Merger"), icon = "icon_piece_merger", model = "SM_BeltMerger", prefab = "Piece_Merger", price = 5,
desc = Loc.N("Brings up to three belts into one, in turn. E gives one of them the right of way.") },
new PieceDef { id = PieceId.Square, cat = PieceCat.Structures, name = Loc.N("Square Foundation"), icon = "icon_piece_foundation", model = "SM_Foundation_Square", prefab = "Piece_Square", price = 10, sizeX = 3, sizeZ = 3,
desc = Loc.N("A level timber deck on mown ground. What stands on it goes along when you move it.") },
new PieceDef { id = PieceId.Hex, cat = PieceCat.Structures, name = Loc.N("Hex Foundation"), icon = "icon_piece_hexfoundation", model = "SM_Foundation_Hex", prefab = "Piece_Hex", price = 10, sizeX = 3, sizeZ = 3,
desc = Loc.N("A level timber deck on mown ground, turns in steps of 30 degrees.") },
new PieceDef { id = PieceId.Dryer, cat = PieceCat.Production, name = Loc.N("Windmill"), icon = "icon_piece_vaporizer", model = "SM_Windmill", prefab = "Piece_Dryer", price = 500, sizeX = 2, sizeZ = 2, kw = 10f,
desc = Loc.N("Five kilos of grass become five of hay in 12 seconds. Hay pays three times as much.") },
new PieceDef { id = PieceId.Press, cat = PieceCat.Production, name = Loc.N("Brick Press"), icon = "icon_piece_cryo", model = "SM_CryoPress", prefab = "Piece_Press", price = 1000, sizeX = 2, sizeZ = 2, kw = 18f,
desc = Loc.N("A kilo of grass and a kilo of hay become two kilos of brick in 6 seconds. Brick pays seven times as much.") },
new PieceDef { id = PieceId.SolarS, cat = PieceCat.Power, name = Loc.N("Solar Post"), icon = "icon_piece_solars", prefab = "Piece_SolarS", price = 75,
desc = Loc.N("3 kW within 16 m, less when the sun is low, nothing at night.") },
new PieceDef { id = PieceId.SolarM, cat = PieceCat.Power, name = Loc.N("Solar Pair"), icon = "icon_piece_solarm", prefab = "Piece_SolarM", price = 150, sizeX = 2, sizeZ = 2,
desc = Loc.N("7.5 kW within 24 m, less when the sun is low, nothing at night.") },
new PieceDef { id = PieceId.SolarL, cat = PieceCat.Power, name = Loc.N("Solar Tracker"), icon = "icon_piece_solarl", prefab = "Piece_SolarL", price = 300, sizeX = 3, sizeZ = 3,
desc = Loc.N("16 kW within 34 m. Follows the sun, so it gives its full power all day.") },
new PieceDef { id = PieceId.Garage, cat = PieceCat.Services, name = Loc.N("Garage"), icon = "icon_perk_fleet", model = "SM_Bld_Garage_01", prefab = "Piece_Garage", price = 200, sizeX = 9, sizeZ = 4, scale = 0.6f,
desc = Loc.N("Sells and calls machines. What they unload on the pad goes into a silo, two ports at the back send it out as bundles.") },
new PieceDef { id = PieceId.Binder, cat = PieceCat.Logistics, name = Loc.N("Binder"), icon = "icon_piece_binder", model = "SM_Binder", prefab = "Piece_Binder", price = 100, sizeX = 2, sizeZ = 2,
desc = Loc.N("E hands it what's in your tool. It ties the grass into bundles and puts them on the belt at its front.") },
new PieceDef { id = PieceId.RobotI, cat = PieceCat.Services, name = Loc.N("Robot Mk I"), icon = "icon_piece_robot", model = "SM_RobotDock", prefab = "Piece_RobotI", price = 250, sizeX = 3, sizeZ = 3,
desc = Loc.N("Mows the 19 sectors around its dock. The dock ties what it brings into bundles for the belt.") },
new PieceDef { id = PieceId.RobotII, cat = PieceCat.Services, name = Loc.N("Robot Mk II"), icon = "icon_piece_robot2", model = "SM_RobotDock", prefab = "Piece_RobotII", price = 500, sizeX = 3, sizeZ = 3,
desc = Loc.N("37 sectors, a wider cut and a bigger hopper.") },
new PieceDef { id = PieceId.Reaper, cat = PieceCat.Services, name = Loc.N("Reaper"), icon = "icon_piece_reaper", model = "SM_Reaper", prefab = "Piece_Reaper", price = 20000, sizeX = 3, sizeZ = 4,
desc = Loc.N("Goes from sector to sector on its own and shoots every bundle into a Bundle Catcher, from anywhere on the planet.") },
new PieceDef { id = PieceId.Catcher, cat = PieceCat.Services, name = Loc.N("Bundle Catcher"), icon = "icon_piece_catcher", model = "SM_BundleCatcher", prefab = "Piece_Catcher", price = 1500, sizeX = 3, sizeZ = 3,
desc = Loc.N("Holds 100 kg of what Reapers shoot and puts it on the belt.") },
new PieceDef { id = PieceId.Pole, cat = PieceCat.Power, name = Loc.N("Power Pole"), icon = "icon_piece_pole", model = "SM_Prop_Power_Pole_01", prefab = "Piece_Pole", price = 25, scale = 0.62f,
desc = Loc.N("Carries the network 30 m further. Poles reach each other and everything around them.") },
new PieceDef { id = PieceId.BatteryS, cat = PieceCat.Power, name = Loc.N("Battery Rack"), icon = "icon_piece_battery", model = "SM_BatteryRack", prefab = "Piece_BatteryS", price = 250, sizeX = 2, sizeZ = 2,
desc = Loc.N("Stores 5 kWh of spare sun and gives it back at up to 10 kW when the panels fall short, within 12 m.") },
new PieceDef { id = PieceId.BatteryL, cat = PieceCat.Power, name = Loc.N("Battery Bank"), icon = "icon_piece_batteryl", model = "SM_BatteryBank", prefab = "Piece_BatteryL", price = 1000, sizeX = 3, sizeZ = 2,
desc = Loc.N("Stores 25 kWh and gives back up to 40 kW, within 16 m. A windmill and a press run all night on one.") },
new PieceDef { id = PieceId.UnloadBay, cat = PieceCat.Logistics, name = Loc.N("Unload Bay"), icon = "icon_piece_unloadbay", model = "SM_UnloadBay", prefab = "Piece_UnloadBay", price = 150, sizeX = 4, sizeZ = 7,
desc = Loc.N("Drive a mower onto the grate and it empties into the bin. Two hatches at the back put it on belts as bundles.") },
new PieceDef { id = PieceId.DronePad, cat = PieceCat.Logistics, name = Loc.N("Drone Pad"), icon = "icon_piece_dronepad", model = "SM_DronePad", prefab = "Piece_DronePad", price = 600, sizeX = 3, sizeZ = 3, scale = 3.2f,
desc = Loc.N("Its drones fly out to bundles of grass lying loose within 40 m and bring them in. The front hatch puts them on a belt. Two drones, one more per upgrade.") },
new PieceDef { id = PieceId.Intake, cat = PieceCat.Services, company = true, name = Loc.N("Base Intake"), icon = "icon_piece_hopper", model = "SM_BaseIntake", prefab = "Piece_Intake", sizeX = 3, sizeZ = 2,
desc = Loc.N("A low hopper against the side of the base: drop grass in or run a belt to it, and it's paid and on its way to Earth.") },
// structures: a 3 m grid, walls on the edges of a deck, floors and roofs on top of the walls
new PieceDef { id = PieceId.Wall, cat = PieceCat.Structures, name = Loc.N("Wall"), icon = "icon_piece_wall", model = "SM_Wall", prefab = "Piece_Wall", price = 4, sizeX = 3, sizeZ = 1,
desc = Loc.N("A 3 m timber wall. It goes on the edge of a foundation or a floor; R turns it round.") },
new PieceDef { id = PieceId.WindowWall, cat = PieceCat.Structures, name = Loc.N("Window Wall"), icon = "icon_piece_windowwall", model = "SM_WallWindow", prefab = "Piece_WindowWall", price = 6, sizeX = 3, sizeZ = 1,
desc = Loc.N("A wall with a glazed window and a flower box under it.") },
new PieceDef { id = PieceId.DoorWall, cat = PieceCat.Structures, name = Loc.N("Door Wall"), icon = "icon_piece_doorwall", model = "SM_WallDoor", prefab = "Piece_DoorWall", price = 6, sizeX = 3, sizeZ = 1,
desc = Loc.N("A wall with a doorway you can walk through, and a lantern over it.") },
new PieceDef { id = PieceId.Railing, cat = PieceCat.Structures, name = Loc.N("Railing"), icon = "icon_piece_railing", model = "SM_Railing", prefab = "Piece_Railing", price = 2, sizeX = 3, sizeZ = 1,
desc = Loc.N("Waist-high rails for the edge of a raised deck or a floor upstairs.") },
new PieceDef { id = PieceId.Fence, cat = PieceCat.Decor, name = Loc.N("Picket Fence"), icon = "icon_piece_fence", model = "SM_Fence", prefab = "Piece_Fence", price = 1, sizeX = 3, sizeZ = 1,
desc = Loc.N("Three metres of cream pickets, on the ground or on the edge of a deck.") },
new PieceDef { id = PieceId.Floor, cat = PieceCat.Structures, name = Loc.N("Floor"), icon = "icon_piece_floor", model = "SM_Floor", prefab = "Piece_Floor", price = 6, sizeX = 3, sizeZ = 3,
desc = Loc.N("A storey up: it rests on the walls below. Walls and machines stand on it like on a foundation.") },
new PieceDef { id = PieceId.FlatRoof, cat = PieceCat.Structures, name = Loc.N("Flat Roof"), icon = "icon_piece_flatroof", model = "SM_FlatRoof", prefab = "Piece_FlatRoof", price = 5, sizeX = 3, sizeZ = 3,
desc = Loc.N("A tin roof on top of the walls. You can stand on it, and build on it too.") },
new PieceDef { id = PieceId.Roof, cat = PieceCat.Structures, name = Loc.N("Pitched Roof"), icon = "icon_piece_roof", model = "SM_Roof", prefab = "Piece_Roof", price = 5, sizeX = 3, sizeZ = 3,
desc = Loc.N("Half of a gable roof on top of the walls, the eave on the wall you aim at. Two back to back make a whole roof.") },
new PieceDef { id = PieceId.Stairs, cat = PieceCat.Structures, name = Loc.N("Stairs"), icon = "icon_piece_stairs", model = "SM_Stairs", prefab = "Piece_Stairs", price = 8, sizeX = 1, sizeZ = 3,
desc = Loc.N("A flight up one storey, 3 m. It climbs the way the arrow points.") },
new PieceDef { id = PieceId.Steps, cat = PieceCat.Structures, name = Loc.N("Steps"), icon = "icon_piece_steps", model = "SM_Steps", prefab = "Piece_Steps", price = 4, sizeX = 2, sizeZ = 2,
desc = Loc.N("Six wide steps up to a raised foundation, 1.5 m high.") },
new PieceDef { id = PieceId.Pillar, cat = PieceCat.Structures, name = Loc.N("Pillar"), icon = "icon_piece_pillar", model = "SM_Pillar", prefab = "Piece_Pillar", price = 2, sizeX = 1, sizeZ = 1,
desc = Loc.N("A 3 m timber post on a stone base: it holds up a floor where there's no wall.") },
new PieceDef { id = PieceId.Planter, cat = PieceCat.Decor, name = Loc.N("Flower Box"), icon = "icon_piece_planter", model = "SM_Planter", prefab = "Piece_Planter", price = 3, sizeX = 2, sizeZ = 1,
desc = Loc.N("Flowers in a timber box. They don't pay, they just look nice.") },
new PieceDef { id = PieceId.Lamppost, cat = PieceCat.Decor, name = Loc.N("Lamp Post"), icon = "icon_piece_lamppost", model = "SM_Lamppost", prefab = "Piece_Lamppost", price = 4, sizeX = 1, sizeZ = 1,
desc = Loc.N("A farm lamp that comes on at dusk.") },
new PieceDef { id = PieceId.Bench, cat = PieceCat.Decor, name = Loc.N("Bench"), icon = "icon_piece_bench", model = "SM_Bench", prefab = "Piece_Bench", price = 3, sizeX = 2, sizeZ = 1,
desc = Loc.N("Somewhere to sit and watch the robots work.") },
new PieceDef { id = PieceId.Crates, cat = PieceCat.Decor, name = Loc.N("Crates"), icon = "icon_piece_crates", model = "SM_Crate", prefab = "Piece_Crates", price = 2, sizeX = 1, sizeZ = 1,
desc = Loc.N("Company crates, stacked two high.") },
new PieceDef { id = PieceId.Flagpole, cat = PieceCat.Decor, name = Loc.N("Flagpole"), icon = "icon_piece_flagpole", model = "SM_Flagpole", prefab = "Piece_Flagpole", price = 5, sizeX = 1, sizeZ = 1,
desc = Loc.N("The crew's own flag, four metres up.") },
};
public static PieceDef Piece(PieceId id) => Pieces[(int)id];
// ───────────────────────── piece upgrades ─────────────────────────
public const int MaxTier = 3;
public static string TierName(int t) => Loc.F("Mk {0}", t == 0 ? "I" : t == 1 ? "II" : t == 2 ? "III" : "IV");
public static UpgradeKind UpgradeOf(PieceId id)
{
switch (id)
{
case PieceId.Belt: case PieceId.Splitter: case PieceId.Merger: return UpgradeKind.Belt;
case PieceId.Dryer: case PieceId.Press: case PieceId.Binder: return UpgradeKind.Machine;
case PieceId.RobotI: case PieceId.RobotII: case PieceId.Reaper: return UpgradeKind.Robot;
case PieceId.Garage: case PieceId.UnloadBay: case PieceId.Catcher: case PieceId.DronePad: return UpgradeKind.Silo;
default: return UpgradeKind.None;
}
}
static readonly float[] BeltTiers = { 1f, 1.5f, 2f, 3f }, MachineTiers = { 1f, 1.5f, 2f, 2.5f }, RobotTiers = { 1f, 1.3f, 1.6f, 1.9f }, SiloTiers = { 1f, 2f, 3f, 4f };
public static float TierMul(UpgradeKind k, int tier)
{
tier = Mathf.Clamp(tier, 0, MaxTier);
switch (k)
{
case UpgradeKind.Belt: return BeltTiers[tier];
case UpgradeKind.Machine: return MachineTiers[tier];
case UpgradeKind.Robot: return RobotTiers[tier];
case UpgradeKind.Silo: return SiloTiers[tier];
default: return 1f;
}
}
/// <summary>A machine at a higher tier also draws more power.</summary>
public static float TierPower(int tier) => 1f + 0.25f * Mathf.Clamp(tier, 0, MaxTier);
public static string TierEffect(UpgradeKind k, int tier)
{
float m = TierMul(k, tier);
switch (k)
{
case UpgradeKind.Belt: return Loc.F("runs at x{0:0.#} speed", m);
case UpgradeKind.Machine: return Loc.F("works x{0:0.#} as fast, draws x{1:0.##} power", m, TierPower(tier));
case UpgradeKind.Robot: return Loc.F("x{0:0.#} speed and hopper", m);
case UpgradeKind.Silo: return Loc.F("sends out x{0:0} the bundles", m);
default: return "";
}
}
public static double UpgradePrice(BuildPiece p, int tier)
{
double basis = p.Run ? Math.Max(20d, p.Run.Metres * 4d) : Math.Max(20d, p.Def.price);
return Math.Round(basis * (tier == 0 ? 0.5 : tier == 1 ? 1.2 : 2.5));
}
public static bool IsFoundation(PieceId id) => id == PieceId.Square || id == PieceId.Hex;
/// <summary>Something to stand and build on: a foundation on the ground, or a floor or flat roof a storey up.</summary>
public static bool IsDeck(PieceId id) => IsFoundation(id) || id == PieceId.Floor || id == PieceId.FlatRoof;
/// <summary>A deck with four 3 m edges, where walls go.</summary>
public static bool IsSquareDeck(PieceId id) => id == PieceId.Square || id == PieceId.Floor || id == PieceId.FlatRoof;
/// <summary>A storey: walls are this tall, and a floor on them is this far above the deck they stand on.</summary>
public const float Storey = 3f;
public static Fit FitOf(PieceId id)
{
switch (id)
{
case PieceId.Wall: case PieceId.WindowWall: case PieceId.DoorWall: case PieceId.Railing: case PieceId.Fence: return Fit.Edge;
case PieceId.Floor: case PieceId.FlatRoof: case PieceId.Roof: return Fit.Top;
default: return Fit.Free;
}
}
/// <summary>A wall-high piece: a floor or a roof can rest on it.</summary>
public static bool Holds(PieceId id) => id == PieceId.Wall || id == PieceId.WindowWall || id == PieceId.DoorWall || id == PieceId.Pillar;
public static bool IsPanel(PieceId id) => id >= PieceId.SolarS && id <= PieceId.SolarL;
static readonly RecipeDef Drying = new RecipeDef { grass = 5f, seconds = 12f, makes = 5f, product = CargoKind.Hay };
static readonly RecipeDef Pressing = new RecipeDef { grass = 1f, hay = 1f, seconds = 6f, makes = 2f, product = CargoKind.Brick };
public static RecipeDef Recipe(PieceId id) => id == PieceId.Press ? Pressing : Drying;
static readonly PanelDef Post = new PanelDef { kw = 3f, radius = 16f };
static readonly PanelDef Pair = new PanelDef { kw = 7.5f, radius = 24f };
static readonly PanelDef Tracker = new PanelDef { kw = 16f, radius = 34f, tracker = true };
public static PanelDef Panel(PieceId id) => id == PieceId.SolarL ? Tracker : id == PieceId.SolarM ? Pair : Post;
static readonly BatteryDef Rack = new BatteryDef { kwh = 5f, kw = 10f, radius = 12f };
static readonly BatteryDef Bank = new BatteryDef { kwh = 25f, kw = 40f, radius = 16f };
public static BatteryDef Battery(PieceId id) => id == PieceId.BatteryL ? Bank : Rack;
public static bool IsBattery(PieceId id) => id == PieceId.BatteryS || id == PieceId.BatteryL;
public const float PoleReach = 30f, PoleHeight = 3.05f, PoleArm = 0.62f;
/// <summary>How far a power piece reaches, 0 for anything else.</summary>
public static float Reach(PieceId id) => IsPanel(id) ? Panel(id).radius : IsBattery(id) ? Battery(id).radius : id == PieceId.Pole ? PoleReach : 0f;
/// <summary>Seconds from noon to noon. The original's figure isn't known.</summary>
public const float DayLength = 1800f;
// ───────────────────────── economy (shared by server & client prediction) ─────────────────────────
public static float BinMul(int level) => 1 << Mathf.Clamp(level, 0, 3);
public static float CompactorMul(int level) => 1f + level * 0.15f;
public static float ToolCap(ToolId t, int binLevel, int compactor) => Tool(t).capacity * BinMul(binLevel) * CompactorMul(compactor);
public static float WidthBonus(int level) => level * 0.08f;
public const float ToolReach = 2.6f;
public const float BundleKg = 1f;
public static float BundleSeconds(int quick, int express) =>
0.6f * (quick switch { 0 => 1f, 1 => 0.75f, 2 => 0.56f, _ => 0.42f }) * (express > 0 ? 0.5f : 1f);
public static float MoveMul(int stride, int frame) => (1f + stride * 0.07f) * (frame > 0 ? 1.08f : 1f);
public static float JumpMul(int leap, int frame) => (1f + leap * 0.2f) * (frame > 0 ? 1.15f : 1f);
public static float ThrowMul(int level) => 1f + level * 0.25f;
public static float PayoutMul(int prices, int exchange) => (1f + prices * 0.06f) * (exchange > 0 ? 1.1f : 1f);
public static float ToolPriceMul(int deals) => 1f - deals * 0.05f;
// cargo
public static string CargoName(CargoKind k) => k switch { CargoKind.Hay => Loc.T("Hay"), CargoKind.Brick => Loc.T("Pressed Brick"), _ => Loc.T("Grass Bundle") };
/// <summary>What Earth pays per kilo for each form (before market bonuses).</summary>
public static float PerKg(CargoKind k) => k switch { CargoKind.Hay => 3f, CargoKind.Brick => 7f, _ => 1f };
// belts
public const float BeltSpeed = 2.2f;
public const float BeltShortest = 0.8f, BeltLongest = 30f, BeltLowest = 0.4f, BeltHighest = 6f, BeltSteepest = 40f;
public static double BeltPrice(float metres) => System.Math.Round(metres * Piece(PieceId.Belt).price, 2);
// vehicles
public const double TravelPrice = 50d;
public static readonly RobotDef[] Robots =
{
new RobotDef { piece = PieceId.RobotI, name = Loc.N("Robot Mk I"), reach = 2, width = 0.9f, speed = 1.6f, hopper = 20f },
new RobotDef { piece = PieceId.RobotII, name = Loc.N("Robot Mk II"), reach = 3, width = 1.2f, speed = 2.2f, hopper = 50f },
new RobotDef { piece = PieceId.Reaper, name = Loc.N("Reaper"), width = 1.8f, speed = 3f, hopper = 40f },
};
public static RobotDef Robot(PieceId id)
{
foreach (var r in Robots) if (r.piece == id) return r;
return Robots[0];
}
public static readonly VehicleDef[] Vehicles =
{
new VehicleDef { kind = VehicleKind.Push, name = Loc.N("Push Mower"), icon = "icon_vehicle_push", price = 300, width = 1.35f, hopper = 100f, speed = 5f, accel = 7f, turn = 3f,
desc = Loc.N("The first step up from a scythe: a wide strip at walking pace.") },
new VehicleDef { kind = VehicleKind.Rider, name = Loc.N("Garden Rider"), icon = "icon_vehicle_ski", price = 1000, width = 2f, hopper = 500f, speed = 9.7f, accel = 11f, turn = 2.2f,
desc = Loc.N("Sit down, drive, mow. Unloads at a garage pad.") },
new VehicleDef { kind = VehicleKind.Pickup, name = Loc.N("Pickup"), icon = "icon_vehicle_hover", price = 2000, speed = 14f, accel = 10f, turn = 1.8f, bed = 4, seatDrop = 0.56f, seatAhead = 0.12f,
desc = Loc.N("Doesn't mow. Fast, and carries four bundles: E loads the one in your arms, T tips them out.") },
new VehicleDef { kind = VehicleKind.Tractor, name = Loc.N("Mowing Tractor"), icon = "icon_vehicle_tug", price = 2500, width = 2.8f, hopper = 1200f, speed = 9f, accel = 8f, turn = 1.5f, seatDrop = 0.42f,
desc = Loc.N("A proper machine for proper fields.") },
new VehicleDef { kind = VehicleKind.Combine, name = Loc.N("Combine"), icon = "icon_vehicle_combine", price = 6000, width = 3.7f, hopper = 3000f, speed = 8f, accel = 5f, turn = 1.3f, seatDrop = 0.45f,
desc = Loc.N("Slow to turn, and nothing else cuts as wide or carries as much.") },
new VehicleDef { kind = VehicleKind.Hauler, name = Loc.N("Haul Tractor"), icon = "icon_vehicle_hauler", price = 4000, width = 1.6f, hopper = 4000f, speed = 12f, accel = 8f, turn = 1.4f, seatDrop = 0.18f,
desc = Loc.N("A narrow cutter and a huge tank on a trailer: mow far out, come back once.") },
new VehicleDef { kind = VehicleKind.Mulcher, name = Loc.N("Wide Mulcher"), icon = "icon_vehicle_mulcher", price = 8000, width = 5.5f, hopper = 900f, speed = 7f, accel = 5f, turn = 1.1f, seatDrop = 0.18f,
desc = Loc.N("Wings out to five and a half metres. Fills fast: put an Unload Bay near the field.") },
new VehicleDef { kind = VehicleKind.Baler, name = Loc.N("Baler Tractor"), icon = "icon_vehicle_baler", price = 3500, width = 2.2f, hopper = 600f, speed = 9f, accel = 8f, turn = 1.5f, bales = true,
desc = Loc.N("Bales as it goes: pull up beside the start of any belt and its chute feeds the belt, five bundles a second.") },
};
public static VehicleDef Vehicle(VehicleKind k) => Vehicles[(int)k];
public static readonly TuneDef[] Tunes =
{
new TuneDef { id = TuneId.Motors, name = Loc.N("Tuned Motors"), prices = new long[] { 250, 600, 1500 }, effect = l => Loc.F("+{0}% speed and pull", l * 10) },
new TuneDef { id = TuneId.Hopper, name = Loc.N("Big Hopper"), prices = new long[] { 200, 500, 1200 }, effect = l => Loc.F("+{0}% hopper", l * 30) },
new TuneDef { id = TuneId.Turbo, name = Loc.N("Turbo Kit"), prices = new long[] { 400, 1200 }, effect = l => Loc.F("SHIFT boost {0:0}%", BoostMul(l) * 100f) },
new TuneDef { id = TuneId.Cruise, name = Loc.N("Cruise Control"), prices = new long[] { 500 }, effect = l => Loc.T("C holds your speed") },
new TuneDef { id = TuneId.Cutter, name = Loc.N("Cutter Control"), prices = new long[] { 400, 900, 2000 }, effect = l => Loc.F("Strip +{0}% at {1:0}% speed", l * 25, CutterSpeed(l) * 100f) },
new TuneDef { id = TuneId.Release, name = Loc.N("Quick Release"), prices = new long[] { 150, 400 }, effect = l => Loc.F("+{0}% unloading", l * 50) },
new TuneDef { id = TuneId.Lights, name = Loc.N("Floodlights"), prices = new long[] { 100, 300 }, effect = l => Loc.F("+{0}% light at night", l * 60) },
};
public static TuneDef Tune(TuneId t) => Tunes[(int)t];
/// <summary>Upgrades cost more on dearer machines, from half to three times the listed price.</summary>
public static double TunePrice(VehicleKind k, TuneId t, int level) => System.Math.Round(Tune(t).prices[level] * System.Math.Min(3d, System.Math.Max(0.5d, Vehicle(k).price / 1000d)), 2);
public static bool TuneFits(VehicleKind k, TuneId t) => Vehicle(k).bed == 0 || (t != TuneId.Hopper && t != TuneId.Cutter && t != TuneId.Release);
public static float BoostMul(int level) => level >= 2 ? 1.65f : level == 1 ? 1.5f : 1.25f;
public static float CutterSpeed(int level) => level >= 3 ? 0.6f : level == 2 ? 0.72f : level == 1 ? 0.85f : 1f;
public static float VehicleTankMul(int level) => 1f + level * 0.3f;
public static float VehicleSpeedMul(int level) => 1f + level * 0.1f;
public static float DockRate(int level) => 120f * (1f + level * 0.5f);
public static string ToRoman(int n) => n switch { 1 => "I", 2 => "II", 3 => "III", 4 => "IV", 5 => "V", _ => n.ToString() };
public static string Kilos(double kg)
{
if (kg >= 1_000_000) return Loc.F("{0} t", Loc.Num(kg / 1000d, "N0"));
if (kg >= 10_000) return Loc.F("{0} t", Loc.Num(kg / 1000d, "0.#"));
return Loc.F("{0} kg", Loc.Num(kg, kg < 100d ? "0.##" : "N0"));
}
}
}