public int AddObject(IModelObject modelObject) { ObjectsCount++; modelObject.SetID(ObjectsCount); Objects.Add(new KeyValuePair <int, IModelObject>(modelObject.GetID(), modelObject)); return(modelObject.GetID()); }
public int AddObject(IModelObject modelObject) { if (!ObjectsByPosition.ContainsKey(modelObject.GetPosition())) { ObjectsCount++; modelObject.SetID(ObjectsCount); modelObject.Parent = this; ObjectsByID.Add(new KeyValuePair <int, IModelObject>(modelObject.GetID(), modelObject)); ObjectsByPosition.Add(modelObject.GetPosition(), modelObject); return(modelObject.GetID()); } else { throw new Exception("Duplicate Position Object."); } }