/// <summary> /// Draws a specific BlockEntity with whatever texture is currently bound. /// </summary> /// <param name="entity"></param> private void DrawBlockEntity(BlockEntity entity) { GraphicsManager.DrawQuad(new Vector3d(entity.Position.X - (entity.Width / 2.0), entity.Position.Y + (entity.Height / 2.0), entity.Position.Z), new Vector3d(entity.Position.X + (entity.Width / 2.0), entity.Position.Y + (entity.Height / 2.0), entity.Position.Z), new Vector3d(entity.Position.X + (entity.Width / 2.0), entity.Position.Y - (entity.Height / 2.0), entity.Position.Z), new Vector3d(entity.Position.X - (entity.Width / 2.0), entity.Position.Y - (entity.Height / 2.0), entity.Position.Z)); }
/// <summary> /// Adds a new BlockEntity to this arena (intended to be called from Python). /// </summary> /// <param name="textureName">The name of the texture that will be used to draw this BlockEntity.</param> /// <param name="x">The center X coordinate of the BlockEntity</param> /// <param name="y">The center Y coordinate of the BlockEntity</param> /// <param name="width">The half-width (radius width) of the BlockEntity.</param> /// <param name="height">The half-height (radius height) of the BlockEntity.</param> /// <param name="background">True to make this a background entity, false to make it foreground.</param> /// <param name="collidable">True to enable collision of this entity, false to disable it.</param> /// <returns>true if the operation succeeded, false otherwise.</returns> public bool AddBlockEntity(string textureName, float x, float y, float z, float width, float height, bool background, bool collidable) { if (!Textures.ContainsKey(textureName)) { Console.WriteLine("LoadableBattleArena.AddBlockEntity: Failed to add BlockEntity because referenced texture dependency not met: \"" + textureName + "\"."); return false; } else { Texture tex = Textures[textureName]; BlockEntity entity = new BlockEntity(); entity.Position = new OpenTK.Vector3(x, y, z); entity.Dimensions = new OpenTK.Vector2(width, height); entity.CollisionEnabled = collidable; entity.Layer = BlockEntity.CollisionLayer.World; Dictionary<Texture, List<BlockEntity>> mapping; if(background) mapping = DepthLayers[(int)DepthLayerTypes.Background].BlockEntriesByTexture; else mapping = DepthLayers[(int)DepthLayerTypes.Foreground].BlockEntriesByTexture; if(!mapping.ContainsKey(tex)) mapping.Add(tex, new List<BlockEntity>()); mapping[tex].Add(entity); return true; } }