mirror of
https://github.com/TorqueGameEngines/Torque3D.git
synced 2026-01-19 20:24:49 +00:00
add strikeObject functionality feature
This commit is contained in:
parent
8b4b467bff
commit
3cd82d9229
|
|
@ -863,11 +863,47 @@ void Lightning::strikeRandomPoint()
|
|||
}
|
||||
|
||||
//--------------------------------------------------------------------------
|
||||
void Lightning::strikeObject(ShapeBase*)
|
||||
void Lightning::strikeObject(ShapeBase* targetObj)
|
||||
{
|
||||
AssertFatal(isServerObject(), "Error, client objects may not initiate lightning!");
|
||||
|
||||
AssertFatal(false, "Lightning::strikeObject is not implemented.");
|
||||
Point3F strikePoint = targetObj->getPosition();
|
||||
Point3F objectCenter;
|
||||
|
||||
targetObj->getObjBox().getCenter(&objectCenter);
|
||||
objectCenter.convolve(targetObj->getScale());
|
||||
targetObj->getTransform().mulP(objectCenter);
|
||||
|
||||
bool playerInWarmup = false;
|
||||
Player *playerObj = dynamic_cast< Player * >(targetObj);
|
||||
if (playerObj)
|
||||
{
|
||||
if (!playerObj->getControllingClient())
|
||||
{
|
||||
playerInWarmup = true;
|
||||
}
|
||||
}
|
||||
|
||||
if (!playerInWarmup)
|
||||
{
|
||||
applyDamage_callback(objectCenter, VectorF(0.0, 0.0, 1.0), targetObj);
|
||||
}
|
||||
|
||||
SimGroup* pClientGroup = Sim::getClientGroup();
|
||||
for (SimGroup::iterator itr = pClientGroup->begin(); itr != pClientGroup->end(); itr++) {
|
||||
NetConnection* nc = static_cast<NetConnection*>(*itr);
|
||||
if (nc != NULL)
|
||||
{
|
||||
LightningStrikeEvent* pEvent = new LightningStrikeEvent;
|
||||
pEvent->mLightning = this;
|
||||
|
||||
pEvent->mStart.x = strikePoint.x;
|
||||
pEvent->mStart.y = strikePoint.y;
|
||||
pEvent->mTarget = targetObj;
|
||||
|
||||
nc->postNetEvent(pEvent);
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
|
|
|
|||
|
|
@ -229,7 +229,7 @@ class Lightning : public GameBase
|
|||
|
||||
void warningFlashes();
|
||||
void strikeRandomPoint();
|
||||
void strikeObject(ShapeBase*);
|
||||
void strikeObject(ShapeBase* targetObj);
|
||||
void processEvent(LightningStrikeEvent*);
|
||||
|
||||
DECLARE_CONOBJECT(Lightning);
|
||||
|
|
|
|||
Loading…
Reference in a new issue