feat: replaced mirror_get_converter with a more direct mirror_get_typeclass

This commit is contained in:
Sara 2024-01-11 23:51:53 +01:00
parent 1a3c4c9676
commit 760d9f2879
3 changed files with 13 additions and 11 deletions

View file

@ -1,4 +1,5 @@
#include "PlayerStates.h"
#include "mirror.h"
#include "physics_world.h"
#include "Damagable.h"
@ -59,14 +60,13 @@ void PlayerAttackTrigger(Player* self) {
MakeVector(0.1f, 0.06f), PHYSICS_LAYER_COMBAT, self->rigidbody);
if(found != NULL) {
PhysicsEntity entity = collider_get_owner(found);
Damagable(*const as_damagable)(void*) = mirror_get_converter(entity.data, entity.mirror, "Damagable");
if(as_damagable) {
Damagable damagable = as_damagable(entity.data);
const IDamagable* damagable = mirror_get_typeclass(entity.data, entity.mirror, "Damagable");
if(damagable) {
DamageEventData data = {
.damageAmount = 1,
.origin = self->transform.position
};
damagable.tc->damage(entity.data, &data);
damagable->damage(entity.data, &data);
}
}
++self->animationTriggers;