using System.Collections.Generic; using Framework; using UnityEngine; namespace Gameplay { public partial class Map { private List _runTimeTerrainProperty = new List(); public struct RuntimeBlockProperty { public bool selectable; public int crossLevel; public bool banAttack; public bool banGFX; public bool isEmptyBlock; public RuntimeBlockProperty(TerrainTypeProperty data) { selectable = data.selectable; crossLevel = data.crossLevel; banAttack = data.banAttack; banGFX = data.banGFX; isEmptyBlock = data.emptyBlock; } } public void SetRuntimeBlockProperty(int cellIndex, RuntimeBlockProperty data) { // DebugUtil.LogWarning("set cellIndex: " + cellIndex + " data: " + data.crossLevel + " " + data.isEmptyBlock); var vec2Pos = TGSCellIndex2BlockPosition(cellIndex); SetRuntimeBlockProperty(vec2Pos, data); } public void SetRuntimeBlockProperty(Vector2Int position, RuntimeBlockProperty data) { if (MapData.CheckPosition(position)) { var index = MapData.Position2BlockIndex(position); if (index >= 0 && index < _runTimeTerrainProperty.Count) { _runTimeTerrainProperty[index] = data; UpdateTGSByData(_terrainGridSystem, position, data); EventManager.Instance.Send(EventManager.EventName.MapRuntimeBlockPropertyChange, position); } } } public bool GetRuntimeBlockProperty(int cellIndex, out RuntimeBlockProperty data) { var vec2Pos = TGSCellIndex2BlockPosition(cellIndex); return GetRuntimeBlockProperty(vec2Pos, out data); } public bool GetRuntimeBlockProperty(Vector2Int position, out RuntimeBlockProperty data) { if (MapData.CheckPosition(position)) { var index = MapData.Position2BlockIndex(position); if (index >= 0 && index < _runTimeTerrainProperty.Count) { data = _runTimeTerrainProperty[index]; return true; } } data = new RuntimeBlockProperty(); return false; } } }