public void RegisterField(CompPsychicSuppressionField comp) { foreach (var cell in comp.CellsInRange()) { if (suppressionField.TryGetValue(cell, out var existing)) { existing.Comps.Add(comp); } else { var entry = new SuppressionFieldEntry(); entry.Comps.Add(comp); suppressionField.Add(cell, entry); } } }
public void UnregisterField(CompPsychicSuppressionField comp) { var entriesToRemove = new List <IntVec3>(); foreach (var entry in suppressionField) { if (!entry.Value.Comps.Contains(comp)) { continue; } entry.Value.Comps.Remove(comp); if (entry.Value.Comps.Any()) { continue; } entriesToRemove.Add(entry.Key); } entriesToRemove.ForEach(entry => suppressionField.Remove(entry)); }
public void UpdateFieldRadius(CompPsychicSuppressionField comp) { UnregisterField(comp); RegisterField(comp); }