Merge pull request #36 from Deconimus/encapsulate_decorIdFromCollisionObject

Encapsulate looking up a decorId from CollisionObjects
This commit is contained in:
Matt Penny 2024-03-11 23:29:16 -04:00 committed by GitHub
commit 87af5a059c
No known key found for this signature in database
GPG key ID: B5690EEEBB952194
4 changed files with 9 additions and 4 deletions

View file

@ -236,4 +236,8 @@ int decorIdForObjectDefinition(struct DecorObjectDefinition* def) {
}
return result;
}
}
int decorIdForCollisionObject(struct CollisionObject* collisionObject) {
return decorIdForObjectDefinition((struct DecorObjectDefinition*)collisionObject->collider);
}

View file

@ -19,4 +19,6 @@
struct DecorObjectDefinition* decorObjectDefinitionForId(int id);
int decorIdForObjectDefinition(struct DecorObjectDefinition* def);
int decorIdForCollisionObject(struct CollisionObject* collisionObject); // evil hack
#endif

View file

@ -26,7 +26,7 @@ void fizzlerTrigger(void* data, struct CollisionObject* objectEnteringTrigger) {
}
if (fizzler->cubeSignalIndex != -1) {
int decorType = decorIdForObjectDefinition((struct DecorObjectDefinition*)objectEnteringTrigger->collider);
int decorType = decorIdForCollisionObject(objectEnteringTrigger);
if (decorType == DECOR_TYPE_CUBE || decorType == DECOR_TYPE_CUBE_UNIMPORTANT) {
signalsSend(fizzler->cubeSignalIndex);
}

View file

@ -15,8 +15,7 @@ enum ObjectTriggerType triggerDetermineType(struct CollisionObject* objectEnteri
return TRIGGER_TYPE_TO_MASK(ObjectTriggerTypePlayer);
}
int decorType = decorIdForObjectDefinition((struct DecorObjectDefinition*)objectEnteringTrigger->collider);
int decorType = decorIdForCollisionObject(objectEnteringTrigger);
if (decorType == DECOR_TYPE_CUBE || decorType == DECOR_TYPE_CUBE_UNIMPORTANT) {
return gScene.player.grabConstraint.object == objectEnteringTrigger ? TRIGGER_TYPE_TO_MASK(ObjectTriggerTypeCubeHover) | TRIGGER_TYPE_TO_MASK(ObjectTriggerTypeCube) : TRIGGER_TYPE_TO_MASK(ObjectTriggerTypeCube);
}