Smaller planets, 93% sectors, dearer late game, automation perks, autopilot, grass train
Not yet tried in the game: Unity could not get a licence (Unity Hub isn't running), so this was only type-checked with Roslyn. - Planets by area: the hard one half the old whole planet, normal a third of that, easy a sixth. Saves keep the size set they were made on (sizeGen 0). - A sector closes at 93% mown. - Mid and late prices go up (perks, machines, vehicles, tunes); the early game stays as it was. - AUTOMATION perk tree: Long Leash (robot reach), Overdrive Motors, Bigger Hoppers, Long-Range Drones and Hive Mind. - Autopilot, a garage tune for mowers: C hands the machine over. It mows the fields around in strokes, unloads at the nearest pad or the base yard and comes back. Getting in takes it back; it carries on after a load. - Grass Train: lays its own track to a station next door, mowing under it, then runs back and forth cutting wider each run. Models in gc_train.py. Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
This commit is contained in:
@ -42,8 +42,8 @@ namespace GrassCutter
|
||||
NetworkVariable<Vector4> Trip(int i) => i == 0 ? _trip0 : i == 1 ? _trip1 : i == 2 ? _trip2 : _trip3;
|
||||
/// <summary>Two drones at Mk I, one more per upgrade, four at most.</summary>
|
||||
int Count => Mathf.Min(Most, 2 + (Piece ? Piece.Tier.Value : 0));
|
||||
float Fly => Speed * Mathf.Sqrt(Piece ? Piece.TierMul : 1f);
|
||||
float Reach => Range + RangePerTier * (Piece ? Piece.Tier.Value : 0);
|
||||
float Fly => Speed * Mathf.Sqrt(Piece ? Piece.TierMul : 1f) * (TeamState.Instance ? TeamState.Instance.DroneSpeedMul : 1f);
|
||||
float Reach => Range + RangePerTier * (Piece ? Piece.Tier.Value : 0) + (TeamState.Instance ? TeamState.Instance.DroneReachAdd : 0f);
|
||||
readonly float[] _idleUntil = new float[Most];
|
||||
float _shipAt;
|
||||
double Now => NetworkManager ? NetworkManager.ServerTime.Time : Time.timeAsDouble;
|
||||
|
||||
@ -14,9 +14,9 @@ namespace GrassCutter
|
||||
|
||||
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 TuneId : byte { Motors, Hopper, Turbo, Cruise, Cutter, Release, Lights, Autopilot, Count }
|
||||
|
||||
public enum PerkTree : byte { Containers = 0, Cutting = 1, Suit = 2, Logistics = 3, Economy = 4 }
|
||||
public enum PerkTree : byte { Containers = 0, Cutting = 1, Suit = 2, Logistics = 3, Economy = 4, Automation = 5 }
|
||||
|
||||
public enum PerkId : byte
|
||||
{
|
||||
@ -30,13 +30,15 @@ namespace GrassCutter
|
||||
QuickTwine, BundleLine, ThrowArm, ExpressDepot,
|
||||
// ECONOMY
|
||||
EarthPrices, RegionBonus, SupplyDeals, GreenExchange,
|
||||
// AUTOMATION (after the rest: a save keeps its perks by number)
|
||||
BotReach, BotSpeed, BotHopper, DroneRange, HiveMind,
|
||||
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, SkyMower, Count }
|
||||
Wall, WindowWall, DoorWall, Railing, Fence, Floor, FlatRoof, Roof, Stairs, Steps, Pillar, Planter, Lamppost, Bench, Crates, Flagpole, SkyMower, Train, 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 }
|
||||
@ -236,50 +238,65 @@ namespace GrassCutter
|
||||
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 },
|
||||
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, 600, 2400 },
|
||||
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,
|
||||
new PerkDef { id = PerkId.AutoBaler, tree = PerkTree.Containers, name = Loc.N("Auto-Binder"), icon = "icon_piece_filler", col = 3, row = 2, prices = new long[] { 5000 }, 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 },
|
||||
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, 180, 700 },
|
||||
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 },
|
||||
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, 350 },
|
||||
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 },
|
||||
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, 450 },
|
||||
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,
|
||||
new PerkDef { id = PerkId.WhetSteel, tree = PerkTree.Cutting, name = Loc.N("Whetstone Steel"), icon = "icon_perk_blast", col = 1, row = 1, prices = new long[] { 4500 }, 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 },
|
||||
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, 200, 800 },
|
||||
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 },
|
||||
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, 400 },
|
||||
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,
|
||||
new PerkDef { id = PerkId.FieldFrame, tree = PerkTree.Suit, name = Loc.N("Field Frame"), icon = "icon_perk_fins", col = 1, row = 1, prices = new long[] { 3500 }, 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 },
|
||||
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, 120, 450 },
|
||||
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 },
|
||||
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, 300 },
|
||||
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 },
|
||||
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, 360 },
|
||||
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,
|
||||
new PerkDef { id = PerkId.ExpressDepot, tree = PerkTree.Logistics, name = Loc.N("Express Depot"), icon = "icon_perk_dockpump", col = 1, row = 1, prices = new long[] { 2500 }, 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 },
|
||||
new PerkDef { id = PerkId.EarthPrices, tree = PerkTree.Economy, name = Loc.N("Earth Prices"), icon = "icon_perk_contracts", col = 0, row = 0, prices = new long[] { 150, 900, 3500 },
|
||||
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 },
|
||||
new PerkDef { id = PerkId.RegionBonus, tree = PerkTree.Economy, name = Loc.N("Sector Bounty"), icon = "icon_perk_purity", col = 2, row = 0, prices = new long[] { 250, 1200 },
|
||||
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 },
|
||||
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, 900 },
|
||||
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,
|
||||
new PerkDef { id = PerkId.GreenExchange, tree = PerkTree.Economy, name = Loc.N("Green Exchange"), icon = "icon_star", col = 1, row = 2, prices = new long[] { 12000 }, big = true, requires = new[] { PerkId.EarthPrices }, requireLevel = 2,
|
||||
desc = Loc.N("A seat on the Earth grass exchange: +10% on every payout.") },
|
||||
|
||||
// ── AUTOMATION ──
|
||||
new PerkDef { id = PerkId.BotReach, tree = PerkTree.Automation, name = Loc.N("Long Leash"), icon = "icon_perk_turnaround", col = 0, row = 0, prices = new long[] { 600, 1800, 5000 },
|
||||
desc = Loc.N("Robots start further out and mow further from home."), effect = l => Loc.F("+{0}% robot reach", l * 25) },
|
||||
new PerkDef { id = PerkId.BotSpeed, tree = PerkTree.Automation, name = Loc.N("Overdrive Motors"), icon = "icon_perk_turbo", col = 1, row = 0, prices = new long[] { 800, 2400, 6500 },
|
||||
desc = Loc.N("Robots and Sky Mowers drive and mow faster."), effect = l => Loc.F("+{0}% robot speed", l * 12) },
|
||||
new PerkDef { id = PerkId.BotHopper, tree = PerkTree.Automation, name = Loc.N("Bigger Hoppers"), icon = "icon_perk_tankcap", col = 2, row = 0, prices = new long[] { 700, 2600 },
|
||||
desc = Loc.N("Robots carry more grass before they head home."), effect = l => Loc.F("+{0}% robot hopper", l * 25) },
|
||||
new PerkDef { id = PerkId.DroneRange, tree = PerkTree.Automation, name = Loc.N("Long-Range Drones"), icon = "icon_perk_dronefleet", col = 3, row = 0, prices = new long[] { 900, 2800, 7000 },
|
||||
desc = Loc.N("Drone pads fetch bundles from further away."), effect = l => Loc.F("+{0} m drone reach", l * DroneReachStep) },
|
||||
new PerkDef { id = PerkId.HiveMind, tree = PerkTree.Automation, name = Loc.N("Hive Mind"), icon = "icon_perk_swarm", col = 2, row = 1, prices = new long[] { 15000 }, big = true, requires = new[] { PerkId.BotSpeed, PerkId.DroneRange }, requireLevel = 2,
|
||||
desc = Loc.N("Every robot, Sky Mower and drone works 20% faster.") },
|
||||
};
|
||||
|
||||
/// <summary>Metres a drone pad reaches further per level of Long-Range Drones.</summary>
|
||||
public const int DroneReachStep = 20;
|
||||
|
||||
public static PerkDef Perk(PerkId id) => Perks[(int)id];
|
||||
|
||||
// ───────────────────────── build pieces ─────────────────────────
|
||||
@ -298,9 +315,9 @@ namespace GrassCutter
|
||||
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,
|
||||
new PieceDef { id = PieceId.Dryer, cat = PieceCat.Production, name = Loc.N("Windmill"), icon = "icon_piece_vaporizer", model = "SM_Windmill", prefab = "Piece_Dryer", price = 800, 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,
|
||||
new PieceDef { id = PieceId.Press, cat = PieceCat.Production, name = Loc.N("Brick Press"), icon = "icon_piece_cryo", model = "SM_CryoPress", prefab = "Piece_Press", price = 2500, 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.") },
|
||||
@ -314,21 +331,21 @@ namespace GrassCutter
|
||||
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 sectors around its dock, then further out once they are done. With a belt the dock sends bundles down it, without one it ships the grass to Earth itself.") },
|
||||
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,
|
||||
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 = 900, sizeX = 3, sizeZ = 3,
|
||||
desc = Loc.N("Starts with 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,
|
||||
new PieceDef { id = PieceId.Reaper, cat = PieceCat.Services, name = Loc.N("Reaper"), icon = "icon_piece_reaper", model = "SM_Reaper", prefab = "Piece_Reaper", price = 60000, 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,
|
||||
new PieceDef { id = PieceId.Catcher, cat = PieceCat.Services, name = Loc.N("Bundle Catcher"), icon = "icon_piece_catcher", model = "SM_BundleCatcher", prefab = "Piece_Catcher", price = 3000, 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,
|
||||
new PieceDef { id = PieceId.BatteryL, cat = PieceCat.Power, name = Loc.N("Battery Bank"), icon = "icon_piece_batteryl", model = "SM_BatteryBank", prefab = "Piece_BatteryL", price = 1800, 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,
|
||||
new PieceDef { id = PieceId.DronePad, cat = PieceCat.Logistics, name = Loc.N("Drone Pad"), icon = "icon_piece_dronepad", model = "SM_DronePad", prefab = "Piece_DronePad", price = 900, sizeX = 3, sizeZ = 3, scale = 3.2f,
|
||||
desc = Loc.N("Its drones fly out to bundles of grass lying loose within 70 m (25 m more per upgrade) and bring them in. With a belt on the front hatch they go down it, without one straight to Earth. 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.") },
|
||||
@ -367,8 +384,10 @@ namespace GrassCutter
|
||||
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.") },
|
||||
// (appended: the list follows PieceId, and saves keep the ids)
|
||||
new PieceDef { id = PieceId.SkyMower, cat = PieceCat.Services, name = Loc.N("Sky Mower"), icon = "icon_piece_skymower", model = "SM_DronePad", prefab = "Piece_SkyMower", price = 4000, sizeX = 3, sizeZ = 3, scale = 3.2f,
|
||||
new PieceDef { id = PieceId.SkyMower, cat = PieceCat.Services, name = Loc.N("Sky Mower"), icon = "icon_piece_skymower", model = "SM_DronePad", prefab = "Piece_SkyMower", price = 9000, sizeX = 3, sizeZ = 3, scale = 3.2f,
|
||||
desc = Loc.N("A big mowing drone. It flies over rocks and hills, works 91 sectors around its pad and goes further out once they are mown. No belt needed: the pad sends the grass to Earth.") },
|
||||
new PieceDef { id = PieceId.Train, cat = PieceCat.Services, name = Loc.N("Grass Train"), icon = "icon_piece_train", model = "SM_TrainStation", prefab = "Piece_Train", price = 12000, sizeX = 4, sizeZ = 8,
|
||||
desc = Loc.N("Lays its own track to a station next door, mowing all the way there. Then it runs back and forth, its side cutters reaching further out on every run, and what it cuts is paid for at either end. Build it on open ground facing the way it should go.") },
|
||||
};
|
||||
|
||||
public static PieceDef Piece(PieceId id) => Pieces[(int)id];
|
||||
@ -384,7 +403,7 @@ namespace GrassCutter
|
||||
{
|
||||
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: case PieceId.SkyMower: return UpgradeKind.Robot;
|
||||
case PieceId.RobotI: case PieceId.RobotII: case PieceId.Reaper: case PieceId.SkyMower: case PieceId.Train: return UpgradeKind.Robot;
|
||||
case PieceId.Garage: case PieceId.UnloadBay: case PieceId.Catcher: case PieceId.DronePad: return UpgradeKind.Silo;
|
||||
default: return UpgradeKind.None;
|
||||
}
|
||||
@ -519,19 +538,19 @@ namespace GrassCutter
|
||||
{
|
||||
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,
|
||||
new VehicleDef { kind = VehicleKind.Rider, name = Loc.N("Garden Rider"), icon = "icon_vehicle_ski", price = 1200, 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,
|
||||
new VehicleDef { kind = VehicleKind.Pickup, name = Loc.N("Pickup"), icon = "icon_vehicle_hover", price = 2500, 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,
|
||||
new VehicleDef { kind = VehicleKind.Tractor, name = Loc.N("Mowing Tractor"), icon = "icon_vehicle_tug", price = 4000, 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,
|
||||
new VehicleDef { kind = VehicleKind.Combine, name = Loc.N("Combine"), icon = "icon_vehicle_combine", price = 15000, 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,
|
||||
new VehicleDef { kind = VehicleKind.Hauler, name = Loc.N("Haul Tractor"), icon = "icon_vehicle_hauler", price = 7000, 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,
|
||||
new VehicleDef { kind = VehicleKind.Mulcher, name = Loc.N("Wide Mulcher"), icon = "icon_vehicle_mulcher", price = 20000, 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,
|
||||
new VehicleDef { kind = VehicleKind.Baler, name = Loc.N("Baler Tractor"), icon = "icon_vehicle_baler", price = 6000, 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.") },
|
||||
};
|
||||
|
||||
@ -539,19 +558,21 @@ namespace GrassCutter
|
||||
|
||||
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.Motors, name = Loc.N("Tuned Motors"), prices = new long[] { 250, 900, 3000 }, effect = l => Loc.F("+{0}% speed and pull", l * 10) },
|
||||
new TuneDef { id = TuneId.Hopper, name = Loc.N("Big Hopper"), prices = new long[] { 200, 700, 2400 }, effect = l => Loc.F("+{0}% hopper", l * 30) },
|
||||
new TuneDef { id = TuneId.Turbo, name = Loc.N("Turbo Kit"), prices = new long[] { 400, 2000 }, 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.Cutter, name = Loc.N("Cutter Control"), prices = new long[] { 400, 1400, 4000 }, 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) },
|
||||
new TuneDef { id = TuneId.Autopilot, name = Loc.N("Autopilot"), prices = new long[] { 1500 }, effect = l => Loc.T("C hands it over: it mows and unloads on its own") },
|
||||
};
|
||||
|
||||
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 bool TuneFits(VehicleKind k, TuneId t) => t == TuneId.Autopilot ? Vehicle(k).bed == 0 && Vehicle(k).width > 0f
|
||||
: 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;
|
||||
|
||||
@ -53,7 +53,9 @@ namespace GrassCutter
|
||||
BuildPiece _bp;
|
||||
/// <summary>The dock's upgrade level makes the robot faster and its hopper bigger.</summary>
|
||||
protected float Boost => (_bp ? _bp : (_bp = GetComponent<BuildPiece>())) ? _bp.TierMul : 1f;
|
||||
public float HopperCap => Def.hopper * Boost;
|
||||
public float HopperCap => Def.hopper * Boost * (TeamState.Instance ? TeamState.Instance.BotHopperMul : 1f);
|
||||
/// <summary>The crew's automation perks.</summary>
|
||||
protected float PerkSpeed => TeamState.Instance ? TeamState.Instance.BotSpeedMul : 1f;
|
||||
public RobotMood Doing => (RobotMood)Mood.Value;
|
||||
|
||||
protected abstract Transform Body { get; }
|
||||
@ -312,7 +314,7 @@ namespace GrassCutter
|
||||
// not RotateTowards: it calls anything under a tenth of a degree "there already", and that is 4 m on this ball
|
||||
var gap = goal - Dir;
|
||||
// on the way somewhere (to a sector, home to unload) it goes faster than it mows
|
||||
float step = Def.speed * Boost * (Homing || _travel ? TravelMul : 1f) * dt / Planet.Radius;
|
||||
float step = Def.speed * Boost * PerkSpeed * (Homing || _travel ? TravelMul : 1f) * dt / Planet.Radius;
|
||||
if (gap.magnitude > step) Dir = (Dir + gap.normalized * step).normalized;
|
||||
else
|
||||
{
|
||||
|
||||
@ -23,8 +23,10 @@ namespace GrassCutter
|
||||
protected override Transform Body => bot;
|
||||
protected override bool NoseOnBack => true;
|
||||
protected override Vector3 Origin => transform.position;
|
||||
protected override int Reach => _reach > 0 ? _reach : Def.reach;
|
||||
int MaxReach => Def.reach * 4;
|
||||
protected override int Reach => Mathf.Min(MaxReach, Mathf.Max(_reach, StartReach));
|
||||
/// <summary>Where it starts: its own reach, and Long Leash puts it further out.</summary>
|
||||
int StartReach => Def.reach + (TeamState.Instance ? TeamState.Instance.BotReachRings : 0);
|
||||
int MaxReach => Mathf.Max(StartReach, Mathf.RoundToInt(Def.reach * 4 * (TeamState.Instance ? TeamState.Instance.BotRoamMul : 1f)));
|
||||
protected override Vector3 HomeDir => Planet.Up(transform.position);
|
||||
|
||||
public override string Prompt
|
||||
@ -98,7 +100,7 @@ namespace GrassCutter
|
||||
public override void Moved(Vector3 at)
|
||||
{
|
||||
base.Moved(at);
|
||||
_reach = Def.reach;
|
||||
_reach = 0;
|
||||
_area = 0;
|
||||
}
|
||||
}
|
||||
|
||||
@ -18,6 +18,9 @@ namespace GrassCutter
|
||||
public float tank;
|
||||
public int[] tune;
|
||||
public Vector2[] bed;
|
||||
/// <summary>On autopilot (<see cref="Vehicle.AutoJob"/>, 0 off), and the spot and way it was started from.</summary>
|
||||
public int auto;
|
||||
public Vector3 home, fwd;
|
||||
}
|
||||
|
||||
/// <summary>Where a garage puts a machine: its pad, or if it's gone, at the base along the ramp in the first free spot.</summary>
|
||||
@ -141,6 +144,7 @@ namespace GrassCutter
|
||||
{
|
||||
if (!v || !v.IsSpawned) continue;
|
||||
var s = new VehicleSave { kind = (int)v.kind, key = v.Crew.Value.ToString(), at = v.transform.position, turn = v.transform.rotation, tank = v.Tank.Value };
|
||||
if (!v.HasDriver) v.AutoState(out s.auto, out s.home, out s.fwd);
|
||||
s.tune = new int[v.Tuned.Count];
|
||||
for (int i = 0; i < s.tune.Length; i++) s.tune[i] = v.Tuned[i];
|
||||
s.bed = new Vector2[v.Bed.Count];
|
||||
@ -161,6 +165,7 @@ namespace GrassCutter
|
||||
v.Tank.Value = s.tank;
|
||||
if (s.tune != null) for (int i = 0; i < s.tune.Length && i < v.Tuned.Count; i++) v.Tuned[i] = (byte)s.tune[i];
|
||||
if (s.bed != null) foreach (var b in s.bed) v.Bed.Add(b);
|
||||
if (s.auto != 0) v.ServerResumeAuto(s.home, s.fwd);
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
@ -46,6 +46,8 @@ namespace GrassCutter
|
||||
public int ver;
|
||||
/// <summary>How big the ball is: 0 the whole planet (every save from before there was a choice), 1 half, 2 a third.</summary>
|
||||
public int level;
|
||||
/// <summary>Which set of planet sizes (<see cref="Difficulties.NewGen"/>): 0 for every save from before.</summary>
|
||||
public int sizeGen;
|
||||
public double money, shipped, mown;
|
||||
/// <summary>Time of day: the first morning begins here.</summary>
|
||||
public float day = 0.75f;
|
||||
@ -86,7 +88,7 @@ namespace GrassCutter
|
||||
Tiles.OnListChanged += _ => { TilesChanged?.Invoke(); Changed?.Invoke(); };
|
||||
if (!IsServer)
|
||||
{
|
||||
Difficulties.Apply((Difficulty)Size.Value);
|
||||
Difficulties.ApplyWire(Size.Value);
|
||||
MowMap.Reset(); // the host sends what has been cut
|
||||
}
|
||||
WatchSectors();
|
||||
@ -140,6 +142,15 @@ namespace GrassCutter
|
||||
|
||||
public float BundleSeconds => GameDefs.BundleSeconds(Level(PerkId.QuickTwine), Level(PerkId.ExpressDepot));
|
||||
|
||||
/// <summary>Rings a robot starts further out, from Long Leash.</summary>
|
||||
public int BotReachRings => Level(PerkId.BotReach);
|
||||
/// <summary>How far out a robot may roam, against its own limit.</summary>
|
||||
public float BotRoamMul => 1f + Level(PerkId.BotReach) * 0.25f;
|
||||
public float BotSpeedMul => (1f + Level(PerkId.BotSpeed) * 0.12f) * (Has(PerkId.HiveMind) ? 1.2f : 1f);
|
||||
public float BotHopperMul => 1f + Level(PerkId.BotHopper) * 0.25f;
|
||||
public float DroneReachAdd => Level(PerkId.DroneRange) * GameDefs.DroneReachStep;
|
||||
public float DroneSpeedMul => Has(PerkId.HiveMind) ? 1.2f : 1f;
|
||||
|
||||
public float PayoutMul => GameDefs.PayoutMul(Level(PerkId.EarthPrices), Level(PerkId.GreenExchange));
|
||||
|
||||
public double ToolPrice(ToolDef d) => d.id == ToolId.Hammer ? d.price : Math.Round(d.price * (double)GameDefs.ToolPriceMul(Level(PerkId.SupplyDeals)), 2);
|
||||
@ -325,7 +336,7 @@ namespace GrassCutter
|
||||
public void Save()
|
||||
{
|
||||
if (!IsServer) return;
|
||||
var d = new SaveData { ver = 6, level = Size.Value, money = Money.Value, shipped = Shipped.Value, mown = Mown.Value, crew = _crew, day = Sun.Phase, vehicles = PackVehicles(), banned = _banned };
|
||||
var d = new SaveData { ver = 6, level = (int)Difficulties.Current, sizeGen = Difficulties.Gen, money = Money.Value, shipped = Shipped.Value, mown = Mown.Value, crew = _crew, day = Sun.Phase, vehicles = PackVehicles(), banned = _banned };
|
||||
d.perks = new int[Perks.Count];
|
||||
for (int i = 0; i < Perks.Count; i++) d.perks[i] = Perks[i];
|
||||
d.tiles = new int[Tiles.Count];
|
||||
@ -356,8 +367,8 @@ namespace GrassCutter
|
||||
// the ball first: the mow map, the stakes and every piece go down on it
|
||||
var level = fresh ? Difficulties.Chosen : (Difficulty)d.level;
|
||||
if (fresh && CommandLine.Get("-difficulty") is string forced && byte.TryParse(forced, out byte f)) level = (Difficulty)f;
|
||||
Difficulties.Apply(level);
|
||||
Size.Value = (byte)Difficulties.Current;
|
||||
Difficulties.Apply(level, fresh ? Difficulties.NewGen : d.sizeGen);
|
||||
Size.Value = Difficulties.Wire;
|
||||
MowMap.Reset();
|
||||
if (!fresh) LoadMow();
|
||||
Money.Value = d.money;
|
||||
|
||||
434
Assets/Scripts/Gameplay/Train.cs
Normal file
434
Assets/Scripts/Gameplay/Train.cs
Normal file
@ -0,0 +1,434 @@
|
||||
using System.Collections.Generic;
|
||||
using System.Linq;
|
||||
using Unity.Netcode;
|
||||
using UnityEngine;
|
||||
|
||||
namespace GrassCutter
|
||||
{
|
||||
/// <summary>
|
||||
/// The grass train. Built at a base, it lays its own track to a station next door (the one most in front of it, E picks
|
||||
/// another while the track is short), mowing a strip under the rails all the way. Once the track gets there it runs
|
||||
/// back and forth, its side cutters reaching one strip further out on every run until they reach as far as they can,
|
||||
/// and what it cuts is paid for at either end. The host moves it; every peer draws the track and the train from the
|
||||
/// same few numbers (where to, how much is laid, where the head is).
|
||||
/// </summary>
|
||||
public class Train : NetworkBehaviour, IInteractable, IPieceState
|
||||
{
|
||||
public Transform loco;
|
||||
public Transform[] wagons;
|
||||
|
||||
/// <summary>Track points every two metres; the first stretch runs straight off the platform.</summary>
|
||||
const float Step = 2f, Lead = 24f, StopShort = 16f;
|
||||
/// <summary>Metres a second laying track and running on it, at Mk I.</summary>
|
||||
const float LaySpeed = 2.4f, RunSpeed = 8f;
|
||||
/// <summary>Strip cut under the rails, and the width each side cutter adds on a run.</summary>
|
||||
const float Strip = 3.4f, Arm = 3f;
|
||||
/// <summary>How far out the side cutters reach at Mk I, either side of the track.</summary>
|
||||
const float Reach = 18f;
|
||||
const float WaitAtEnd = 6f, Hold = 6000f, Gap = 5.2f, Gauge = 1.5f;
|
||||
|
||||
/// <summary>The station it is laying track to (255: not chosen yet).</summary>
|
||||
public readonly NetworkVariable<byte> Target = new NetworkVariable<byte>(255);
|
||||
/// <summary>Metres of track down.</summary>
|
||||
public readonly NetworkVariable<float> Laid = new NetworkVariable<float>();
|
||||
/// <summary>Where the locomotive is along the track, in metres from the platform.</summary>
|
||||
public readonly NetworkVariable<float> At = new NetworkVariable<float>();
|
||||
/// <summary>Runs since the track was finished: run n cuts the n-th strip out either side.</summary>
|
||||
public readonly NetworkVariable<int> Runs = new NetworkVariable<int>();
|
||||
public readonly NetworkVariable<float> Hopper = new NetworkVariable<float>();
|
||||
|
||||
readonly List<Vector3> _pts = new List<Vector3>();
|
||||
readonly List<float> _cum = new List<float>();
|
||||
float _length, _wait, _shown = -1f;
|
||||
BuildPiece _bp;
|
||||
BuildPiece Piece => _bp ? _bp : (_bp = GetComponent<BuildPiece>());
|
||||
TeamState Ts => TeamState.Instance;
|
||||
|
||||
float Mul => (Piece ? Piece.TierMul : 1f) * (Ts ? Ts.BotSpeedMul : 1f);
|
||||
float MaxOut => Reach * (Piece ? Piece.TierMul : 1f);
|
||||
/// <summary>Where the train stands at home: far enough along for every wagon to be on the rails.</summary>
|
||||
float HomeAt => Mathf.Min(_length, (wagons != null ? wagons.Length : 0) * Gap + 1f);
|
||||
float Inner => Strip * 0.5f + (Runs.Value - 1) * Arm;
|
||||
bool Laying => Laid.Value < _length - 0.01f;
|
||||
bool RouteDone => !Laying && Runs.Value > 0 && Inner >= MaxOut;
|
||||
|
||||
// ───────────────────────── life ─────────────────────────
|
||||
|
||||
readonly List<(Transform t, Quaternion rest, float r)> _wheels = new List<(Transform, Quaternion, float)>();
|
||||
Transform _reel;
|
||||
Quaternion _reelRest;
|
||||
float _rolled, _reelAngle, _lastShown = -1f;
|
||||
|
||||
void Awake()
|
||||
{
|
||||
// the wheels turn as it goes, the cutter reel on the nose spins while it cuts
|
||||
foreach (var root in new[] { loco }.Concat(wagons ?? new Transform[0]))
|
||||
{
|
||||
if (!root) continue;
|
||||
foreach (var t in root.GetComponentsInChildren<Transform>(true))
|
||||
{
|
||||
if (t.name.StartsWith("Wheel"))
|
||||
{
|
||||
var mf = t.GetComponent<MeshFilter>();
|
||||
float rad = mf && mf.sharedMesh ? Mathf.Max(0.1f, mf.sharedMesh.bounds.extents.y) : 0.4f;
|
||||
_wheels.Add((t, t.localRotation, rad));
|
||||
}
|
||||
else if (t.name == "Reel") { _reel = t; _reelRest = t.localRotation; }
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
public override void OnNetworkSpawn()
|
||||
{
|
||||
Target.OnValueChanged += (_, __) => Route();
|
||||
if (IsServer && Target.Value == 255) Target.Value = Pick(-1);
|
||||
Route();
|
||||
}
|
||||
|
||||
public override void OnNetworkDespawn()
|
||||
{
|
||||
if (_track) Destroy(_track);
|
||||
}
|
||||
|
||||
public override void OnDestroy()
|
||||
{
|
||||
if (_track) Destroy(_track);
|
||||
base.OnDestroy();
|
||||
}
|
||||
|
||||
/// <summary>A station next to the one this stands by, the most in front of it after <paramref name="after"/>.</summary>
|
||||
byte Pick(int after)
|
||||
{
|
||||
var p = transform.position;
|
||||
var up = Planet.Up(p);
|
||||
var fwd = Vector3.ProjectOnPlane(transform.forward, up).normalized;
|
||||
int home = Stations.Nearest(p);
|
||||
var near = new List<(int i, float score)>();
|
||||
for (int i = 0; i < Stations.Count; i++)
|
||||
{
|
||||
if (i == home) continue;
|
||||
var d = Stations.Dir(i);
|
||||
// the twelve stations stand on an icosahedron: the five next door are a dot of 0.447 away
|
||||
if (Vector3.Dot(d, Stations.Dir(home)) < 0.3f) continue;
|
||||
near.Add((i, Vector3.Dot(Vector3.ProjectOnPlane(d - up, up).normalized, fwd)));
|
||||
}
|
||||
if (near.Count == 0) return (byte)(home == 0 ? 1 : 0);
|
||||
near.Sort((a, b) => b.score.CompareTo(a.score));
|
||||
if (after < 0) return (byte)near[0].i;
|
||||
int k = near.FindIndex(n => n.i == after);
|
||||
return (byte)near[(k + 1) % near.Count].i;
|
||||
}
|
||||
|
||||
void Route()
|
||||
{
|
||||
_pts.Clear();
|
||||
_cum.Clear();
|
||||
_length = 0f;
|
||||
ClearTrack();
|
||||
if (Target.Value >= Stations.Count) return;
|
||||
var up = Planet.Up(transform.position);
|
||||
var fwd = Vector3.ProjectOnPlane(transform.forward, up).normalized;
|
||||
// from the buffer stop at the back of the platform
|
||||
var a = transform.position - fwd * 3.6f;
|
||||
var lead = Planet.Surface(a + fwd * Lead);
|
||||
// off the platform in a straight ramp down to the ground
|
||||
int n = Mathf.CeilToInt(Lead / Step);
|
||||
for (int i = 0; i < n; i++)
|
||||
{
|
||||
var g = Planet.Surface(Vector3.Lerp(a, lead, i / (float)n));
|
||||
float t = i / (float)n;
|
||||
_pts.Add(Vector3.Lerp(a, g, Mathf.SmoothStep(0f, 1f, t)));
|
||||
}
|
||||
// then the great circle to the station, stopping short of its yard
|
||||
var from = Planet.Up(lead);
|
||||
var to = Stations.Dir(Target.Value);
|
||||
float ang = Mathf.Acos(Mathf.Clamp(Vector3.Dot(from, to), -1f, 1f));
|
||||
float full = ang * Planet.Radius, arc = Mathf.Max(Step, full - StopShort);
|
||||
int m = Mathf.Max(1, Mathf.CeilToInt(arc / Step));
|
||||
for (int j = 0; j <= m; j++) _pts.Add(Planet.OnSurface(Vector3.Slerp(from, to, j * arc / m / full)));
|
||||
_cum.Add(0f);
|
||||
for (int i = 1; i < _pts.Count; i++) _cum.Add(_cum[i - 1] + Vector3.Distance(_pts[i - 1], _pts[i]));
|
||||
_length = _cum[_cum.Count - 1];
|
||||
}
|
||||
|
||||
/// <summary>The point this far along the track.</summary>
|
||||
Vector3 Pos(float d)
|
||||
{
|
||||
if (_pts.Count == 0) return transform.position;
|
||||
d = Mathf.Clamp(d, 0f, _length);
|
||||
int lo = 0, hi = _cum.Count - 1;
|
||||
while (hi - lo > 1)
|
||||
{
|
||||
int mid = (lo + hi) >> 1;
|
||||
if (_cum[mid] <= d) lo = mid; else hi = mid;
|
||||
}
|
||||
float seg = _cum[hi] - _cum[lo];
|
||||
return Vector3.Lerp(_pts[lo], _pts[hi], seg > 1e-4f ? (d - _cum[lo]) / seg : 0f);
|
||||
}
|
||||
|
||||
Vector3 Ahead(float d) => (Pos(d + 1f) - Pos(d - 1f)).normalized;
|
||||
|
||||
// ───────────────────────── the host runs it ─────────────────────────
|
||||
|
||||
void Update()
|
||||
{
|
||||
if (!IsSpawned) return;
|
||||
if (IsServer && _length > 0f) Run(Time.deltaTime);
|
||||
Draw();
|
||||
}
|
||||
|
||||
void Run(float dt)
|
||||
{
|
||||
if (_wait > 0f) { _wait -= dt; return; }
|
||||
if (Laying)
|
||||
{
|
||||
float was = Laid.Value, now = Mathf.Min(_length, was + LaySpeed * Mul * dt);
|
||||
Laid.Value = now;
|
||||
At.Value = now;
|
||||
Cut(was, now, 0f, Strip);
|
||||
if (!Laying) Arrive(1);
|
||||
return;
|
||||
}
|
||||
if (Runs.Value <= 0) { Runs.Value = 1; return; }
|
||||
bool done = RouteDone;
|
||||
// odd runs come home, even ones go out; with nothing left in reach it goes home and waits there
|
||||
float goal = done || Runs.Value % 2 == 1 ? HomeAt : _length;
|
||||
float a = At.Value, b = Mathf.MoveTowards(a, goal, RunSpeed * Mul * dt);
|
||||
if (b != a) At.Value = b;
|
||||
if (!done) Cut(a, b, Inner, Mathf.Min(Arm, MaxOut - Inner));
|
||||
if (Mathf.Abs(b - goal) < 0.01f)
|
||||
{
|
||||
if (done) Ship();
|
||||
else Arrive(Runs.Value + 1);
|
||||
}
|
||||
}
|
||||
|
||||
void Arrive(int nextRun)
|
||||
{
|
||||
Ship();
|
||||
_wait = WaitAtEnd;
|
||||
Runs.Value = nextRun;
|
||||
}
|
||||
|
||||
void Ship()
|
||||
{
|
||||
if (Hopper.Value <= 0.01f || !Ts) return;
|
||||
Ts.DepositRpc(Hopper.Value, (byte)CargoKind.Grass, Pos(At.Value));
|
||||
Hopper.Value = 0f;
|
||||
}
|
||||
|
||||
/// <summary>Mows along the track from a to b: under it (offset 0), or a strip either side starting this far out.</summary>
|
||||
void Cut(float a, float b, float offset, float width)
|
||||
{
|
||||
if (width <= 0.05f || Mathf.Abs(b - a) < 1e-4f) return;
|
||||
float kg = 0f;
|
||||
int n = Mathf.Max(1, Mathf.CeilToInt(Mathf.Abs(b - a) / Step));
|
||||
for (int k = 0; k < n; k++)
|
||||
{
|
||||
float d0 = Mathf.Lerp(a, b, k / (float)n), d1 = Mathf.Lerp(a, b, (k + 1) / (float)n);
|
||||
var p0 = Pos(d0);
|
||||
var p1 = Pos(d1);
|
||||
if (offset <= 0f) { kg += MowMap.Cut(Planet.Surface(p0), Planet.Surface(p1), width, 0f, MowMap.PaintFeather); continue; }
|
||||
var up = Planet.Up(p0);
|
||||
var side = Vector3.Cross(up, Ahead(d0)).normalized;
|
||||
float o = offset + width * 0.5f;
|
||||
kg += MowMap.Cut(Planet.Surface(p0 + side * o), Planet.Surface(p1 + side * o), width, 0f, MowMap.PaintFeather);
|
||||
kg += MowMap.Cut(Planet.Surface(p0 - side * o), Planet.Surface(p1 - side * o), width, 0f, MowMap.PaintFeather);
|
||||
}
|
||||
Hopper.Value = Mathf.Min(Hold, Hopper.Value + kg * GameDefs.GrassDensity);
|
||||
}
|
||||
|
||||
// ───────────────────────── what everyone sees ─────────────────────────
|
||||
|
||||
void Draw()
|
||||
{
|
||||
if (_length <= 0f) return;
|
||||
float at = At.Value;
|
||||
if (IsServer || _shown < 0f || Mathf.Abs(_shown - at) > 30f) _shown = at;
|
||||
else _shown = Mathf.MoveTowards(_shown, at, (RunSpeed * 2.5f + Mathf.Abs(at - _shown) * 4f) * Time.deltaTime);
|
||||
Place(loco, _shown, true);
|
||||
if (wagons != null)
|
||||
for (int i = 0; i < wagons.Length; i++)
|
||||
{
|
||||
float d = _shown - (i + 1) * Gap;
|
||||
if (wagons[i]) wagons[i].gameObject.SetActive(d >= 0f);
|
||||
if (d >= 0f) Place(wagons[i], d, true);
|
||||
}
|
||||
Lay(Laid.Value);
|
||||
Spin();
|
||||
}
|
||||
|
||||
void Spin()
|
||||
{
|
||||
float moved = _lastShown < 0f ? 0f : _shown - _lastShown;
|
||||
_lastShown = _shown;
|
||||
if (Mathf.Abs(moved) > 20f) moved = 0f;
|
||||
_rolled += moved;
|
||||
foreach (var (t, rest, r) in _wheels)
|
||||
if (t) t.localRotation = rest * Quaternion.AngleAxis(_rolled / r * Mathf.Rad2Deg, Vector3.right);
|
||||
if (_reel && Mathf.Abs(moved) > 1e-4f && !RouteDone)
|
||||
{
|
||||
_reelAngle += Time.deltaTime * 720f;
|
||||
_reel.localRotation = _reelRest * Quaternion.AngleAxis(_reelAngle, Vector3.right);
|
||||
}
|
||||
}
|
||||
|
||||
void Place(Transform t, float d, bool onRails)
|
||||
{
|
||||
if (!t) return;
|
||||
var p = Pos(d);
|
||||
var up = Planet.Up(p);
|
||||
var f = Vector3.ProjectOnPlane(Ahead(d), up);
|
||||
if (f.sqrMagnitude < 1e-6f) f = Vector3.ProjectOnPlane(transform.forward, up);
|
||||
t.SetPositionAndRotation(p + up * (onRails ? 0.22f : 0f), Quaternion.LookRotation(f.normalized, up));
|
||||
}
|
||||
|
||||
// ───────────────────────── the track ─────────────────────────
|
||||
|
||||
const int ChunkPts = 32;
|
||||
GameObject _track;
|
||||
readonly List<Mesh> _chunks = new List<Mesh>();
|
||||
int _drawnSeg = -1;
|
||||
|
||||
void ClearTrack()
|
||||
{
|
||||
if (_track) Destroy(_track);
|
||||
_track = null;
|
||||
_chunks.Clear();
|
||||
_drawnSeg = -1;
|
||||
}
|
||||
|
||||
/// <summary>Rails and sleepers up to this many metres, a chunk of track at a time.</summary>
|
||||
void Lay(float upto)
|
||||
{
|
||||
int seg = 0;
|
||||
while (seg + 1 < _cum.Count && _cum[seg + 1] <= upto + 0.01f) seg++;
|
||||
if (seg == _drawnSeg) return;
|
||||
if (!_track)
|
||||
{
|
||||
_track = new GameObject("Track_" + NetworkObjectId);
|
||||
_drawnSeg = -1;
|
||||
}
|
||||
int from = Mathf.Max(0, _drawnSeg) / ChunkPts, to = seg / ChunkPts;
|
||||
for (int c = from; c <= to; c++) Chunk(c, seg);
|
||||
_drawnSeg = seg;
|
||||
}
|
||||
|
||||
void Chunk(int c, int lastSeg)
|
||||
{
|
||||
while (_chunks.Count <= c)
|
||||
{
|
||||
var go = new GameObject("Rails");
|
||||
go.transform.SetParent(_track.transform, false);
|
||||
var mesh = new Mesh { name = "Track" };
|
||||
go.AddComponent<MeshFilter>().sharedMesh = mesh;
|
||||
var mr = go.AddComponent<MeshRenderer>();
|
||||
var bank = AssetBank.I;
|
||||
mr.sharedMaterials = new[] { bank ? bank.Mat("M_Steel") : null, bank ? bank.Mat("M_Wood") : null };
|
||||
mr.shadowCastingMode = UnityEngine.Rendering.ShadowCastingMode.Off;
|
||||
_chunks.Add(mesh);
|
||||
}
|
||||
var v = new List<Vector3>();
|
||||
var nrm = new List<Vector3>();
|
||||
var uv = new List<Vector2>();
|
||||
var rails = new List<int>();
|
||||
var ties = new List<int>();
|
||||
int s0 = c * ChunkPts, s1 = Mathf.Min(lastSeg, s0 + ChunkPts);
|
||||
for (int s = s0; s < s1; s++)
|
||||
{
|
||||
var a = _pts[s];
|
||||
var b = _pts[s + 1];
|
||||
var up = Planet.Up(a);
|
||||
var f = (b - a).normalized;
|
||||
var side = Vector3.Cross(up, f).normalized;
|
||||
// two steel rails a little proud of the sleepers, one sleeper per two metres
|
||||
for (int r = -1; r <= 1; r += 2)
|
||||
{
|
||||
var o = side * (r * Gauge * 0.5f) + up * 0.16f;
|
||||
Box(v, nrm, uv, rails, a + o, b + o, side, up, 0.09f, 0.11f);
|
||||
}
|
||||
var mid = (a + b) * 0.5f + up * 0.06f;
|
||||
Box(v, nrm, uv, ties, mid - f * 0.14f, mid + f * 0.14f, side, up, 2.2f, 0.12f);
|
||||
}
|
||||
var mesh2 = _chunks[c];
|
||||
mesh2.Clear();
|
||||
mesh2.SetVertices(v);
|
||||
mesh2.SetNormals(nrm);
|
||||
mesh2.SetUVs(0, uv);
|
||||
mesh2.subMeshCount = 2;
|
||||
mesh2.SetTriangles(rails, 0);
|
||||
mesh2.SetTriangles(ties, 1);
|
||||
mesh2.RecalculateBounds();
|
||||
}
|
||||
|
||||
/// <summary>A box from a to b, this wide and this tall, standing on the line (no bottom face).</summary>
|
||||
static void Box(List<Vector3> v, List<Vector3> n, List<Vector2> uv, List<int> tris, Vector3 a, Vector3 b, Vector3 side, Vector3 up, float w, float h)
|
||||
{
|
||||
var s = side * (w * 0.5f);
|
||||
var t = up * h;
|
||||
var f = (b - a).normalized;
|
||||
Quad(v, n, uv, tris, a - s + t, a + s + t, b + s + t, b - s + t, up);
|
||||
Quad(v, n, uv, tris, a + s, b + s, b + s + t, a + s + t, side);
|
||||
Quad(v, n, uv, tris, b - s, a - s, a - s + t, b - s + t, -side);
|
||||
Quad(v, n, uv, tris, a - s, a + s, a + s + t, a - s + t, -f);
|
||||
Quad(v, n, uv, tris, b + s, b - s, b - s + t, b + s + t, f);
|
||||
}
|
||||
|
||||
static void Quad(List<Vector3> v, List<Vector3> n, List<Vector2> uv, List<int> tris, Vector3 p0, Vector3 p1, Vector3 p2, Vector3 p3, Vector3 normal)
|
||||
{
|
||||
int i = v.Count;
|
||||
v.Add(p0); v.Add(p1); v.Add(p2); v.Add(p3);
|
||||
for (int k = 0; k < 4; k++) n.Add(normal);
|
||||
uv.Add(new Vector2(0, 0)); uv.Add(new Vector2(1, 0)); uv.Add(new Vector2(1, 1)); uv.Add(new Vector2(0, 1));
|
||||
// Unity's front face: Cross(b - a, c - a) points at the viewer
|
||||
var cross = Vector3.Cross(p1 - p0, p2 - p0);
|
||||
if (Vector3.Dot(cross, normal) > 0f) { tris.Add(i); tris.Add(i + 1); tris.Add(i + 2); tris.Add(i); tris.Add(i + 2); tris.Add(i + 3); }
|
||||
else { tris.Add(i); tris.Add(i + 2); tris.Add(i + 1); tris.Add(i); tris.Add(i + 3); tris.Add(i + 2); }
|
||||
}
|
||||
|
||||
// ───────────────────────── talking to it ─────────────────────────
|
||||
|
||||
public string Prompt
|
||||
{
|
||||
get
|
||||
{
|
||||
string where = Target.Value < Stations.Count ? Stations.Name(Target.Value) : "?";
|
||||
var def = GameDefs.Piece(PieceId.Train);
|
||||
if (Laying)
|
||||
{
|
||||
string s = Loc.F("{0}: laying track to {1}, {2} of {3} m", def.name, where, Mathf.RoundToInt(Laid.Value), Mathf.RoundToInt(_length));
|
||||
return Laid.Value < Lead ? s + " · " + Loc.T("E: another station") : s;
|
||||
}
|
||||
if (RouteDone) return Loc.F("{0}: the line to {1} is mown clean as far as it reaches. An upgrade reaches further.", def.name, where);
|
||||
return Loc.F("{0}: running to {1} and back, cutting {2} m out either side, {3} on board", def.name, where, Mathf.RoundToInt(Inner + Arm), GameDefs.Kilos(Hopper.Value));
|
||||
}
|
||||
}
|
||||
|
||||
public bool CanInteract => Laying && Laid.Value < Lead;
|
||||
|
||||
public void Interact() => OtherWayRpc();
|
||||
|
||||
[Rpc(SendTo.Server)]
|
||||
void OtherWayRpc()
|
||||
{
|
||||
if (!Laying || Laid.Value >= Lead) return;
|
||||
Laid.Value = 0f;
|
||||
At.Value = 0f;
|
||||
Target.Value = Pick(Target.Value);
|
||||
}
|
||||
|
||||
public float[] State
|
||||
{
|
||||
get => new[] { Target.Value, Laid.Value, At.Value, Runs.Value, Hopper.Value };
|
||||
set
|
||||
{
|
||||
if (value == null || value.Length < 5 || !IsServer) return;
|
||||
if (value[0] < Stations.Count) Target.Value = (byte)value[0];
|
||||
Laid.Value = value[1];
|
||||
At.Value = value[2];
|
||||
Runs.Value = (int)value[3];
|
||||
Hopper.Value = value[4];
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
291
Assets/Scripts/Gameplay/Vehicle.Auto.cs
Normal file
291
Assets/Scripts/Gameplay/Vehicle.Auto.cs
Normal file
@ -0,0 +1,291 @@
|
||||
using System.Collections.Generic;
|
||||
using Unity.Netcode;
|
||||
using UnityEngine;
|
||||
|
||||
namespace GrassCutter
|
||||
{
|
||||
/// <summary>
|
||||
/// The autopilot, bought for a machine at the garage. C hands the machine over and the driver steps off: it mows a field
|
||||
/// round where it was let go in long strokes (every other row first, so it has room to turn), then the fields round
|
||||
/// that one, ring by ring. With the hopper full it drives to the nearest place to unload (a garage pad, an unload bay or
|
||||
/// the base yard), empties it and comes back to the stroke it left. Getting in takes it back. The host drives it.
|
||||
/// </summary>
|
||||
public partial class Vehicle
|
||||
{
|
||||
public enum AutoJob : byte { Off, Mowing, Unloading, Done }
|
||||
|
||||
/// <summary>What the autopilot is doing (the host writes it).</summary>
|
||||
public readonly NetworkVariable<byte> Auto = new NetworkVariable<byte>();
|
||||
public AutoJob Job => (AutoJob)Auto.Value;
|
||||
public bool OnAuto => Auto.Value != (byte)AutoJob.Off;
|
||||
/// <summary>Has an autopilot, and a cutter for it to mow with.</summary>
|
||||
public bool CanAuto => GameDefs.TuneFits(kind, TuneId.Autopilot) && Level(TuneId.Autopilot) > 0;
|
||||
|
||||
/// <summary>A field is this many metres a side; it works this many rings of fields round the first.</summary>
|
||||
const float FieldSize = 34f;
|
||||
const int FieldRings = 4;
|
||||
|
||||
Vector3 _home, _homeFwd;
|
||||
/// <summary>Strokes as pairs of points on the ground: start, end, start, end...</summary>
|
||||
readonly List<Vector3> _strokes = new List<Vector3>();
|
||||
int _next, _field;
|
||||
float _stuck, _back, _backSteer, _lastSteer;
|
||||
int _stuckTimes;
|
||||
Vector3 _unloadAt;
|
||||
|
||||
static readonly List<Vector2Int> s_fields = new List<Vector2Int>();
|
||||
static readonly Collider[] s_block = new Collider[4];
|
||||
|
||||
/// <summary>The driver hands over: they step off, it carries on.</summary>
|
||||
[Rpc(SendTo.Server)]
|
||||
void AutoRpc(RpcParams rpc = default)
|
||||
{
|
||||
if (Driver.Value != rpc.Receive.SenderClientId || !CanAuto) return;
|
||||
ServerEject();
|
||||
ServerStartAuto(transform.position, transform.forward);
|
||||
}
|
||||
|
||||
/// <summary>Host: start working round this spot, the strokes running this way.</summary>
|
||||
public void ServerStartAuto(Vector3 home, Vector3 forward)
|
||||
{
|
||||
if (!IsServer || !CanAuto) return;
|
||||
var up = Planet.Up(home);
|
||||
_home = home;
|
||||
_homeFwd = Vector3.ProjectOnPlane(forward, up).normalized;
|
||||
if (_homeFwd.sqrMagnitude < 0.5f) _homeFwd = Vector3.ProjectOnPlane(Vector3.forward, up).normalized;
|
||||
_field = -1;
|
||||
_strokes.Clear();
|
||||
_next = 0;
|
||||
_stuckTimes = 0;
|
||||
Auto.Value = (byte)AutoJob.Mowing;
|
||||
if (!NextField()) Auto.Value = (byte)AutoJob.Done;
|
||||
}
|
||||
|
||||
float _resumeAt;
|
||||
|
||||
/// <summary>Host, loading a save: back to work once the world round it has been built.</summary>
|
||||
public void ServerResumeAuto(Vector3 home, Vector3 forward)
|
||||
{
|
||||
_home = home;
|
||||
_homeFwd = forward;
|
||||
_resumeAt = Time.time + 4f;
|
||||
}
|
||||
|
||||
void AutoResume()
|
||||
{
|
||||
if (_resumeAt <= 0f || Time.time < _resumeAt) return;
|
||||
_resumeAt = 0f;
|
||||
if (!HasDriver) ServerStartAuto(_home, _homeFwd);
|
||||
}
|
||||
|
||||
/// <summary>Where the autopilot was started, for the save (Off: it wasn't).</summary>
|
||||
public void AutoState(out int job, out Vector3 home, out Vector3 fwd)
|
||||
{
|
||||
job = Auto.Value;
|
||||
home = _home;
|
||||
fwd = _homeFwd;
|
||||
}
|
||||
|
||||
string AutoPrompt => Job == AutoJob.Unloading ? Loc.T("autopilot: off to unload")
|
||||
: Job == AutoJob.Done ? Loc.T("autopilot: nothing left to mow round here")
|
||||
: Loc.T("autopilot: mowing");
|
||||
|
||||
// ───────────────────────── planning ─────────────────────────
|
||||
|
||||
static void Fields()
|
||||
{
|
||||
if (s_fields.Count > 0) return;
|
||||
s_fields.Add(Vector2Int.zero);
|
||||
for (int r = 1; r <= FieldRings; r++)
|
||||
{
|
||||
// round the ring: along the top, down the right, back along the bottom, up the left
|
||||
for (int x = -r; x < r; x++) s_fields.Add(new Vector2Int(x, r));
|
||||
for (int z = r; z > -r; z--) s_fields.Add(new Vector2Int(r, z));
|
||||
for (int x = r; x > -r; x--) s_fields.Add(new Vector2Int(x, -r));
|
||||
for (int z = -r; z < r; z++) s_fields.Add(new Vector2Int(-r, z));
|
||||
}
|
||||
}
|
||||
|
||||
/// <summary>Plans the next field that has grass on it. False when there is none left.</summary>
|
||||
bool NextField()
|
||||
{
|
||||
Fields();
|
||||
_strokes.Clear();
|
||||
_next = 0;
|
||||
while (++_field < s_fields.Count)
|
||||
{
|
||||
Plan(s_fields[_field]);
|
||||
if (_strokes.Count > 0) return true;
|
||||
}
|
||||
return false;
|
||||
}
|
||||
|
||||
void Plan(Vector2Int f)
|
||||
{
|
||||
var up = Planet.Up(_home);
|
||||
var fwd = _homeFwd;
|
||||
var right = Vector3.Cross(up, fwd);
|
||||
var centre = _home + right * (f.x * FieldSize) + fwd * (f.y * FieldSize);
|
||||
float w = Mathf.Max(0.8f, CutWidth * 0.85f);
|
||||
int rows = Mathf.Max(1, Mathf.CeilToInt(FieldSize / w));
|
||||
// every other row out, the rest on the way back: a turn is two strips wide, not one
|
||||
var order = new List<int>();
|
||||
for (int i = 0; i < rows; i += 2) order.Add(i);
|
||||
for (int i = rows - 1 - (rows % 2 == 0 ? 0 : 1); i >= 1; i -= 2) order.Add(i);
|
||||
bool flip = false;
|
||||
foreach (int i in order)
|
||||
{
|
||||
float u = -FieldSize * 0.5f + (i + 0.5f) * w;
|
||||
var a = centre + right * u - fwd * (FieldSize * 0.5f);
|
||||
var b = centre + right * u + fwd * (FieldSize * 0.5f);
|
||||
if (flip) (a, b) = (b, a);
|
||||
if (Stroke(a, b)) flip = !flip;
|
||||
}
|
||||
}
|
||||
|
||||
/// <summary>Adds the stretches of a row that are free to drive and have grass on them. True if any were.</summary>
|
||||
bool Stroke(Vector3 a, Vector3 b)
|
||||
{
|
||||
const float Step = 1.5f;
|
||||
int n = Mathf.Max(2, Mathf.CeilToInt(Vector3.Distance(a, b) / Step));
|
||||
bool any = false;
|
||||
int start = -1, grass = 0;
|
||||
Vector3 first = default, last = default;
|
||||
for (int k = 0; k <= n; k++)
|
||||
{
|
||||
var p = Planet.Surface(Vector3.Lerp(a, b, k / (float)n));
|
||||
bool free = Free(p);
|
||||
if (free)
|
||||
{
|
||||
if (start < 0) { start = k; first = p; grass = 0; }
|
||||
last = p;
|
||||
if (MowMap.Yield(p) > 0.3f) grass++;
|
||||
}
|
||||
if (!free || k == n)
|
||||
{
|
||||
if (start >= 0 && grass >= 2 && Vector3.Distance(first, last) > 3f)
|
||||
{
|
||||
_strokes.Add(first);
|
||||
_strokes.Add(last);
|
||||
any = true;
|
||||
}
|
||||
start = -1;
|
||||
}
|
||||
}
|
||||
return any;
|
||||
}
|
||||
|
||||
/// <summary>Open ground: no deck, rock, building or scenery in the way.</summary>
|
||||
bool Free(Vector3 p)
|
||||
{
|
||||
if (Ts && Ts.OnDeck(p)) return false;
|
||||
if (Ground.Instance && Ground.Instance.RockAt(p)) return false;
|
||||
var up = Planet.Up(p);
|
||||
int n = Physics.OverlapSphereNonAlloc(p + up * 1.3f, width * 0.5f + 1f, s_block, (1 << Layers.Default) | (1 << Layers.Build), QueryTriggerInteraction.Ignore);
|
||||
for (int i = 0; i < n; i++)
|
||||
if (s_block[i] && !s_block[i].transform.IsChildOf(transform)) return false;
|
||||
return true;
|
||||
}
|
||||
|
||||
/// <summary>The nearest place to empty the hopper: a pad (garage, unload bay) or the base yard.</summary>
|
||||
bool FindUnload(out Vector3 at)
|
||||
{
|
||||
at = default;
|
||||
float best = float.MaxValue;
|
||||
var p = transform.position;
|
||||
foreach (var s in SiloPiece.Pads)
|
||||
{
|
||||
if (!s || !s.IsSpawned) continue;
|
||||
float d = (s.PadSpot - p).sqrMagnitude;
|
||||
if (d < best) { best = d; at = s.PadSpot; }
|
||||
}
|
||||
if (!s_dock) { var dz = GameObject.Find("DockZone"); s_dock = dz ? dz.transform : null; }
|
||||
if (s_dock && (s_dock.position - p).sqrMagnitude < best) { best = (s_dock.position - p).sqrMagnitude; at = s_dock.position; }
|
||||
return best < float.MaxValue;
|
||||
}
|
||||
|
||||
// ───────────────────────── driving (host) ─────────────────────────
|
||||
|
||||
/// <summary>The stick the autopilot holds this physics step.</summary>
|
||||
Vector2 AutoInput(float dt)
|
||||
{
|
||||
var p = transform.position;
|
||||
var up = Planet.Up(p);
|
||||
var job = Job;
|
||||
if (job == AutoJob.Off || job == AutoJob.Done) return Vector2.zero;
|
||||
|
||||
if (job == AutoJob.Mowing && Tank.Value >= Capacity - 0.5f)
|
||||
{
|
||||
if (FindUnload(out _unloadAt)) { Auto.Value = (byte)(job = AutoJob.Unloading); _stuckTimes = 0; }
|
||||
else { Auto.Value = (byte)AutoJob.Done; return Vector2.zero; }
|
||||
}
|
||||
if (job == AutoJob.Unloading)
|
||||
{
|
||||
// on the pad: stand still until it's empty, then back to work
|
||||
if (Unloading) return Vector2.zero;
|
||||
if (Tank.Value <= 0.1f) { Auto.Value = (byte)AutoJob.Mowing; _stuckTimes = 0; return Vector2.zero; }
|
||||
}
|
||||
|
||||
Vector3 goal;
|
||||
if (job == AutoJob.Unloading) goal = _unloadAt;
|
||||
else
|
||||
{
|
||||
if (_next >= _strokes.Count && !NextField())
|
||||
{
|
||||
// all done round here: what's in the hopper goes home first
|
||||
if (Tank.Value > 0.1f && FindUnload(out _unloadAt)) Auto.Value = (byte)AutoJob.Unloading;
|
||||
else Auto.Value = (byte)AutoJob.Done;
|
||||
return Vector2.zero;
|
||||
}
|
||||
goal = _strokes[_next];
|
||||
}
|
||||
|
||||
var to = Vector3.ProjectOnPlane(goal - p, up);
|
||||
float dist = to.magnitude;
|
||||
if (job == AutoJob.Mowing && dist < 1.6f)
|
||||
{
|
||||
_next++;
|
||||
_stuckTimes = 0;
|
||||
return new Vector2(_lastSteer, 0.4f);
|
||||
}
|
||||
|
||||
var fwd = Vector3.ProjectOnPlane(transform.forward, up).normalized;
|
||||
float ang = Vector3.SignedAngle(fwd, to, up);
|
||||
float speed = Vector3.ProjectOnPlane(Body.linearVelocity, up).magnitude;
|
||||
|
||||
// backing out of something it ran into
|
||||
if (_back > 0f)
|
||||
{
|
||||
_back -= dt;
|
||||
return new Vector2(_backSteer, -1f);
|
||||
}
|
||||
|
||||
float steer = Mathf.Clamp(ang / 30f, -1f, 1f);
|
||||
// mowing it keeps to a pace it can turn at; on the way somewhere far it goes faster
|
||||
float cap = job == AutoJob.Mowing ? 0.7f : dist > 20f ? 1f : 0.6f;
|
||||
float thr = cap * Mathf.Lerp(1f, 0.4f, Mathf.Clamp01(Mathf.Abs(ang) / 90f));
|
||||
if (dist < 6f) thr = Mathf.Min(thr, 0.3f + dist * 0.08f);
|
||||
_lastSteer = steer;
|
||||
|
||||
if (speed < 0.5f && thr > 0.2f)
|
||||
{
|
||||
_stuck += dt;
|
||||
if (_stuck > 2.2f)
|
||||
{
|
||||
_stuck = 0f;
|
||||
_back = 1.5f;
|
||||
_backSteer = ang > 0f ? -1f : 1f;
|
||||
if (++_stuckTimes >= 4)
|
||||
{
|
||||
// can't get there: the next stroke, or another way home
|
||||
_stuckTimes = 0;
|
||||
if (job == AutoJob.Mowing) _next += (_next % 2 == 0) ? 2 : 1;
|
||||
else Auto.Value = (byte)AutoJob.Done;
|
||||
}
|
||||
}
|
||||
}
|
||||
else _stuck = 0f;
|
||||
return new Vector2(steer, thr);
|
||||
}
|
||||
}
|
||||
}
|
||||
@ -11,7 +11,7 @@ namespace GrassCutter
|
||||
/// while driving and unloads at a garage pad. The pickup carries bundles on its bed instead.
|
||||
/// </summary>
|
||||
[RequireComponent(typeof(Rigidbody))]
|
||||
public class Vehicle : NetworkBehaviour, IInteractable
|
||||
public partial class Vehicle : NetworkBehaviour, IInteractable
|
||||
{
|
||||
public static readonly List<Vehicle> All = new List<Vehicle>();
|
||||
public const ulong Nobody = ulong.MaxValue;
|
||||
@ -109,7 +109,7 @@ namespace GrassCutter
|
||||
|
||||
// ───────────────────────── seat ─────────────────────────
|
||||
|
||||
public string Prompt => HasDriver ? null : Def.bed > 0 ? Loc.F("Ride the {0} ({1} of {2} bundles, E with a bundle loads it)", Def.name, Bed.Count, Def.bed) : Loc.F("Ride the {0} ({1} / {2})", Def.name, GameDefs.Kilos(Tank.Value), GameDefs.Kilos(Capacity));
|
||||
public string Prompt => HasDriver ? null : OnAuto ? Loc.F("Take over the {0} ({1}, {2} / {3})", Def.name, AutoPrompt, GameDefs.Kilos(Tank.Value), GameDefs.Kilos(Capacity)) : Def.bed > 0 ? Loc.F("Ride the {0} ({1} of {2} bundles, E with a bundle loads it)", Def.name, Bed.Count, Def.bed) : Loc.F("Ride the {0} ({1} / {2})", Def.name, GameDefs.Kilos(Tank.Value), GameDefs.Kilos(Capacity));
|
||||
public bool CanInteract => !HasDriver;
|
||||
|
||||
public void Interact()
|
||||
@ -124,6 +124,9 @@ namespace GrassCutter
|
||||
if (HasDriver || RollingOut) return;
|
||||
foreach (var v in All) if (v != this && v.Driver.Value == who) return;
|
||||
Driver.Value = who;
|
||||
// getting in takes it back from the autopilot
|
||||
Auto.Value = (byte)AutoJob.Off;
|
||||
_resumeAt = 0f;
|
||||
if (OwnerClientId != who) NetworkObject.ChangeOwnership(who);
|
||||
}
|
||||
|
||||
@ -253,7 +256,13 @@ namespace GrassCutter
|
||||
Sfx.Play("ui_open");
|
||||
UIRoot.I?.OpenGarage(near.GetComponent<Garage>(), kind);
|
||||
}
|
||||
if (Ctl.CruisePressed && Level(TuneId.Cruise) > 0) _cruise = !_cruise;
|
||||
if (Ctl.CruisePressed && CanAuto)
|
||||
{
|
||||
AutoRpc();
|
||||
Sfx.Play("ui_click", 0.8f, 1.2f);
|
||||
Hud.Toast(Loc.F("Autopilot on: the {0} mows round here and unloads itself. Hop back in to take over.", Def.name), Hud.ToastKind.Info);
|
||||
}
|
||||
else if (Ctl.CruisePressed && Level(TuneId.Cruise) > 0) _cruise = !_cruise;
|
||||
if (Ctl.MovePressed && Def.bed > 0) TipRpc();
|
||||
}
|
||||
else _cruise = false;
|
||||
@ -272,6 +281,13 @@ namespace GrassCutter
|
||||
if (!IsSpawned || !IsOwner || Body.isKinematic) return;
|
||||
bool driving = LocalDriving;
|
||||
var input = driving ? Ctl.Move : Vector2.zero;
|
||||
// the host drives a machine on autopilot
|
||||
bool auto = false;
|
||||
if (IsServer && !HasDriver)
|
||||
{
|
||||
AutoResume();
|
||||
if (OnAuto) { input = AutoInput(Time.fixedDeltaTime); auto = true; }
|
||||
}
|
||||
float boost = driving && Ctl.Sprint ? GameDefs.BoostMul(Level(TuneId.Turbo)) : 1f;
|
||||
if (input.y < -0.1f) _cruise = false;
|
||||
float throttle = _cruise && input.y < 0.1f ? 1f : input.y;
|
||||
@ -329,7 +345,7 @@ namespace GrassCutter
|
||||
var tq = Vector3.Cross(transform.up, lean.normalized) * 18f - Body.angularVelocity * 2.5f;
|
||||
Body.AddTorque(Vector3.ProjectOnPlane(tq, up) * Body.mass, ForceMode.Force);
|
||||
}
|
||||
if (driving && Throttle.Value != throttle) Throttle.Value = throttle;
|
||||
if ((driving || auto) && Throttle.Value != throttle) Throttle.Value = throttle;
|
||||
|
||||
// mow under the cutter: what the header sweeps goes in the hopper
|
||||
bool mowing = false;
|
||||
@ -338,12 +354,12 @@ namespace GrassCutter
|
||||
var ip = intake ? intake.position : transform.position + fwd * length * 0.5f;
|
||||
bool overMeadow = Planet.Altitude(ip) < 1.2f && !(Ground.Instance && Ground.Instance.RockAt(ip));
|
||||
bool onDeck = Ts && Ts.OnDeck(ip);
|
||||
if (overMeadow && !onDeck && Tank.Value < Capacity && driving)
|
||||
if (overMeadow && !onDeck && Tank.Value < Capacity && (driving || auto))
|
||||
{
|
||||
mowing = true;
|
||||
float kg = MowMap.Cut(_hasCut ? _lastCut : ip, ip, CutWidth, blade: true) * GameDefs.GrassDensity;
|
||||
Tank.Value = Mathf.Min(Capacity, Tank.Value + kg);
|
||||
if (Tank.Value >= Capacity - 0.01f) { Sfx.Play("tank_full", 0.8f); Assistant.Say("asst_hopper"); Hud.Toast(Loc.F("{0} hopper full: unload at the base yard, a garage pad or an Unload Bay (follow the UNLOAD markers)", Def.name), Hud.ToastKind.Warn); }
|
||||
if (Tank.Value >= Capacity - 0.01f && driving) { Sfx.Play("tank_full", 0.8f); Assistant.Say("asst_hopper"); Hud.Toast(Loc.F("{0} hopper full: unload at the base yard, a garage pad or an Unload Bay (follow the UNLOAD markers)", Def.name), Hud.ToastKind.Warn); }
|
||||
_lastCut = ip;
|
||||
}
|
||||
_hasCut = mowing;
|
||||
@ -352,7 +368,7 @@ namespace GrassCutter
|
||||
|
||||
// unload: in the yard at the base it's paid as it comes off, on a garage's pad or an unload bay it fills the bin
|
||||
var pad = Tank.Value > 0.1f ? SiloPiece.PadUnder(transform.position) : null;
|
||||
if (Def.bales && driving) Bale(dt);
|
||||
if (Def.bales && (driving || auto)) Bale(dt);
|
||||
Unloading = Tank.Value > 0.1f && (pad || NearDock());
|
||||
if (Tank.Value > 0.1f && (pad || NearDock()) && Ts)
|
||||
{
|
||||
|
||||
@ -702,7 +702,7 @@ namespace GrassCutter
|
||||
_frame = _heading;
|
||||
Sfx.Play("build_place", 0.5f, 1.3f);
|
||||
Assistant.Say("asst_drive");
|
||||
Hud.Toast(Loc.T("WASD to drive · SHIFT boost · R chase view · E to hop off"), Hud.ToastKind.Info);
|
||||
Hud.Toast(v.CanAuto ? Loc.T("WASD to drive · SHIFT boost · R chase view · E to hop off · C autopilot") : Loc.T("WASD to drive · SHIFT boost · R chase view · E to hop off"), Hud.ToastKind.Info);
|
||||
}
|
||||
|
||||
void ExitVehicle()
|
||||
|
||||
@ -6,7 +6,7 @@ using UnityEngine.UIElements;
|
||||
namespace GrassCutter
|
||||
{
|
||||
/// <summary>
|
||||
/// The upgrade matrix as node graphs: the GreenHaul console shows CONTAINERS · CUTTING · SUIT · LOGISTICS · ECONOMY,
|
||||
/// The upgrade matrix as node graphs: the GreenHaul console shows CONTAINERS · CUTTING · SUIT · LOGISTICS · ECONOMY · AUTOMATION,
|
||||
/// each branch growing out of the free Earth Uplink, the garage shows the FLEET. Click a node to inspect it, buy it from
|
||||
/// the shared crew wallet.
|
||||
/// </summary>
|
||||
@ -15,7 +15,7 @@ namespace GrassCutter
|
||||
public VisualElement Card { get; }
|
||||
readonly Label _money, _installs;
|
||||
readonly Action _close;
|
||||
public static readonly PerkTree[] TerminalTrees = { PerkTree.Containers, PerkTree.Cutting, PerkTree.Suit, PerkTree.Logistics, PerkTree.Economy };
|
||||
public static readonly PerkTree[] TerminalTrees = { PerkTree.Containers, PerkTree.Cutting, PerkTree.Suit, PerkTree.Logistics, PerkTree.Economy, PerkTree.Automation };
|
||||
readonly PerkTree[] _trees;
|
||||
bool Hub => _trees == TerminalTrees;
|
||||
int TreeCount => _trees.Length;
|
||||
@ -33,11 +33,11 @@ namespace GrassCutter
|
||||
static int MaxRow { get { int m = 0; foreach (var d in GameDefs.Perks) m = Mathf.Max(m, d.row); return m; } }
|
||||
static readonly float CanvasW = PadX * 2f + ColW * (MaxCol + 1), CanvasH = PadY + RowH * (MaxRow + 1) + Node + 64f;
|
||||
|
||||
static readonly string[] TreeNames = { Loc.N("CONTAINERS"), Loc.N("CUTTING"), Loc.N("SUIT"), Loc.N("LOGISTICS"), Loc.N("ECONOMY"), Loc.N("FLEET") };
|
||||
static readonly string[] TreeNames = { Loc.N("CONTAINERS"), Loc.N("CUTTING"), Loc.N("SUIT"), Loc.N("LOGISTICS"), Loc.N("ECONOMY"), Loc.N("AUTOMATION") };
|
||||
static readonly Color[] TreeColors =
|
||||
{
|
||||
new Color(0.9f, 0.72f, 0.24f), new Color(0.45f, 0.8f, 0.2f), new Color(0.85f, 0.75f, 0.4f), new Color(1f, 0.8f, 0.25f),
|
||||
new Color(0.25f, 0.7f, 0.45f), new Color(0.75f, 0.45f, 0.25f),
|
||||
new Color(0.25f, 0.7f, 0.45f), new Color(0.3f, 0.66f, 0.86f),
|
||||
};
|
||||
|
||||
TeamState Ts => TeamState.Instance;
|
||||
|
||||
@ -18,12 +18,29 @@ namespace GrassCutter
|
||||
public static string Tag(Difficulty d) => Loc.T(d == Difficulty.Mommy ? Loc.N("EASY") : d == Difficulty.HoldMyBeer ? Loc.N("NORMAL") : Loc.N("EXTRA HARD"));
|
||||
|
||||
public static string Blurb(Difficulty d) => Loc.T(
|
||||
d == Difficulty.Mommy ? Loc.N("A planet a third the size, with sectors to match. Earth can wait a little.")
|
||||
: d == Difficulty.HoldMyBeer ? Loc.N("Half the planet, half-size sectors. Still a lot of lawn.")
|
||||
: Loc.N("The whole of Herbaria-7, full-size sectors, every blade of it."));
|
||||
d == Difficulty.Mommy ? Loc.N("A sixth of the big planet, sectors to match. Earth can wait a little.")
|
||||
: d == Difficulty.HoldMyBeer ? Loc.N("A third of the big planet, smaller sectors. Still a lot of lawn.")
|
||||
: Loc.N("The big planet: the whole of Herbaria-7, every blade of it."));
|
||||
|
||||
/// <summary>
|
||||
/// Which set of sizes a save is on. 0: the first one (radius 1, 1/2, 1/3 of the whole planet), every save from
|
||||
/// before the planets shrank; they keep their ball, the pieces on it stand where they stood. 1: by area, the hard
|
||||
/// one half the whole planet, normal a third of that, easy a sixth.
|
||||
/// </summary>
|
||||
public const int NewGen = 1;
|
||||
|
||||
/// <summary>The planet's radius against the whole one.</summary>
|
||||
public static float Scale(Difficulty d) => d == Difficulty.Mommy ? 1f / 3f : d == Difficulty.HoldMyBeer ? 0.5f : 1f;
|
||||
public static float Scale(Difficulty d, int gen) => gen >= 1
|
||||
? (d == Difficulty.Mommy ? 0.288675f : d == Difficulty.HoldMyBeer ? 0.408248f : 0.707107f)
|
||||
: (d == Difficulty.Mommy ? 1f / 3f : d == Difficulty.HoldMyBeer ? 0.5f : 1f);
|
||||
|
||||
/// <summary>The size set the world is built on right now.</summary>
|
||||
public static int Gen { get; private set; }
|
||||
|
||||
/// <summary>Difficulty and size set in one byte, for the wire.</summary>
|
||||
public static byte Wire => (byte)((int)Current | (Gen << 4));
|
||||
|
||||
public static void ApplyWire(byte b) => Apply((Difficulty)(b & 15), b >> 4);
|
||||
|
||||
/// <summary>What the next new save starts on: set by the menu (and `-difficulty 0..2` for the dev bots).</summary>
|
||||
public static Difficulty Chosen = Difficulty.Hazard;
|
||||
@ -32,12 +49,14 @@ namespace GrassCutter
|
||||
public static Difficulty Current { get; private set; } = Difficulty.Hazard;
|
||||
|
||||
/// <summary>Builds the world on the ball for this difficulty, if it isn't on it already.</summary>
|
||||
public static void Apply(Difficulty d)
|
||||
public static void Apply(Difficulty d, int gen)
|
||||
{
|
||||
if (d != Difficulty.Mommy && d != Difficulty.HoldMyBeer) d = Difficulty.Hazard;
|
||||
if (d == Current) return;
|
||||
gen = gen >= 1 ? 1 : 0;
|
||||
if (d == Current && gen == Gen) return;
|
||||
Current = d;
|
||||
Planet.Rescale(GameDefs.PlanetRadius * Scale(d));
|
||||
Gen = gen;
|
||||
Planet.Rescale(GameDefs.PlanetRadius * Scale(d, gen));
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
@ -18,7 +18,7 @@ namespace GrassCutter
|
||||
public const int Res = 128;
|
||||
/// <summary>The last scraps of a sector this nearly done go with the stroke that got it there.</summary>
|
||||
// the last few scraps (behind rocks, along the seams) go by themselves: no hunting for the final percent
|
||||
const float DoneAt = 0.97f;
|
||||
const float DoneAt = 0.93f;
|
||||
const int MaxStampsPerCut = 28, MaxOpen = 300;
|
||||
/// <summary>Less than this left in a cell is not worth a row of its own.</summary>
|
||||
const ushort Scrap = 120;
|
||||
|
||||
Reference in New Issue
Block a user