using System; using System.Collections.Generic; using Microsoft.Xna.Framework.Graphics; using FSO.Common.Rendering.Framework.Camera; using FSO.Common.Rendering.Framework.Model; namespace FSO.Common.Rendering.Framework { /// /// Base class for scenes with 3D elements. /// public abstract class _3DAbstract : IDisposable { public ICamera Camera; public string ID; public bool Visible = true; public abstract List<_3DComponent> GetElements(); public abstract void Add(_3DComponent item); public abstract void Update(UpdateState Time); public abstract void Draw(GraphicsDevice device); protected _3DLayer Parent; private EventHandler ResetEvent; public virtual void PreDraw(GraphicsDevice device) { } public virtual void Initialize(_3DLayer layer) { Parent = layer; } /// /// Creates a new _3DAbstract instance. /// /// A GraphicsDevice instance. public _3DAbstract(GraphicsDevice Device) { m_Device = Device; ResetEvent = new EventHandler(m_Device_DeviceReset); m_Device.DeviceReset += ResetEvent; } /// /// Called when m_Device is reset. /// private void m_Device_DeviceReset(object sender, EventArgs e) { DeviceReset(m_Device); } protected GraphicsDevice m_Device; public abstract void DeviceReset(GraphicsDevice Device); public static bool IsInvalidated; public object Controller { get; internal set; } public void SetController(object controller) { this.Controller = controller; } public T FindController() { if(Controller is T) { return (T)Controller; } return default(T); } public virtual void Dispose() { if (m_Device != null) m_Device.DeviceReset -= ResetEvent; } } }