Only outline when talking to the character

main
parent cfac7d9589
commit f1f365236c

@ -1527,6 +1527,12 @@ double unprocessed_gameplay_time = 0.0;
#define MINIMUM_TIMESTEP (1.0 / 60.0)
EntityRef frome(Entity *e)
{
if(e == 0)
{
return (EntityRef){0};
}
else
{
EntityRef to_return = {
.index = (int)(e - gs.entities),
@ -1536,6 +1542,7 @@ EntityRef frome(Entity *e)
assert(to_return.index < ARRLEN(gs.entities));
return to_return;
}
}
Entity *gete(EntityRef ref)
{
@ -5527,18 +5534,19 @@ void frame(void)
if(it->is_npc || it->is_character)
{
Transform draw_with = entity_transform(it);
bool do_outline = it->is_npc && gete(gs.player->interacting_with) == it;
if(it->npc_kind == NPC_Player)
{
draw_thing((DrawnThing){.armature = &player_armature, .t = draw_with, .outline = true});
draw_thing((DrawnThing){.armature = &player_armature, .t = draw_with});
}
else if(it->npc_kind == NPC_Farmer)
{
farmer_armature.go_to_animation = MD_S8Lit("Dance");
draw_thing((DrawnThing){.armature = &farmer_armature, .t = draw_with});
draw_thing((DrawnThing){.armature = &farmer_armature, .t = draw_with, .outline = do_outline});
}
else
{
draw_thing((DrawnThing){.mesh = &mesh_player, .t = draw_with});
draw_thing((DrawnThing){.mesh = &mesh_player, .t = draw_with, .outline = do_outline});
}
}
}
@ -5634,7 +5642,6 @@ void frame(void)
// these are static so that, on frames where no gameplay processing is necessary and just rendering, the rendering uses values from last frame
static Entity *interacting_with = 0; // used by rendering to figure out who to draw dialog box on
static bool player_in_combat = false;
const float dialog_interact_size = 2.5f * TILE_SIZE;
float speed_target;
// pausing the game
@ -6341,7 +6348,7 @@ void frame(void)
{
// find closest to talk to
{
AABB dialog_rect = aabb_centered(gs.player->pos, V2(dialog_interact_size , dialog_interact_size));
AABB dialog_rect = aabb_centered(gs.player->pos, V2(DIALOG_INTERACT_SIZE, DIALOG_INTERACT_SIZE));
dbgrect(dialog_rect);
Overlapping possible_dialogs = get_overlapping(dialog_rect);
float closest_interact_with_dist = INFINITY;
@ -6391,6 +6398,8 @@ void frame(void)
interacting_with = gete(gs.player->talking_to);
assert(interacting_with);
}
gs.player->interacting_with = frome(interacting_with);
}
if (interact)
@ -6615,7 +6624,7 @@ void frame(void)
{
float dist = LenV2(SubV2(it->pos, gs.player->pos));
dist -= 10.0f; // radius around point where dialog is completely opaque
float max_dist = dialog_interact_size / 2.0f;
float max_dist = DIALOG_INTERACT_SIZE / 2.0f;
float alpha = 1.0f - (float)clamp(dist / max_dist, 0.0, 1.0);
if (gete(gs.player->talking_to) == it && gs.player->state == CHARACTER_TALKING) alpha = 0.0f;
if (it->being_hovered)

@ -307,6 +307,7 @@ typedef struct Entity
// character
bool knighted;
bool in_conversation_mode;
EntityRef interacting_with; // for drawing outline on maybe interacting with somebody
Vec2 to_throw_direction;
BUFF(Vec2, 8) position_history; // so npcs can follow behind the player
CharacterState state;

@ -10,6 +10,7 @@
#define SWORD_SWIPE_RADIUS (TILE_SIZE*3.0f)
#define ARROW_SPEED 200.0f
#define SECONDS_PER_ARROW 1.3f
#define DIALOG_INTERACT_SIZE 5.0f // length of the centered AABB (not halfsize) around the player of who they're interacting with
#define CAM_DISTANCE 15.0f
#define CAM_VERTICAL_TO_HORIZONTAL_RATIO 0.8f

Loading…
Cancel
Save