Cleaned up asset loading system, and made progress on game engine structure.
This commit is contained in:
@@ -7,12 +7,8 @@ using RecrownedGTK.AssetsSystem;
|
||||
namespace RecrownedGTK.Game {
|
||||
public sealed class GameEngine : GameWindow {
|
||||
private IState state;
|
||||
public readonly Preferences preferences;
|
||||
public readonly AssetManager assets;
|
||||
public GameEngine(IState initialState, Preferences preferences, AssetManager assets) : base() {
|
||||
public GameEngine(IState initialState) : base() {
|
||||
this.state = initialState;
|
||||
this.assets = assets;
|
||||
this.preferences = preferences;
|
||||
}
|
||||
|
||||
protected override void OnUpdateFrame(FrameEventArgs e) {
|
||||
@@ -34,7 +30,7 @@ namespace RecrownedGTK.Game {
|
||||
}
|
||||
|
||||
protected override void OnClosed(EventArgs e) {
|
||||
if (state.CloseRequested()) {
|
||||
if (!state.CloseRequested()) {
|
||||
((CancelEventArgs) e).Cancel = true;
|
||||
}
|
||||
base.OnClosed(e);
|
||||
|
@@ -3,13 +3,47 @@ using OpenTK.Input;
|
||||
namespace RecrownedGTK.Game {
|
||||
public interface IState
|
||||
{
|
||||
/// <summary>
|
||||
/// Called when this state is going to be shown.
|
||||
/// </summary>
|
||||
/// <param name="gameManager">The instance of the game manager that is requesting this.</param>
|
||||
/// <returns>True of it's ready to be displayed, false otherwise.</returns>
|
||||
bool Shown(GameEngine gameManager);
|
||||
|
||||
/// <summary>
|
||||
/// Called on updating the state.
|
||||
/// </summary>
|
||||
/// <param name="time">The time that has passed since the last update in seconds.</param>
|
||||
void Update(double time);
|
||||
|
||||
/// <summary>
|
||||
/// Called for rendering things.
|
||||
/// </summary>
|
||||
/// <param name="time">The time that has elapsed since last rendering in seconds.</param>
|
||||
void Render(double time);
|
||||
|
||||
/// <summary>
|
||||
/// Called when this state is no longer being displayed.
|
||||
/// </summary>
|
||||
void Hidden();
|
||||
|
||||
/// <summary>
|
||||
/// Called when the game window size is updated.
|
||||
/// </summary>
|
||||
/// <param name="width">The new width</param>
|
||||
/// <param name="height">The new height</param>
|
||||
void WindowSizeUpdate(int width, int height);
|
||||
|
||||
/// <summary>
|
||||
/// When the game is being requested to be closed.
|
||||
/// </summary>
|
||||
/// <returns>True if closing is acceptable, or false otherwise.</returns>
|
||||
bool CloseRequested();
|
||||
|
||||
/// <summary>
|
||||
/// Called every update in the case that there should be a state change.
|
||||
/// </summary>
|
||||
/// <returns>Another state if ready to change states, or null if not.</returns>
|
||||
IState ChangeState();
|
||||
|
||||
}
|
||||
|
Reference in New Issue
Block a user