2023-09-25 12:13:32 +00:00
|
|
|
#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;
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
2023-09-29 11:42:27 +00:00
|
|
|
static Dqn_f32 FP_Entity_CalcSpriteScaleForDesiredHeight(FP_Game *game, FP_Meters height, Dqn_Rect sprite_rect)
|
|
|
|
{
|
|
|
|
Dqn_f32 sprite_in_meters = FP_Game_PixelsToMetersNx1(game, sprite_rect.size.y);
|
|
|
|
Dqn_f32 result = height.meters / sprite_in_meters;
|
|
|
|
return result;
|
|
|
|
}
|
|
|
|
|
2023-09-25 12:13:32 +00:00
|
|
|
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;
|
|
|
|
}
|
|
|
|
|
2023-09-27 04:47:27 +00:00
|
|
|
static FP_GameEntityHandle FP_Entity_CreateClinger(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);
|
|
|
|
|
2023-09-30 06:51:59 +00:00
|
|
|
entity->type = FP_EntityType_Clinger;
|
|
|
|
entity->hp = 1;
|
|
|
|
entity->is_dying = false;
|
|
|
|
entity->base_acceleration_per_s.meters = 8.f;
|
|
|
|
entity->local_pos = pos;
|
|
|
|
entity->sprite_height.meters = 1.6f;
|
2023-10-01 05:47:40 +00:00
|
|
|
entity->attack_cooldown_ms = 1000;
|
2023-09-29 11:42:27 +00:00
|
|
|
|
|
|
|
entity->local_hit_box_size = FP_Game_MetersToPixelsNx2(game, 0.4f, entity->sprite_height.meters * .5f);
|
2023-09-27 04:47:27 +00:00
|
|
|
FP_Entity_AddDebugEditorFlags(game, entity->handle);
|
|
|
|
entity->flags |= FP_GameEntityFlag_NonTraversable;
|
|
|
|
entity->flags |= FP_GameEntityFlag_Attackable;
|
|
|
|
return result;
|
|
|
|
}
|
|
|
|
|
2023-09-25 12:13:32 +00:00
|
|
|
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);
|
|
|
|
|
2023-09-30 06:51:59 +00:00
|
|
|
entity->type = FP_EntityType_Smoochie;
|
|
|
|
entity->base_acceleration_per_s.meters = 8.f;
|
|
|
|
entity->hp = 1;
|
|
|
|
entity->is_dying = false;
|
|
|
|
entity->local_pos = pos;
|
|
|
|
entity->sprite_height.meters = 1.6f;
|
2023-10-01 05:47:40 +00:00
|
|
|
entity->attack_cooldown_ms = 1000;
|
2023-09-30 06:51:59 +00:00
|
|
|
entity->local_hit_box_size = FP_Game_MetersToPixelsNx2(game, 0.4f, entity->sprite_height.meters * .6f);
|
2023-09-25 12:13:32 +00:00
|
|
|
FP_Entity_AddDebugEditorFlags(game, entity->handle);
|
|
|
|
entity->flags |= FP_GameEntityFlag_NonTraversable;
|
2023-09-26 12:34:42 +00:00
|
|
|
entity->flags |= FP_GameEntityFlag_Attackable;
|
2023-09-25 12:13:32 +00:00
|
|
|
return result;
|
|
|
|
}
|
|
|
|
|
2023-10-01 10:15:05 +00:00
|
|
|
static FP_GameEntityHandle FP_Entity_CreateWallAtPos(FP_Game *game, Dqn_String8 name, Dqn_V2 pos, Dqn_V2 size)
|
2023-09-25 12:13:32 +00:00
|
|
|
{
|
|
|
|
FP_GameEntity *entity = FP_Game_MakeEntityPointerF(game, name.data);
|
|
|
|
FP_GameEntityHandle result = entity->handle;
|
2023-10-01 10:15:05 +00:00
|
|
|
entity->local_pos = pos;
|
|
|
|
entity->local_hit_box_size = size;
|
2023-09-25 12:13:32 +00:00
|
|
|
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<FP_GameEntityHandle>(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);
|
|
|
|
|
2023-09-30 06:51:59 +00:00
|
|
|
entity->type = FP_EntityType_Terry;
|
|
|
|
entity->local_pos = pos;
|
2023-09-30 12:27:25 +00:00
|
|
|
entity->base_acceleration_per_s.meters = 16.f;
|
2023-09-30 06:51:59 +00:00
|
|
|
entity->sprite_height.meters = 1.8f;
|
2023-10-01 05:47:40 +00:00
|
|
|
entity->attack_cooldown_ms = 500;
|
2023-09-30 06:51:59 +00:00
|
|
|
entity->local_hit_box_size = FP_Game_MetersToPixelsNx2(game, 0.5f, entity->sprite_height.meters * .6f);
|
2023-09-25 12:13:32 +00:00
|
|
|
FP_Entity_AddDebugEditorFlags(game, result);
|
|
|
|
entity->flags |= FP_GameEntityFlag_NonTraversable;
|
2023-09-29 05:44:02 +00:00
|
|
|
entity->flags |= FP_GameEntityFlag_Attackable;
|
2023-09-30 12:27:25 +00:00
|
|
|
entity->flags |= FP_GameEntityFlag_CameraTracking;
|
2023-09-25 12:13:32 +00:00
|
|
|
return result;
|
|
|
|
}
|
|
|
|
|
2023-10-01 06:50:32 +00:00
|
|
|
static FP_GameEntityHandle FP_Entity_CreateMerchantTerry(FP_Game *game, Dqn_V2 pos, DQN_FMT_STRING_ANNOTATE char const *fmt, ...)
|
2023-09-25 12:13:32 +00:00
|
|
|
{
|
|
|
|
va_list args;
|
|
|
|
va_start(args, fmt);
|
|
|
|
FP_GameEntity *entity = FP_Game_MakeEntityPointerFV(game, fmt, args);
|
|
|
|
FP_GameEntityHandle result = entity->handle;
|
|
|
|
va_end(args);
|
|
|
|
|
2023-10-01 06:50:32 +00:00
|
|
|
entity->type = FP_EntityType_MerchantTerry;
|
|
|
|
entity->local_pos = pos;
|
|
|
|
entity->sprite_height.meters = 3.66f;
|
|
|
|
FP_Entity_AddDebugEditorFlags(game, result);
|
|
|
|
entity->flags |= FP_GameEntityFlag_NonTraversable;
|
|
|
|
|
2023-10-01 11:16:49 +00:00
|
|
|
TELY_AssetSpriteAnimation *sprite_anim = TELY_Asset_GetSpriteAnimation(&game->atlas_sprite_sheet, g_anim_names.merchant_graveyard);
|
|
|
|
Dqn_Rect sprite_rect = game->atlas_sprite_sheet.rects.data[sprite_anim->index];
|
|
|
|
Dqn_f32 size_scale = FP_Entity_CalcSpriteScaleForDesiredHeight(game, entity->sprite_height, sprite_rect);
|
|
|
|
Dqn_V2 sprite_rect_scaled = sprite_rect.size * size_scale;
|
|
|
|
|
|
|
|
entity->local_hit_box_offset = Dqn_V2_InitNx2(0, sprite_rect_scaled.h * .15f);
|
|
|
|
entity->local_hit_box_size = Dqn_V2_InitNx2(sprite_rect_scaled.w, sprite_rect_scaled.h - (sprite_rect_scaled.h * .4f));
|
2023-10-01 06:50:32 +00:00
|
|
|
return result;
|
|
|
|
}
|
|
|
|
|
|
|
|
static FP_GameEntityHandle FP_Entity_CreateMerchantGraveyard(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_MerchantGraveyard;
|
|
|
|
entity->local_pos = pos;
|
|
|
|
entity->sprite_height.meters = 3.66f;
|
|
|
|
FP_Entity_AddDebugEditorFlags(game, result);
|
|
|
|
entity->flags |= FP_GameEntityFlag_NonTraversable;
|
|
|
|
|
2023-10-01 11:16:49 +00:00
|
|
|
|
|
|
|
TELY_AssetSpriteAnimation *sprite_anim = TELY_Asset_GetSpriteAnimation(&game->atlas_sprite_sheet, g_anim_names.merchant_graveyard);
|
|
|
|
Dqn_Rect sprite_rect = game->atlas_sprite_sheet.rects.data[sprite_anim->index];
|
|
|
|
Dqn_f32 size_scale = FP_Entity_CalcSpriteScaleForDesiredHeight(game, entity->sprite_height, sprite_rect);
|
|
|
|
Dqn_V2 sprite_rect_scaled = sprite_rect.size * size_scale;
|
|
|
|
|
|
|
|
entity->local_hit_box_offset = Dqn_V2_InitNx2(0, sprite_rect_scaled.h * .1f);
|
|
|
|
entity->local_hit_box_size = Dqn_V2_InitNx2(sprite_rect_scaled.w - (sprite_rect_scaled.w * .3f), sprite_rect_scaled.h - (sprite_rect_scaled.h * .5f));
|
2023-10-01 06:50:32 +00:00
|
|
|
return result;
|
|
|
|
}
|
|
|
|
|
|
|
|
static FP_GameEntityHandle FP_Entity_CreateMerchantGym(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_MerchantGym;
|
|
|
|
entity->local_pos = pos;
|
|
|
|
entity->sprite_height.meters = 3.66f;
|
|
|
|
FP_Entity_AddDebugEditorFlags(game, result);
|
|
|
|
entity->flags |= FP_GameEntityFlag_NonTraversable;
|
|
|
|
|
2023-10-01 11:16:49 +00:00
|
|
|
TELY_AssetSpriteAnimation *sprite_anim = TELY_Asset_GetSpriteAnimation(&game->atlas_sprite_sheet, g_anim_names.merchant_gym);
|
|
|
|
Dqn_Rect sprite_rect = game->atlas_sprite_sheet.rects.data[sprite_anim->index];
|
|
|
|
Dqn_f32 size_scale = FP_Entity_CalcSpriteScaleForDesiredHeight(game, entity->sprite_height, sprite_rect);
|
|
|
|
Dqn_V2 sprite_rect_scaled = sprite_rect.size * size_scale;
|
|
|
|
|
|
|
|
entity->local_hit_box_offset = Dqn_V2_InitNx2(0, sprite_rect_scaled.h * .3f);
|
|
|
|
entity->local_hit_box_size = Dqn_V2_InitNx2(sprite_rect_scaled.w - (sprite_rect_scaled.w * .3f), sprite_rect_scaled.h - (sprite_rect_scaled.h * .6f));
|
2023-10-01 06:50:32 +00:00
|
|
|
return result;
|
|
|
|
}
|
|
|
|
|
|
|
|
static FP_GameEntityHandle FP_Entity_CreateMerchantPhoneCompany(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_MerchantPhoneCompany;
|
2023-09-25 14:07:39 +00:00
|
|
|
entity->local_pos = pos;
|
|
|
|
entity->sprite_height.meters = 3.66f;
|
2023-09-25 12:13:32 +00:00
|
|
|
FP_Entity_AddDebugEditorFlags(game, result);
|
|
|
|
entity->flags |= FP_GameEntityFlag_NonTraversable;
|
|
|
|
|
2023-10-01 11:16:49 +00:00
|
|
|
TELY_AssetSpriteAnimation *sprite_anim = TELY_Asset_GetSpriteAnimation(&game->atlas_sprite_sheet, g_anim_names.merchant_phone_company);
|
|
|
|
Dqn_Rect sprite_rect = game->atlas_sprite_sheet.rects.data[sprite_anim->index];
|
|
|
|
Dqn_f32 size_scale = FP_Entity_CalcSpriteScaleForDesiredHeight(game, entity->sprite_height, sprite_rect);
|
|
|
|
Dqn_V2 sprite_rect_scaled = sprite_rect.size * size_scale;
|
|
|
|
|
|
|
|
entity->local_hit_box_offset = Dqn_V2_InitNx2(0, sprite_rect_scaled.h * .15f);
|
|
|
|
entity->local_hit_box_size = Dqn_V2_InitNx2(sprite_rect_scaled.w - (sprite_rect_scaled.w * .3f), sprite_rect_scaled.h - (sprite_rect_scaled.h * .4f));
|
2023-09-25 12:13:32 +00:00
|
|
|
return result;
|
|
|
|
}
|
2023-09-29 07:42:58 +00:00
|
|
|
|
|
|
|
static FP_GameEntityHandle FP_Entity_CreateClubTerry(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_ClubTerry;
|
|
|
|
entity->local_pos = pos;
|
2023-09-29 11:42:27 +00:00
|
|
|
entity->sprite_height.meters = 4.f;
|
2023-10-01 11:16:49 +00:00
|
|
|
FP_Entity_AddDebugEditorFlags(game, result);
|
|
|
|
entity->flags |= FP_GameEntityFlag_NonTraversable;
|
2023-09-29 11:42:27 +00:00
|
|
|
|
2023-10-01 05:55:48 +00:00
|
|
|
TELY_AssetSpriteAnimation *sprite_anim = TELY_Asset_GetSpriteAnimation(&game->atlas_sprite_sheet, g_anim_names.club_terry_alive);
|
|
|
|
Dqn_Rect sprite_rect = game->atlas_sprite_sheet.rects.data[sprite_anim->index];
|
2023-09-29 11:42:27 +00:00
|
|
|
Dqn_f32 size_scale = FP_Entity_CalcSpriteScaleForDesiredHeight(game, entity->sprite_height, sprite_rect);
|
|
|
|
Dqn_V2 sprite_rect_scaled = sprite_rect.size * size_scale;
|
|
|
|
|
2023-10-01 11:16:49 +00:00
|
|
|
entity->local_hit_box_offset = Dqn_V2_InitNx2(0, sprite_rect_scaled.h * .1f);
|
2023-09-29 11:42:27 +00:00
|
|
|
entity->local_hit_box_size = Dqn_V2_InitNx2(sprite_rect_scaled.w, sprite_rect_scaled.h - (sprite_rect_scaled.h * .4f));
|
2023-09-29 07:42:58 +00:00
|
|
|
return result;
|
|
|
|
}
|
2023-10-01 05:11:08 +00:00
|
|
|
|
|
|
|
static FP_GameEntityHandle FP_Entity_CreateHeart(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_Heart;
|
|
|
|
entity->local_pos = pos;
|
|
|
|
entity->sprite_height.meters = 4.f;
|
2023-10-01 11:16:49 +00:00
|
|
|
FP_Entity_AddDebugEditorFlags(game, result);
|
|
|
|
entity->flags |= FP_GameEntityFlag_NonTraversable;
|
2023-10-01 05:11:08 +00:00
|
|
|
|
2023-10-01 05:55:48 +00:00
|
|
|
TELY_AssetSpriteAnimation *sprite_anim = TELY_Asset_GetSpriteAnimation(&game->atlas_sprite_sheet, g_anim_names.heart);
|
|
|
|
Dqn_Rect sprite_rect = game->atlas_sprite_sheet.rects.data[sprite_anim->index];
|
2023-10-01 05:11:08 +00:00
|
|
|
Dqn_f32 size_scale = FP_Entity_CalcSpriteScaleForDesiredHeight(game, entity->sprite_height, sprite_rect);
|
|
|
|
Dqn_V2 sprite_rect_scaled = sprite_rect.size * size_scale;
|
|
|
|
|
2023-10-01 05:20:05 +00:00
|
|
|
entity->local_hit_box_offset = Dqn_V2_InitNx2(0, sprite_rect_scaled.h * .15f);
|
|
|
|
entity->local_hit_box_size = Dqn_V2_InitNx2(sprite_rect_scaled.w - (sprite_rect_scaled.w * .3f), sprite_rect_scaled.h - (sprite_rect_scaled.h * .4f));
|
2023-10-01 05:11:08 +00:00
|
|
|
return result;
|
|
|
|
}
|