using System.Collections.Generic; using UnityEngine; using UnityEngine.Scripting; namespace NecromancerTome { /// /// Подрастить растения вокруг игрока (16.10, для проверки работы духа урны на грядках): каждое растущее растение /// (BlockPlantGrowing) в радиусе переходит на следующие стадии родным BlockPlantGrowing.ForceNextGrowStage. /// [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 _params, CommandSenderInfo _senderInfo) { SdtdConsole con = SingletonMonoBehaviour.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"); } } }