feat: added out list argument to HurtboxCast

This commit is contained in:
Sara 2024-02-22 21:12:07 +01:00
parent 2895ce6079
commit 6b8dbaee7b
3 changed files with 7 additions and 3 deletions

View file

@ -18,7 +18,7 @@ void Internal_HurtboxDealDamage(const Hurtbox* self, List* colliders, float min_
}
}
int HurtboxCast(Hurtbox* self, float facing_dir) {
int HurtboxCast(Hurtbox* self, float facing_dir, List *out) {
const IPhysicsEntity* physics_entity = mirror_get_typeclass(self->owner.data, self->owner.mirror, "PhysicsEntity");
const ITransformable* transformable = mirror_get_typeclass(self->owner.data, self->owner.mirror, "Transformable");
@ -32,5 +32,9 @@ int HurtboxCast(Hurtbox* self, float facing_dir) {
const Vector offset = vaddf(transform->position, MakeVector(facing_dir * self->offset.x, self->offset.y));
List found = physics_world_box_query_all(offset, self->size, PHYSICS_LAYER_COMBAT, body);
Internal_HurtboxDealDamage(self, &found, transform->position.y - self->depth_extent, transform->position.y + self->depth_extent);
if(out == NULL)
list_empty(&found);
else
*out = found;
return found.len;
}

View file

@ -13,6 +13,6 @@ typedef struct Hurtbox {
float depth_extent;
} Hurtbox;
int HurtboxCast(Hurtbox* self, float facing_dir);
extern int HurtboxCast(Hurtbox* self, float facing_dir, List *out);
#endif // !FIGHT_HURTBOX_H

View file

@ -82,7 +82,7 @@ void PlayerHurtbox(Player* self, DamageEventData damage, Vector hitbox_size, Vec
.offset = vaddf(offset, MakeVector(0.f, self->height)),
.depth_extent = 0.15f,
};
HurtboxCast(&box, self->facing);
HurtboxCast(&box, self->facing, NULL);
}
void PlayerJabA_Enter(Player* self) {