mirror of
https://github.com/libretro/scummvm.git
synced 2025-01-05 09:10:29 +00:00
GRIM: Implemented the collision handler callback function.
This commit is contained in:
parent
9b8f540ccd
commit
9e260c58a4
@ -640,7 +640,7 @@ void Actor::moveTo(const Graphics::Vector3d &pos) {
|
||||
if (_collisionMode != CollisionOff) {
|
||||
for (GrimEngine::ActorListType::const_iterator i = g_grim->actorsBegin(); i != g_grim->actorsEnd(); ++i) {
|
||||
Actor *a = i->_value;
|
||||
if (a != this && a->isInSet(g_grim->getSceneName()) && a->isVisible()) {
|
||||
if (a != this && a->isInSet(_setName) && a->isVisible()) {
|
||||
collidesWith(a, &v);
|
||||
}
|
||||
}
|
||||
@ -1487,6 +1487,7 @@ bool Actor::collidesWith(Actor *actor, Graphics::Vector3d *vec) const {
|
||||
v *= size1 + size2;
|
||||
*vec = v + p2 - p1;
|
||||
|
||||
collisionHandlerCallback(actor);
|
||||
return true;
|
||||
}
|
||||
} else if (mode1 == CollisionBox && mode2 == CollisionBox) {
|
||||
@ -1595,6 +1596,7 @@ bool Actor::collidesWith(Actor *actor, Graphics::Vector3d *vec) const {
|
||||
float z = vec->z();
|
||||
*vec = point - circlePos;
|
||||
vec->z() = z;
|
||||
collisionHandlerCallback(actor);
|
||||
return true;
|
||||
}
|
||||
}
|
||||
@ -1630,4 +1632,30 @@ void Actor::costumeMarkerCallback(int marker) {
|
||||
lua_endblock();
|
||||
}
|
||||
|
||||
void Actor::collisionHandlerCallback(Actor *other) const {
|
||||
lua_beginblock();
|
||||
|
||||
lua_pushobject(lua_getref(refSystemTable));
|
||||
lua_pushstring("collisionHandler");
|
||||
lua_Object table = lua_gettable();
|
||||
|
||||
if (lua_istable(table)) {
|
||||
lua_pushobject(table);
|
||||
lua_pushstring("collisionHandler");
|
||||
lua_Object func = lua_gettable();
|
||||
if (lua_isfunction(func)) {
|
||||
lua_pushobject(func);
|
||||
lua_pushusertag(getId(), MKTAG('A','C','T','R'));
|
||||
lua_pushusertag(other->getId(), MKTAG('A','C','T','R'));
|
||||
lua_callfunction(func);
|
||||
}
|
||||
} else if (lua_isfunction(table)) {
|
||||
lua_pushusertag(getId(), MKTAG('A','C','T','R'));
|
||||
lua_pushusertag(other->getId(), MKTAG('A','C','T','R'));
|
||||
lua_callfunction(table);
|
||||
}
|
||||
|
||||
lua_endblock();
|
||||
}
|
||||
|
||||
} // end of namespace Grim
|
||||
|
@ -452,6 +452,7 @@ public:
|
||||
|
||||
private:
|
||||
void costumeMarkerCallback(int marker);
|
||||
void collisionHandlerCallback(Actor *other) const;
|
||||
void updateWalk();
|
||||
void addShadowPlane(const char *n, Scene *scene, int shadowId);
|
||||
bool shouldDrawShadow(int shadowId);
|
||||
|
@ -59,7 +59,7 @@ void Object::dereference() {
|
||||
}
|
||||
}
|
||||
|
||||
int32 Object::getId() {
|
||||
int32 Object::getId() const {
|
||||
return _id;
|
||||
}
|
||||
|
||||
|
@ -46,7 +46,7 @@ public:
|
||||
void reference();
|
||||
void dereference();
|
||||
|
||||
int32 getId();
|
||||
int32 getId() const;
|
||||
|
||||
private:
|
||||
void setId(int32 id);
|
||||
|
Loading…
Reference in New Issue
Block a user