public IGameObject Open(IGameObjectReference reference) { if (reference is GameObjectReference go) { return(OpenFile(Path.Combine(DatabaseFolder, GameObjectFolder, go.Id + GameObjectExtension))); } throw new ArgumentException("Data.Storage: Cannot Open metadata, reference don't exist."); }
public void Delete(IGameObjectReference reference) { if (reference is GameObjectReference go) { DeleteGameObject(go); if (RemoveFromDatabase(go)) { SaveDatabase(); } } }
public IGameObject Duplicate(IGameObjectReference reference) { if (!(reference is IGameObject go)) { go = _storage.Open(reference as IGameObjectMetadata); } var gameObject = _factory.Create(go.Type).CreatePresenter() as GameObject; gameObject.CopyData(go); return(gameObject); }
public static Data.GameObjects.IGameObjectReference GetSource(this IGameObjectReference gameObject) { if (gameObject is GameObject go) { return(go.Source); } else if (gameObject is GameObjectMetadata gom) { return(gom.Source); } throw new ArgumentException("IGameObjectReference is not a GameObject or a GameObjectMetadata."); }
public void CopyTo(IGameObject target, IGameObjectReference source) { if (!(source is IGameObject go)) { go = _storage.Open(source as IGameObjectMetadata); } if (target.Type != go.Type) { throw new ArgumentException("Target and Source are not of the same type."); } (target as GameObject)?.CopyData(go); }
public void Delete(IGameObjectReference reference) { _storage.Delete(reference.GetSource()); }
public IGameObject Open(IGameObjectReference reference) { return(_storage.Open(reference.GetSource()).CreatePresenter()); }