2023-09-16 02:46:28 +00:00
|
|
|
#if defined(__clang__)
|
|
|
|
#pragma once
|
|
|
|
#include "feely_pona_unity.h"
|
|
|
|
#endif
|
|
|
|
|
2023-09-23 02:33:59 +00:00
|
|
|
enum FP_GameEntityFlag
|
2023-09-17 10:24:07 +00:00
|
|
|
{
|
2023-09-23 02:33:59 +00:00
|
|
|
FP_GameEntityFlag_Clickable = 1 << 0,
|
|
|
|
FP_GameEntityFlag_MoveByKeyboard = 1 << 1,
|
|
|
|
FP_GameEntityFlag_MoveByMouse = 1 << 2,
|
2023-09-24 05:33:02 +00:00
|
|
|
FP_GameEntityFlag_MoveByGamepad = 1 << 3,
|
|
|
|
FP_GameEntityFlag_DrawHitBox = 1 << 4,
|
|
|
|
FP_GameEntityFlag_DeriveHitBoxFromChildrenBoundingBox = 1 << 5,
|
|
|
|
FP_GameEntityFlag_NonTraversable = 1 << 6,
|
|
|
|
FP_GameEntityFlag_MobSpawner = 1 << 7,
|
2023-09-24 09:11:44 +00:00
|
|
|
FP_GameEntityFlag_MobSpawnerWaypoint = 1 << 8,
|
2023-09-17 10:24:07 +00:00
|
|
|
};
|
|
|
|
|
|
|
|
enum FP_GameShapeType
|
|
|
|
{
|
|
|
|
FP_GameShapeType_None,
|
|
|
|
FP_GameShapeType_Circle,
|
|
|
|
FP_GameShapeType_Rect,
|
|
|
|
FP_GameShapeType_Line,
|
|
|
|
};
|
|
|
|
|
|
|
|
struct FP_GameShape
|
|
|
|
{
|
|
|
|
FP_GameShapeType type;
|
|
|
|
Dqn_V2 p1;
|
|
|
|
Dqn_V2 p2;
|
|
|
|
Dqn_V4 colour;
|
|
|
|
Dqn_f32 line_thickness;
|
|
|
|
Dqn_f32 circle_radius;
|
|
|
|
TELY_RenderShapeMode render_mode;
|
|
|
|
};
|
|
|
|
|
|
|
|
const uint64_t FP_GAME_ENTITY_HANDLE_GENERATION_MASK = 0xFFFF'0000'0000'0000;
|
|
|
|
const uint64_t FP_GAME_ENTITY_HANDLE_GENERATION_RSHIFT = 48;
|
|
|
|
const uint64_t FP_GAME_ENTITY_HANDLE_GENERATION_MAX = FP_GAME_ENTITY_HANDLE_GENERATION_MASK >> FP_GAME_ENTITY_HANDLE_GENERATION_RSHIFT;
|
|
|
|
|
|
|
|
const uint64_t FP_GAME_ENTITY_HANDLE_INDEX_MASK = 0x0000'FFFF'FFFF'FFFF;
|
|
|
|
const uint64_t FP_GAME_ENTITY_HANDLE_INDEX_MAX = FP_GAME_ENTITY_HANDLE_INDEX_MASK - 1;
|
|
|
|
struct FP_GameEntityHandle
|
|
|
|
{
|
|
|
|
uint64_t id;
|
|
|
|
};
|
|
|
|
|
|
|
|
struct FP_GameWaypoint
|
|
|
|
{
|
|
|
|
Dqn_V2I pos;
|
|
|
|
FP_GameWaypoint *next;
|
|
|
|
FP_GameWaypoint *prev;
|
|
|
|
};
|
|
|
|
|
2023-09-24 09:11:44 +00:00
|
|
|
struct FP_GameEntitySpawnList
|
|
|
|
{
|
|
|
|
FP_GameEntityHandle entity;
|
|
|
|
FP_GameEntitySpawnList *next;
|
|
|
|
FP_GameEntitySpawnList *prev;
|
|
|
|
};
|
|
|
|
|
2023-09-24 11:54:08 +00:00
|
|
|
struct FP_GameEntityActionSprite
|
2023-09-24 05:44:52 +00:00
|
|
|
{
|
|
|
|
TELY_AssetSpriteSheet *sheet;
|
2023-09-24 11:54:08 +00:00
|
|
|
TELY_AssetSpriteAnimation *anim;
|
2023-09-24 05:44:52 +00:00
|
|
|
};
|
|
|
|
|
2023-09-24 13:08:30 +00:00
|
|
|
uint64_t const FP_GAME_ENTITY_ACTION_INFINITE_TIMER = UINT64_MAX;
|
2023-09-17 14:12:58 +00:00
|
|
|
struct FP_GameEntityAction
|
|
|
|
{
|
2023-09-24 13:08:30 +00:00
|
|
|
uint32_t state;
|
|
|
|
uint32_t next_state;
|
|
|
|
TELY_AssetAnimatedSprite sprite;
|
|
|
|
uint64_t started_at_clock_ms;
|
|
|
|
uint64_t end_at_clock_ms;
|
2023-09-17 14:12:58 +00:00
|
|
|
};
|
|
|
|
|
2023-09-24 06:24:51 +00:00
|
|
|
enum FP_GameDirection
|
|
|
|
{
|
|
|
|
FP_GameDirection_Up,
|
|
|
|
FP_GameDirection_Down,
|
|
|
|
FP_GameDirection_Left,
|
|
|
|
FP_GameDirection_Right,
|
|
|
|
};
|
|
|
|
|
2023-09-17 10:24:07 +00:00
|
|
|
struct FP_GameEntity
|
|
|
|
{
|
2023-09-23 06:42:22 +00:00
|
|
|
FP_GameEntity *next;
|
|
|
|
FP_GameEntity *prev;
|
|
|
|
FP_GameEntity *first_child;
|
|
|
|
FP_GameEntity *last_child;
|
|
|
|
FP_GameEntity *parent;
|
|
|
|
|
2023-09-24 14:43:22 +00:00
|
|
|
FP_EntityType type;
|
|
|
|
Dqn_String8 name;
|
|
|
|
FP_GameEntityHandle handle;
|
2023-09-24 07:01:21 +00:00
|
|
|
|
2023-09-24 14:43:22 +00:00
|
|
|
Dqn_V2 size_scale;
|
|
|
|
FP_GameEntityAction action;
|
|
|
|
Dqn_V2 velocity;
|
2023-09-17 10:24:07 +00:00
|
|
|
|
2023-09-24 14:43:22 +00:00
|
|
|
FP_SentinelList<FP_GameEntityHandle> waypoints;
|
2023-09-17 10:24:07 +00:00
|
|
|
|
|
|
|
// NOTE: The entity hit box is positioned at the center of the entity.
|
2023-09-24 14:43:22 +00:00
|
|
|
Dqn_V2 local_hit_box_size;
|
|
|
|
Dqn_V2 local_hit_box_offset;
|
|
|
|
|
|
|
|
Dqn_V2 attack_box_size;
|
|
|
|
Dqn_V2 attack_box_offset;
|
|
|
|
|
|
|
|
Dqn_FArray<Dqn_V2, 8> spawner_waypoints;
|
|
|
|
FP_SentinelList<FP_GameEntityHandle> spawn_list;
|
|
|
|
uint64_t next_spawn_timestamp_s;
|
|
|
|
uint64_t spawn_cap;
|
|
|
|
|
|
|
|
uint64_t flags;
|
|
|
|
FP_GameDirection direction;
|
|
|
|
Dqn_V2 local_pos;
|
|
|
|
Dqn_f64 alive_time_s;
|
|
|
|
Dqn_FArray<FP_GameShape, 4> shapes;
|
2023-09-17 10:24:07 +00:00
|
|
|
};
|
|
|
|
|
|
|
|
struct FP_GameEntityIterator
|
|
|
|
{
|
|
|
|
bool init;
|
|
|
|
Dqn_usize iteration_count;
|
|
|
|
|
|
|
|
FP_GameEntity *entity;
|
|
|
|
FP_GameEntity *last_visited;
|
|
|
|
|
|
|
|
FP_GameEntity *entity_parent;
|
|
|
|
FP_GameEntity *entity_next;
|
|
|
|
FP_GameEntity *entity_first_child;
|
|
|
|
};
|
|
|
|
|
|
|
|
struct FP_GameCamera
|
|
|
|
{
|
|
|
|
Dqn_V2 world_pos;
|
|
|
|
Dqn_f32 rotate_rads;
|
|
|
|
Dqn_V2 scale;
|
|
|
|
};
|
|
|
|
|
|
|
|
struct FP_Game
|
|
|
|
{
|
2023-09-23 07:26:18 +00:00
|
|
|
Dqn_f32 delta_s_accumulator;
|
2023-09-23 02:33:59 +00:00
|
|
|
uint16_t tile_size;
|
|
|
|
TELY_ChunkPool *chunk_pool;
|
2023-09-17 10:24:07 +00:00
|
|
|
TELY_AssetFontHandle inter_regular_font;
|
|
|
|
TELY_AssetFontHandle inter_italic_font;
|
|
|
|
TELY_AssetFontHandle jetbrains_mono_font;
|
|
|
|
TELY_AssetAudioHandle test_audio;
|
|
|
|
Dqn_Slice<TELY_AssetSpriteAnimation> hero_sprite_anims;
|
|
|
|
TELY_AssetSpriteSheet hero_sprite_sheet;
|
|
|
|
Dqn_FArray<FP_GameEntityHandle, 8> parent_entity_stack;
|
|
|
|
Dqn_VArray<FP_GameEntity> entities;
|
2023-09-23 06:42:22 +00:00
|
|
|
|
2023-09-24 11:54:08 +00:00
|
|
|
TELY_AssetSpriteSheet terry_sprite_sheet;
|
|
|
|
TELY_AssetSpriteSheet smoochie_sprite_sheet;
|
|
|
|
TELY_AssetSpriteSheet terry_merchant_sprite_sheet;
|
2023-09-24 04:20:27 +00:00
|
|
|
|
2023-09-24 11:54:08 +00:00
|
|
|
FP_GameEntity *root_entity;
|
|
|
|
FP_GameEntity *entity_free_list;
|
2023-09-23 11:21:08 +00:00
|
|
|
|
2023-09-24 11:54:08 +00:00
|
|
|
FP_GameEntityHandle player;
|
2023-09-24 08:05:28 +00:00
|
|
|
|
2023-09-24 11:54:08 +00:00
|
|
|
FP_GameEntityHandle clicked_entity;
|
|
|
|
FP_GameEntityHandle hot_entity;
|
|
|
|
FP_GameEntityHandle active_entity;
|
|
|
|
FP_GameEntityHandle prev_clicked_entity;
|
|
|
|
FP_GameEntityHandle prev_hot_entity;
|
|
|
|
FP_GameEntityHandle prev_active_entity;
|
2023-09-23 06:42:22 +00:00
|
|
|
|
2023-09-24 11:54:08 +00:00
|
|
|
FP_GameCamera camera;
|
|
|
|
TELY_RFui rfui;
|
2023-09-24 13:08:30 +00:00
|
|
|
|
|
|
|
uint64_t clock_ms;
|
2023-09-16 02:46:28 +00:00
|
|
|
};
|
2023-09-23 02:33:59 +00:00
|
|
|
|
|
|
|
struct FP_GameAStarNode
|
|
|
|
{
|
|
|
|
Dqn_usize cost;
|
|
|
|
Dqn_usize heuristic;
|
2023-09-23 07:19:36 +00:00
|
|
|
Dqn_V2I tile;
|
2023-09-23 02:33:59 +00:00
|
|
|
Dqn_V2I came_from;
|
2023-09-23 05:52:26 +00:00
|
|
|
bool non_traversable;
|
2023-09-23 02:33:59 +00:00
|
|
|
};
|