ModernUO/Projects/UOContent/Engines/Spawners/Spawner.cs
Kamron Batman 866bc90d24
refactor: convert order-based linkage to v4 field-side declarations
[SerializableFieldSaveFlag]/[SerializableFieldDefault] become [SaveFlag(...)]
on the field; [SerializableFieldChanged] becomes the fieldChanged: argument of
[SerializableField]. 175 conversions across 25 files, all wire-neutral - the
migration schemas are untouched.

Co-Authored-By: Claude Fable 5 <noreply@anthropic.com>
2026-08-22 17:46:01 -07:00

70 lines
1.9 KiB
C#

using System;
using ModernUO.Serialization;
namespace Server.Engines.Spawners;
[SerializationGenerator(1)]
public partial class Spawner : BaseSpawner
{
/// <summary>
/// When true, enables proactive spiral scanning to find valid spawn positions.
/// Only relevant when SpawnPositionMode is Automatic or Enabled.
/// </summary>
private bool ShouldSerializeUseSpiralScan() => _useSpiralScan;
[SerializableField(0)]
[SaveFlag(nameof(ShouldSerializeUseSpiralScan))]
[SerializedCommandProperty(AccessLevel.Developer)]
private bool _useSpiralScan;
private bool ShouldSerializeSpawnBounds() => _spawnBounds != default;
[SerializableProperty(1)]
[SaveFlag(nameof(ShouldSerializeSpawnBounds))]
[CommandProperty(AccessLevel.Developer)]
public override Rectangle3D SpawnBounds
{
get => _spawnBounds;
set
{
_spawnBounds = value;
InvalidateProperties();
this.MarkDirty();
}
}
[Constructible(AccessLevel.Developer)]
public Spawner()
{
}
[Constructible(AccessLevel.Developer)]
public Spawner(string spawnedName) : base(spawnedName)
{
}
[Constructible(AccessLevel.Developer)]
public Spawner(
int amount,
TimeSpan minDelay,
TimeSpan maxDelay,
int team = 0,
Rectangle3D spawnBounds = default,
params ReadOnlySpan<string> spawnedNames
) : base(amount, minDelay, maxDelay, team, spawnBounds, spawnedNames)
{
}
public override Region Region => Region.Find(Location, Map);
protected override bool SupportsSpiralScan => _useSpiralScan;
protected override Rectangle3D GetBoundsForSpawnAttempt() => SpawnBounds;
protected override ReadOnlySpan<Rectangle3D> GetAllSpawnBounds() => new(ref _spawnBounds);
private void MigrateFrom(V0Content content)
{
// V0 had no fields in Spawner, new v1 field _useSpiralScan defaults to false
}
}