public ITileMapPlaceable CreateEntity(TileMapObject tileMapObj)
        {
            if (tileMapObj is null)
            {
                throw new ArgumentNullException(nameof(tileMapObj));
            }

            bool success = tileMapObj.CustomProperties.TryGetValue("ClassName", out string className);

            if (!success)
            {
                throw new TileMapObjectCreationException(tileMapObj, CLASS_NAME_PROP_MISSING_ERR_MSG);
            }

            ITileMapPlaceable entity = null;

            try
            {
                entity = (ITileMapPlaceable)Activator.CreateInstance(Type.GetType(className));
                Vector2 position = new Vector2(tileMapObj.X, tileMapObj.Y);
                entity.Initialize(_gameServices, _content, tileMapObj.CustomProperties, position);
            }
            catch (Exception ex)
            {
                throw new TileMapObjectCreationException(tileMapObj, "An error occurred while instantiating the object.", ex);
            }

            return(entity);
        }
        public void RemoveObject(TileMapObject tileMapObject)
        {
            if (!HasObject(tileMapObject))
            {
                return;
            }

            _objects.Remove(tileMapObject);
        }
        public void AddObject(TileMapObject tileMapObject)
        {
            if (tileMapObject is null)
            {
                throw new System.ArgumentNullException(nameof(tileMapObject));
            }

            _objects.Add(tileMapObject);
        }
 public TileMapObjectCreationException(TileMapObject tileMapObj, string message, Exception innerException = null)
     : base(message, innerException)
 {
     Object = tileMapObj;
 }
 public bool HasObject(TileMapObject tileMapObject) => _objects.Contains(tileMapObject);