Команда necrogrow: подрастить растения вокруг игрока (для проверки грядок духа урны)

Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
This commit is contained in:
AlexCube
2026-10-16 20:10:55 +03:00
co-authored by Claude Opus 5.5
parent 7e93e19c5f
commit d7c80341d2
+93
View File
@@ -0,0 +1,93 @@
using System.Collections.Generic;
using UnityEngine;
using UnityEngine.Scripting;
namespace NecromancerTome
{
/// <summary>
/// Подрастить растения вокруг игрока (16.10, для проверки работы духа урны на грядках): каждое растущее растение
/// (BlockPlantGrowing) в радиусе переходит на следующие стадии родным BlockPlantGrowing.ForceNextGrowStage.
/// </summary>
[Preserve]
public class ConsoleCmdNecroGrow : ConsoleCmdAbstract
{
public override bool IsExecuteOnClient => false;
public override bool AllowedInMainMenu => false;
public override string[] getCommands()
{
return new string[] { "necrogrow" };
}
public override string getDescription()
{
return "Necromancer's Tome: grow the plants around you by one or more stages (testing).";
}
public override string getHelp()
{
return "necrogrow [radius] [stages] - advance every growing plant within radius (default 8) by stages (default 9 = ripe)";
}
public override void Execute(List<string> _params, CommandSenderInfo _senderInfo)
{
SdtdConsole con = SingletonMonoBehaviour<SdtdConsole>.Instance;
World world = GameManager.Instance.World;
EntityPlayer player = null;
if (_senderInfo.RemoteClientInfo != null)
{
world.Players.dict.TryGetValue(_senderInfo.RemoteClientInfo.entityId, out player);
}
else
{
player = world.GetPrimaryPlayer();
}
if (player == null)
{
con.Output("necrogrow: no player");
return;
}
int radius = 8, stages = 9;
if (_params.Count >= 1)
{
int.TryParse(_params[0], out radius);
}
if (_params.Count >= 2)
{
int.TryParse(_params[1], out stages);
}
radius = Mathf.Clamp(radius, 1, 32);
Vector3i c = World.worldToBlockPos(player.GetPosition());
int plants = 0, steps = 0;
for (int dx = -radius; dx <= radius; dx++)
{
for (int dz = -radius; dz <= radius; dz++)
{
for (int dy = -4; dy <= 4; dy++)
{
Vector3i p = new Vector3i(c.x + dx, c.y + dy, c.z + dz);
BlockValue bv = world.GetBlock(p);
if (bv.ischild || !(bv.Block is BlockPlantGrowing))
{
continue;
}
plants++;
for (int s = 0; s < stages && bv.Block is BlockPlantGrowing g && !g.nextPlant.isair; s++)
{
BlockValue next = g.ForceNextGrowStage(world, p, bv);
if (next.type == bv.type)
{
break;
}
world.SetBlockRPC(p, next);
bv = next;
steps++;
}
}
}
}
con.Output("necrogrow: " + plants + " growing plant(s) within " + radius + ", " + steps + " stage(s) advanced");
}
}
}