private void RemoveAt(GridTransform i_gt, Vector3Int i_addr) { Debug.Assert(m_index.ContainsKey(i_addr)); Debug.Assert(m_index[i_addr] != null); m_index[i_addr].Remove(i_gt); m_reverseLookup.Remove(i_gt); }
public void UpdateIndex(GridTransform i_gt) { Deindex(i_gt); AddAt(i_gt, i_gt.GridPos); Debug.Assert(GetAt(i_gt.GridPos).Count() > 0, "GetAt returns empty list."); Debug.Assert(GetComponentAt <GridTransform>(i_gt.GridPos) != null, "GetComponentAt returns null."); Debug.Assert(GetComponentsAt <GridTransform>(i_gt.GridPos).Contains(i_gt), "GetComponentAt returns wrong address."); }
public void Deindex(GridTransform i_gt) { Vector3Int oldAddress; if (m_reverseLookup.TryGetValue(i_gt, out oldAddress)) { RemoveAt(i_gt, oldAddress); } }
private void AddAt(GridTransform i_gt, Vector3Int i_addr) { if (!m_index.ContainsKey(i_addr)) { m_index[i_addr] = new List <GridTransform>(); Debug.Assert(m_index.TryGetValue(i_addr, out var list), "TryGetValue failed."); } Debug.Assert(m_index[i_addr].Contains(i_gt) == false); m_index[i_addr].Add(i_gt); Debug.Assert(m_index[i_addr].Contains(i_gt) == true); m_reverseLookup[i_gt] = i_addr; }