public void Add(IWadObjectId newId, IWadObject wadObject) { // Change id if necessary if (newId != wadObject.Id) { var property = wadObject.GetType().GetProperty("Id"); property.SetValue(wadObject, newId); } // Add object if (newId is WadMoveableId) { Moveables.Add((WadMoveableId)newId, (WadMoveable)wadObject); } else if (newId is WadStaticId) { Statics.Add((WadStaticId)newId, (WadStatic)wadObject); } else if (newId is WadSpriteSequenceId) { SpriteSequences.Add((WadSpriteSequenceId)newId, (WadSpriteSequence)wadObject); } else { throw new ArgumentException("Argument not of a valid type."); } }
// This method is optional. By sorting the wad textures it may result ahead of time // we may have better texture space efficency. public void PreloadReplaceWad(IEnumerable <WadMoveable> newMoveables, IEnumerable <WadStatic> newStatics) { Dispose(); try { PreloadReplaceTextures(newMoveables, newStatics); } catch (TextureAtlasFullException) { logger.Error("Unable to preload wad because the texture atlas became too full!"); return; } // Create moveable models Parallel.ForEach(newMoveables, moveable => { var model = AnimatedModel.FromWadMoveable(GraphicsDevice, moveable, AllocateTexture); lock (Moveables) Moveables.Add(moveable, model); }); // Create static meshes Parallel.ForEach(newStatics, @static => { var model = new StaticModel(GraphicsDevice); model.Meshes.Add(ObjectMesh.FromWad2(GraphicsDevice, @static.Mesh, AllocateTexture)); model.UpdateBuffers(); lock (Statics) Statics.Add(@static, model); }); }
public void AddMoveable(string symbol) { if (!Moveables.Contains(symbol)) { Moveables.Add(symbol); } }
public virtual void PlaceMoveable(IMoveable moveable) { if (Moveables.Count != 0) { RemoveMoveable(Moveables.First()); } Moveables.Add(moveable); }
public void AddMoveable(IMoveable moveable) { var listener = new FloorChangeListener(); listener.Subscribe(moveable); Listeners.Add(listener); Moveables.Add(moveable.Identifier, moveable); }
private void AddToList(GameObject go) { var item = go as ICollidable; if (item != null) { Collidables.Add(item); } var moveable = go as IMoveable; if (moveable != null) { Moveables.Add(moveable); } var renderable = go as IRenderable; if (renderable != null) { Renderables.Add(renderable); } }
public AnimatedModel GetMoveable(WadMoveable moveable, bool maybeRebuildAll = true) { // Check if the data is already loaded // If yes attempt to use that one AnimatedModel model; if (Moveables.TryGetValue(moveable, out model)) { if (model.Version >= moveable.Version) { return(model); } ReclaimTextureSpace(model); model.Dispose(); Moveables.Remove(moveable); } // The data is either new or has changed, unfortunately we need to reload it try { model = AnimatedModel.FromWadMoveable(GraphicsDevice, moveable, AllocateTexture); } catch (TextureAtlasFullException exc) { logger.Info(exc.Message); if (maybeRebuildAll) { logger.Info("Starting to rebuild the entire atlas."); Dispose(); return(GetMoveable(moveable, false)); } } Moveables.Add(moveable, model); return(model); }
public void PlaceMoveable(IMoveable moveable) { Moveables.Add(moveable); }