#ifndef TWN_CONTEXT_H
#define TWN_CONTEXT_H

#include "twn_types.h"
#include "twn_api.h"

#include <stdbool.h>
#include <stdint.h>


/* context that is only valid for current frame */
/* any changes to it will be dropped, unless explicitly stated */
typedef struct Context {
    /* you may read from and write to this one from game code */
    /* it is ensured to persist between initializations */
    void *udata;

    /* which frame is it, starting from 0 at startup */
    float frame_number;

    /* real time spent on one frame (in seconds) */
    /* townengine is fixed step based, so you don't have to use delta */
    float frame_duration;

    /* it is disabled by having fog_density approximately equal to zero */
    float fog_density;
    Color fog_color;

    /* resolution is set from config and dictates both logical and drawing space, as they're related */
    /* even if scaling is done, game logic should never change over that */
    Vec2 resolution;
    Vec2 mouse_position;
    Vec2 mouse_movement;

    /* is set on startup, should be used as source of randomness */
    float random_seed;

    /* whether debugging logic should be enabled in user code */
    bool debug;

    /* is set to true when state is invalidated and needs to be rebuilt */
    /* watch for it and handle properly! */
    bool initialization_needed;
    bool mouse_capture;
} Context;

/* when included after twn_engine_context there's an 'ctx' defined already */
#ifndef TWN_ENGINE_CONTEXT_C_H
TWN_API extern Context ctx;
#endif

#endif