#if defined(__clang__) #pragma once #include "feely_pona_unity.h" #endif static void FP_Entity_AddDebugEditorFlags(FP_Game *game, FP_GameEntityHandle handle) { FP_GameEntity *entity = FP_Game_GetEntity(game, handle); if (!FP_Game_IsNilEntity(entity)) { entity->flags |= FP_GameEntityFlag_Clickable; entity->flags |= FP_GameEntityFlag_MoveByKeyboard; entity->flags |= FP_GameEntityFlag_MoveByMouse; entity->flags |= FP_GameEntityFlag_MoveByGamepad; } } static FP_GameEntityHandle FP_Entity_CreateWaypointF(FP_Game *game, Dqn_V2 pos, DQN_FMT_STRING_ANNOTATE char const *fmt, ...) { va_list args; va_start(args, fmt); FP_GameEntity *entity = FP_Game_MakeEntityPointerFV(game, fmt, args); FP_GameEntityHandle result = entity->handle; va_end(args); entity->local_pos = pos; entity->local_hit_box_size = Dqn_V2_InitNx1(32); FP_Entity_AddDebugEditorFlags(game, entity->handle); entity->flags |= FP_GameEntityFlag_MobSpawnerWaypoint; FP_GameShape *shape = Dqn_FArray_Make(&entity->shapes, Dqn_ZeroMem_Yes); shape->type = FP_GameShapeType_Circle; shape->circle_radius = 16.f; shape->render_mode = TELY_RenderShapeMode_Line; shape->colour = TELY_COLOUR_BLUE_CADET_V4; return result; } static FP_GameEntityHandle FP_Entity_CreateSmoochie(FP_Game *game, Dqn_V2 pos, DQN_FMT_STRING_ANNOTATE char const *fmt, ...) { va_list args; va_start(args, fmt); FP_GameEntity *entity = FP_Game_MakeEntityPointerFV(game, fmt, args); FP_GameEntityHandle result = entity->handle; va_end(args); entity->type = FP_EntityType_Smoochie; entity->hp = 1; entity->local_pos = pos; entity->sprite_height.meters = 1.6f; entity->local_hit_box_size = FP_Game_MetersToPixelsNx2(game, 0.4f, 1.6f); FP_Entity_AddDebugEditorFlags(game, entity->handle); entity->flags |= FP_GameEntityFlag_NonTraversable; entity->flags |= FP_GameEntityFlag_Attackable; return result; } static FP_GameEntityHandle FP_Entity_CreateWallAtTile(FP_Game *game, Dqn_String8 name, Dqn_V2I tile_pos, Dqn_V2I size_in_tiles) { Dqn_V2 size = Dqn_V2_InitV2I(size_in_tiles * DQN_CAST(int32_t) game->tile_size); Dqn_V2 world_pos = FP_Game_TilePosToWorldPos(game, tile_pos); world_pos += size * .5f; FP_GameEntity *entity = FP_Game_MakeEntityPointerF(game, name.data); FP_GameEntityHandle result = entity->handle; entity->local_pos = world_pos; entity->local_hit_box_size = Dqn_V2_InitV2I(size_in_tiles * DQN_CAST(int32_t)game->tile_size); FP_Entity_AddDebugEditorFlags(game, entity->handle); entity->flags |= FP_GameEntityFlag_NonTraversable; FP_GameShape *wall = Dqn_FArray_Make(&entity->shapes, Dqn_ZeroMem_Yes); wall->type = FP_GameShapeType_Rect; wall->p2 = entity->local_hit_box_size; wall->colour = TELY_COLOUR_GREEN_DARK_KHAKI_V4; return result; } static FP_GameEntityHandle FP_Entity_CreateMobSpawner(FP_Game *game, Dqn_V2 pos, Dqn_usize spawn_cap, char const *fmt, ...) { va_list args; va_start(args, fmt); FP_GameEntity *entity = FP_Game_MakeEntityPointerFV(game, fmt, args); FP_GameEntityHandle result = entity->handle; va_end(args); entity->local_pos = pos; entity->local_hit_box_size = Dqn_V2_InitNx1(32); FP_Entity_AddDebugEditorFlags(game, result); entity->flags |= FP_GameEntityFlag_MobSpawner; entity->spawn_cap = spawn_cap; entity->spawn_list = FP_SentinelList_Init(game->chunk_pool); FP_GameShape *shape = Dqn_FArray_Make(&entity->shapes, Dqn_ZeroMem_Yes); shape->type = FP_GameShapeType_Rect; shape->p1 = {}; shape->p2 = entity->local_hit_box_size; shape->render_mode = TELY_RenderShapeMode_Line; shape->colour = TELY_COLOUR_BLUE_CADET_V4; return result; } static FP_GameEntityHandle FP_Entity_CreateTerry(FP_Game *game, Dqn_V2 pos, DQN_FMT_STRING_ANNOTATE char const *fmt, ...) { va_list args; va_start(args, fmt); FP_GameEntity *entity = FP_Game_MakeEntityPointerFV(game, fmt, args); FP_GameEntityHandle result = entity->handle; va_end(args); entity->type = FP_EntityType_Terry; entity->local_pos = pos; entity->sprite_height.meters = 1.8f; entity->local_hit_box_size = FP_Game_MetersToPixelsNx2(game, 0.5f, entity->sprite_height.meters); FP_Entity_AddDebugEditorFlags(game, result); entity->flags |= FP_GameEntityFlag_NonTraversable; return result; } static FP_GameEntityHandle FP_Entity_CreateMerchant(FP_Game *game, Dqn_V2 pos, DQN_FMT_STRING_ANNOTATE char const *fmt, ...) { va_list args; va_start(args, fmt); FP_GameEntity *entity = FP_Game_MakeEntityPointerFV(game, fmt, args); FP_GameEntityHandle result = entity->handle; va_end(args); entity->type = FP_EntityType_Merchant; entity->local_pos = pos; entity->local_hit_box_size = Dqn_V2_InitNx2(50, 50); entity->sprite_height.meters = 3.66f; FP_Entity_AddDebugEditorFlags(game, result); entity->flags |= FP_GameEntityFlag_NonTraversable; return result; }