- Mowbot keeps its heading apart from the drawn pose: a flyer's lean and sway were fed back each frame and rolled it over. - Drone pads looked through every loose bundle, testing every belt end, for each idle drone every frame (43 ms on a 1500-bundle farm): distance first, and a 1.5 s pause after finding nothing. - Saves are written, laid out and compressed off the main thread; backups go in the same queue (an autosave froze the game ~50 ms every 30 s). - Robots tick on staggered frames. - -demoperf N profiles save slot N; -demobots logs the Sky Mower's tilt. On the player's save: frames over 25 ms went from 144 to 0 in 40 s, worst frame 74 ms -> 22 ms. Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
61 lines
3.3 KiB
C#
61 lines
3.3 KiB
C#
using System.Collections;
|
|
using System.Linq;
|
|
using UnityEngine;
|
|
|
|
namespace GrassCutter
|
|
{
|
|
public partial class DemoBot
|
|
{
|
|
/// <summary>
|
|
/// -demobots: a Robot Mk I, a Sky Mower and a Drone Pad, none of them with a belt. All three should keep earning on
|
|
/// their own: the robot and the sky mower widen their rings once they are done, the pad ships what its drones bring.
|
|
/// </summary>
|
|
IEnumerator Bots()
|
|
{
|
|
TeamState.DeleteSave();
|
|
yield return new WaitForSeconds(2f);
|
|
NetSession.Instance.HostLocal();
|
|
while (!Me || !Ts) yield return null;
|
|
yield return new WaitForSeconds(3f);
|
|
Clock(11f);
|
|
|
|
var robotAt = Soil17(140f, -40f);
|
|
var skyAt = Soil17(-120f, 60f);
|
|
var padAt = Soil17(40f, 150f);
|
|
Quaternion Face(Vector3 p) => Quaternion.LookRotation(Vector3.ProjectOnPlane(Vector3.forward, Planet.Up(p)), Planet.Up(p));
|
|
var robot = Spawner.Instance.SpawnPiece(PieceId.RobotI, robotAt, Face(robotAt), robotAt, true).GetComponent<RobotDock>();
|
|
var sky = Spawner.Instance.SpawnPiece(PieceId.SkyMower, skyAt, Face(skyAt), skyAt, true).GetComponent<RobotDock>();
|
|
var pad = Spawner.Instance.SpawnPiece(PieceId.DronePad, padAt, Face(padAt), padAt, true).GetComponent<DronePad>();
|
|
for (int i = 0; i < 9; i++)
|
|
{
|
|
var a = Quaternion.AngleAxis(i * 40f, Planet.Up(padAt)) * Vector3.ProjectOnPlane(Vector3.forward, Planet.Up(padAt)).normalized * (12f + i * 6f);
|
|
Spawner.Instance.SpawnCargo(CargoKind.Grass, Planet.Surface(padAt + a) + Planet.Up(padAt + a) * 0.6f, Quaternion.identity, Vector3.zero);
|
|
}
|
|
yield return new WaitForSeconds(1f);
|
|
Log($"bots built: robot {(robot ? "ok" : "MISSING")}, sky {(sky ? "ok" : "MISSING")}, pad {(pad ? "ok" : "MISSING")}");
|
|
if (!robot || !sky || !pad) yield break;
|
|
|
|
double money = Ts.Money.Value;
|
|
Mowbot.Haste = 25f;
|
|
yield return new WaitForSeconds(3f);
|
|
var skyUp = Planet.Up(sky.Shown);
|
|
yield return Look("bot01_sky_mower", sky.Shown + skyUp * 5f + Vector3.ProjectOnPlane(Vector3.right, skyUp).normalized * 9f, sky.Shown, 0.2f);
|
|
yield return Look("bot02_robot", robot.Shown + Planet.Up(robot.Shown) * 3f + Vector3.right * 4f, robot.Shown, 0.2f);
|
|
for (int k = 1; k <= 6; k++)
|
|
{
|
|
yield return new WaitForSeconds(15f);
|
|
Log($"t+{k * 15} s at {Mowbot.Haste:0}x: earned {Ts.Money.Value - money:0}, closed {Ts.Closed.Value}");
|
|
Log($" robot: {robot.Prompt}");
|
|
Log($" sky: {sky.Prompt} alt {Planet.Altitude(sky.ShownBody.position) - Planet.Altitude(sky.Shown):0.0} m, tilt {Vector3.Angle(sky.ShownBody.up, Planet.Up(sky.Shown)):0} deg");
|
|
Log($" pad: {pad.Prompt}, delivered {pad.Delivered}");
|
|
}
|
|
skyUp = Planet.Up(sky.Shown);
|
|
yield return Look("bot03_sky_late", sky.Shown + skyUp * 7f + Vector3.ProjectOnPlane(Vector3.forward, skyUp).normalized * -12f, sky.Shown, 0.2f);
|
|
yield return Look("bot04_pad", padAt + Planet.Up(padAt) * 6f + Vector3.right * 8f, padAt, 0.2f);
|
|
Mowbot.Haste = 1f;
|
|
Log("bots done");
|
|
Application.Quit();
|
|
}
|
|
}
|
|
}
|