Files
grass-cutters/Assets/Scripts/Gameplay/TeamState.Cheats.cs
NiemandKG d1c3761e58 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>
2026-11-06 18:44:40 +06:00

36 lines
1.2 KiB
C#

using UnityEngine;
namespace GrassCutter
{
/// <summary>Server side of the cheat console (host only): wallet and perks, no strings attached.</summary>
public partial class TeamState
{
public void ServerSetMoney(double value)
{
if (!IsServer) return;
Money.Value = System.Math.Max(0d, value);
Save();
}
/// <summary>Set a perk to a level (clamped to its max), with the same side effects as buying it.</summary>
public void ServerSetPerk(PerkId id, int level)
{
if (!IsServer || id >= PerkId.Count) return;
var def = GameDefs.Perk(id);
int was = Level(id);
level = Mathf.Clamp(level, 0, def.maxLevel);
if (level == was) return;
Perks[(int)id] = (byte)level;
if (level > was) PurchasedRpc("Cheats", def.maxLevel > 1 ? Loc.Key(def.nameEn, GameDefs.ToRoman(level)) : Loc.Key(def.nameEn));
}
/// <summary>Hand a player a tool, as if they had bought it.</summary>
public void ServerGiveTool(PlayerAgent p, ToolId t)
{
if (!IsServer || !p) return;
p.Owned.Value |= (ushort)(1 << (int)t);
SaveCrew(p);
}
}
}