Exemplo n.º 1
0
        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.");
        }
Exemplo n.º 2
0
 public void Delete(IGameObjectReference reference)
 {
     if (reference is GameObjectReference go)
     {
         DeleteGameObject(go);
         if (RemoveFromDatabase(go))
         {
             SaveDatabase();
         }
     }
 }
Exemplo n.º 3
0
        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);
        }
Exemplo n.º 4
0
        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.");
        }
Exemplo n.º 5
0
        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);
        }
Exemplo n.º 6
0
 public void Delete(IGameObjectReference reference)
 {
     _storage.Delete(reference.GetSource());
 }
Exemplo n.º 7
0
 public IGameObject Open(IGameObjectReference reference)
 {
     return(_storage.Open(reference.GetSource()).CreatePresenter());
 }