Files
grass-cutters/Assets/Scripts/Core/GameBoot.cs
NiemandKG ad2154b38c Release checklist: no cheat console for players, Steam required, Steam's language wins when changed, menu links, head bob toggle
- The cheat console opens only in the editor, a development build, or with -gcdev
- Without steam_appid.txt next to the exe, a failed Steam start says so and quits instead of running offline; -nosteam only works in our own builds
- A language picked in the game's Steam properties overrides the one saved in the game, if it changed since
- Main menu: language button, Steam page (overlay, else browser), feedback (Steam discussions); "early build" and the AppID gone from the footer
- Settings > Game: head bob on/off
- The cursor stays inside the window while it's free
- -resetsettings puts every setting back as it comes out of the box

Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
2026-11-17 18:45:17 +06:00

53 lines
2.8 KiB
C#

using UnityEngine;
namespace GrassCutter
{
/// <summary>Scene entry point: warms up singletons and configures physics layers.</summary>
public class GameBoot : MonoBehaviour
{
void Awake()
{
Application.targetFrameRate = -1;
Layers.SetupCollisions();
Fx.Warmup();
_ = Sfx.I;
if (CommandLine.Has("-resetsettings")) { for (int t = 0; t <= 5; t++) GameSettings.Defaults(t); Debug.Log("[Boot] settings reset"); }
GameSettings.Apply();
if (CommandLine.Has("-resetsave")) { TeamState.DeleteSave(); Debug.Log("[Boot] save reset"); }
foreach (var d in UnityEngine.InputSystem.InputSystem.devices) Debug.Log($"[Input] device: {d.name} ({d.layout}) {d.description.product}");
}
void Start()
{
NoProbes();
// dev bots render off-screen so they can run with -batchmode without touching the user's desktop
// (-onscreen: a real window instead, for measuring what the screen really costs)
if ((CommandLine.Has("-screenshot") || CommandLine.Has("-autodemo")) && !CommandLine.Has("-onscreen"))
BotCapture.Setup(int.TryParse(CommandLine.Get("-shotw", "1600"), out var w) ? w : 1600, int.TryParse(CommandLine.Get("-shoth", "900"), out var h) ? h : 900);
if (CommandLine.Get("-screenshot") is string path) gameObject.AddComponent<AutoScreenshot>().path = path;
if (CommandLine.Get("-autodemo") is string demo) gameObject.AddComponent<DemoBot>().folder = demo;
}
/// <summary>
/// The planet has no light probes, so interpolating them for every moving thing (two thousand bundles on the belts
/// of a big farm) is work for nothing: the ambient light is the same. Off on every networked prefab and everything
/// in the scene, once at boot.
/// </summary>
static void NoProbes()
{
if (LightmapSettings.lightProbes != null && LightmapSettings.lightProbes.count > 0) return;
void Off(GameObject go)
{
if (!go) return;
foreach (var r in go.GetComponentsInChildren<Renderer>(true)) r.lightProbeUsage = UnityEngine.Rendering.LightProbeUsage.Off;
}
var nm = Unity.Netcode.NetworkManager.Singleton;
// (not in the editor: there the prefab is the asset on disk)
if (!Application.isEditor && nm && nm.NetworkConfig?.Prefabs?.Prefabs != null)
foreach (var p in nm.NetworkConfig.Prefabs.Prefabs) Off(p.Prefab);
foreach (var r in Object.FindObjectsByType<Renderer>(FindObjectsInactive.Include, FindObjectsSortMode.None))
r.lightProbeUsage = UnityEngine.Rendering.LightProbeUsage.Off;
}
}
}