using System; using System.Collections.Generic; using UnityEngine; namespace Heroes.Battle { /// /// Designer-authored obstacle entry. The sprite is placed on an anchor hex /// and marks a set of hexes as blocked. Relative blocked hexes are expressed /// as offsets from the anchor. A visual offset in world space is applied to /// the sprite so designers can align overhanging art. /// [CreateAssetMenu(menuName = "Heroes/Battle/Obstacle", fileName = "Obstacle")] public sealed class ObstacleDefinition : ScriptableObject { [Tooltip("Stable identifier used in BattlefieldConfig. Leave empty to use asset name.")] public string id; public Sprite sprite; [Tooltip("Obstacle class (VCMI terminology). Absolute obstacles are placed at a fixed anchor and appear at most once per battlefield.")] public ObstacleType type = ObstacleType.Usual; [Tooltip("Fixed anchor position used when type = Absolute. Ignored for Usual obstacles.")] public Vector2Int absoluteAnchor = new Vector2Int(7, 5); [Tooltip("Terrains on which this obstacle is allowed to spawn.")] public List allowedTerrains = new List(); [Tooltip("Hexes blocked by this obstacle, relative to the anchor hex (0,0).")] public List blockedHexes = new List { new HexOffset { dx = 0, dy = 0 } }; [Tooltip("World-space offset applied to the sprite when placed on the anchor hex.")] public Vector2 spriteOffset = Vector2.zero; [Tooltip("Relative weight for random selection. Higher = more frequent. Only used for Usual obstacles.")] [Min(0f)] public float weight = 1f; public string ResolveId() => string.IsNullOrEmpty(id) ? name : id; } /// /// Obstacle class mirroring VCMI's CObstacleInstance::USUAL / ABSOLUTE_OBSTACLE. /// Absolute obstacles define a large scripted decoration (e.g. ship wreck, /// giant rock) that sits at a fixed anchor; at most one appears per battle. /// public enum ObstacleType { Usual, Absolute, } [Serializable] public struct HexOffset { public int dx; public int dy; } }