Added different types of collision triggered scripts. Only available on a couple of tracks for testing at the moment

This commit is contained in:
Sachith Hasaranga Seneviratne 2014-07-08 17:52:47 +05:30
parent 6b70ea36af
commit 008bf124ba
4 changed files with 30 additions and 8 deletions

View File

@ -1,4 +1,15 @@
void onCollision()
void onKartObjectCollision()
{
}
void onItemObjectCollision()
{
}
void onKartKartCollision()
{
}

View File

@ -1,4 +1,4 @@
void onCollision()
void onKartObjectCollision()
{
displayMessage("Woot! You hit item of ID: " + getCollidingID());
@ -6,3 +6,14 @@ disableAnimation(getCollidingID());
Vec3 explosion_loc = Vec3(79.53,0.07,97.13);
createExplosion(explosion_loc);
}
void onItemObjectCollision()
{
}
void onKartKartCollision()
{
}

View File

@ -174,7 +174,7 @@ void Physics::update(float dt)
int kartid1 = p->getUserPointer(0)->getPointerKart()->getWorldKartId();
int kartid2 = p->getUserPointer(1)->getPointerKart()->getWorldKartId();
Scripting::Physics::setCollision(kartid1,kartid2);
Scripting::Physics::setCollisionType("Kart-Kart");
Scripting::Physics::setCollisionType("KartKart");
script_engine->runScript("collisions");
continue;
} // if kart-kart collision
@ -184,8 +184,8 @@ void Physics::update(float dt)
// Kart hits physical object
// -------------------------
Scripting::ScriptEngine* script_engine = World::getWorld()->getScriptEngine();
Scripting::Physics::setCollision(0, 0); //TODO : support item types etc
Scripting::Physics::setCollisionType("Kart-PhysObj");
Scripting::Physics::setCollision(0, 0);
Scripting::Physics::setCollisionType("KartObject"); //object as in physical object
Scripting::Physics::setCollision
(
p->getUserPointer(0)->getPointerPhysicalObject()->getID(),
@ -256,7 +256,7 @@ void Physics::update(float dt)
// -------------------------------
Scripting::ScriptEngine* script_engine = World::getWorld()->getScriptEngine();
Scripting::Physics::setCollision(0,0); //TODO : support item types etc
Scripting::Physics::setCollisionType("Projectile-PhysObj");
Scripting::Physics::setCollisionType("ItemObject");
Scripting::Physics::setCollision
(
p->getUserPointer(1)->getPointerPhysicalObject()->getID(),

View File

@ -67,11 +67,11 @@ namespace Scripting
{
m_collisionType = collisionType;
}
asIScriptFunction* registerScriptCallbacks(asIScriptEngine *engine)
{
asIScriptFunction *func;
func = engine->GetModule(0)->GetFunctionByDecl("void onCollision()");
std::string function_name = "void on" + m_collisionType + "Collision()";
func = engine->GetModule(0)->GetFunctionByDecl(function_name.c_str());
return func;
}
void registerScriptFunctions(asIScriptEngine *engine)