using System.Collections.Generic;
using OpenTK;
using SM.Base.Contexts;
namespace SM.Base.Scene
{
///
/// A generic scene that imports different functions.
///
/// The type of cameras.
/// The type of show items.
public abstract class GenericScene : GenericItemCollection
where TCamera : GenericCamera, new()
where TItem : IShowItem
{
///
/// The active camera, that is used if the context doesn't force the viewport camera.
/// If none set, it automaticly uses the viewport camera.
///
public TCamera Camera { get; set; }
///
/// A camera to control the background.
///
public TCamera BackgroundCamera { get; set; } = new TCamera();
///
/// A camera to control the HUD.
///
public TCamera HUDCamera { get; set; } = new TCamera();
///
/// This contains the background.
///
protected IBackgroundItem _background;
///
/// This defines the HUD objects.
///
public List HUD { get; } = new List();
///
/// A collection for cameras to switch easier to different cameras.
///
public Dictionary Cameras = new Dictionary();
///
public override void Draw(DrawContext context)
{
if (!context.ForceViewport && Camera != null) context.View = Camera.CalculateViewMatrix();
DrawContext backgroundDrawContext = context;
backgroundDrawContext.View = BackgroundCamera.CalculateViewMatrix();
_background?.Draw(backgroundDrawContext);
base.Draw(context);
context.View = HUDCamera.CalculateViewMatrix();
for (int i = 0; i < HUD.Count; i++)
HUD[i].Draw(context);
}
///
/// Called, when the user activates the scene.
///
internal void Activate()
{
OnActivating();
}
///
/// Called, when the user activates the scene.
///
protected virtual void OnActivating()
{ }
}
}