unit Frost.Scenes;

interface

uses
  Frost.Forms,
  Frost.RenderEngine,
  Frost.GameObjects,
  Frost.Particles,
  Frost.Renderers;

type

TScene = class
    private               
      FCamera: TCamera;
      FObjectTree: TObjectTree;
      FRenderEngine: TRenderEngine;    
      FParticleEngine: TParticleRendererLayer;
    protected                
      FCameraController: TGameObject;
    public            
      constructor Create;
      destructor Destroy; override;
      procedure Awake;
      procedure OnSceneUpdate(delta: Double); 
      procedure OnStart;  virtual;
      procedure OnUpdate(delta: Double); virtual;
      procedure OnDestroy;virtual;
  end;

implementation

{$REGION 'TScene'}
constructor TScene.Create;
begin

end;

procedure TScene.Awake;
begin
  FObjectTree := TObjectTree.Create;

  FCameraController := TGameObject.Create(nil);
  FCameraController.Name := 'MainCamera';
  FCamera := TCamera.Create(FCameraController);
  FRenderEngine := TRenderEngine.Create(FCamera);  

  FRenderEngine.AddLayer(TMeshRendererLayer.Create);
  FParticleEngine := TParticleRendererLayer.Create;
  FRenderEngine.AddLayer(FParticleEngine);

  OnStart;
end;

procedure TScene.OnSceneUpdate(Delta: Double);
begin                   
  OnUpdate(delta);
  FObjectTree.Update(Delta);
  FParticleEngine.UpdateParticles(Delta, FCamera);
  FRenderEngine.Render;   
end;

procedure TScene.OnStart;
begin

end;

procedure TScene.OnUpdate;
begin

end;

procedure TScene.OnDestroy;
begin

end;

destructor TScene.Destroy;
begin
  FObjectTree.Free;
  inherited;
end;
{$ENDREGION}

end.
