GL - only 1 player can manipulate a object at a time
This commit is contained in:
parent
5ba57c1a72
commit
8a359bd1ba
|
@ -80,7 +80,7 @@ void AttatchmentMassDriver::ForcePush(const GameLogic::WEAPON_FIRE &usage, float
|
|||
{
|
||||
pushForce = Oyster::Math::Float4(this->owner->GetLookDir()) * (800);
|
||||
heldObject->ApplyImpulse((Oyster::Math::Float3)pushForce);
|
||||
|
||||
((DynamicObject*)(heldObject->GetCustomTag()))->RemoveManipulation();
|
||||
hasObject = false;
|
||||
heldObject = NULL;
|
||||
return;
|
||||
|
|
|
@ -309,6 +309,7 @@ using namespace GameLogic;
|
|||
|
||||
|
||||
obj->ApplyImpulse(((forcePushData*)(args))->pushForce);
|
||||
|
||||
|
||||
DynamicObject *dynamicObj = dynamic_cast<DynamicObject*>(realObj);
|
||||
|
||||
|
@ -333,12 +334,21 @@ using namespace GameLogic;
|
|||
Object* realObj = (Object*)(obj->GetCustomTag());
|
||||
//check so that it is an object that you can pickup
|
||||
|
||||
switch(realObj->GetObjectType())
|
||||
DynamicObject *dynamicObj = dynamic_cast<DynamicObject*>(realObj);
|
||||
|
||||
if(!dynamicObj) return;
|
||||
|
||||
if(dynamicObj->getManipulatingPlayer() != NULL)
|
||||
{
|
||||
return;
|
||||
}
|
||||
|
||||
switch(dynamicObj->GetObjectType())
|
||||
{
|
||||
case ObjectSpecialType::ObjectSpecialType_StandardBox:
|
||||
weapon->heldObject = obj; //weapon now holds the object
|
||||
weapon->hasObject = true;
|
||||
|
||||
dynamicObj->SetManipulatingPlayer(*weapon->owner); //TODO: add if this is to be a struggle of who has the most power in its weapon, the player that is already manipulating the object or you. if you then you take the object from the other player, if not then you do not take the object
|
||||
|
||||
break;
|
||||
}
|
||||
|
|
|
@ -12,6 +12,7 @@ DynamicObject::DynamicObject()
|
|||
this->isReleased = false;
|
||||
this->isActive = true;
|
||||
this->affectedBy = NULL;
|
||||
this->manipulatedBy = NULL;
|
||||
}
|
||||
|
||||
DynamicObject::DynamicObject(Oyster::Physics::ICustomBody *rigidBody , void (*EventOnCollision)(Oyster::Physics::ICustomBody *proto,Oyster::Physics::ICustomBody *deuter,Oyster::Math::Float kineticEnergyLoss), ObjectSpecialType type, int objectID)
|
||||
|
@ -20,6 +21,7 @@ DynamicObject::DynamicObject(Oyster::Physics::ICustomBody *rigidBody , void (*Ev
|
|||
this->isReleased = false;
|
||||
this->isActive = true;
|
||||
this->affectedBy = NULL;
|
||||
this->manipulatedBy = NULL;
|
||||
}
|
||||
DynamicObject::DynamicObject(Oyster::Physics::ICustomBody *rigidBody , Oyster::Physics::ICustomBody::SubscriptMessage (*EventOnCollision)(Oyster::Physics::ICustomBody *proto,Oyster::Physics::ICustomBody *deuter,Oyster::Math::Float kineticEnergyLoss), ObjectSpecialType type, int objectID)
|
||||
:Object(rigidBody, EventOnCollision, type, objectID)
|
||||
|
@ -27,6 +29,7 @@ DynamicObject::DynamicObject(Oyster::Physics::ICustomBody *rigidBody , Oyster::P
|
|||
this->isReleased = false;
|
||||
this->isActive = true;
|
||||
this->affectedBy = NULL;
|
||||
this->manipulatedBy = NULL;
|
||||
}
|
||||
|
||||
DynamicObject::DynamicObject(Oyster::Physics::ICustomBody *rigidBody , void (*EventOnCollision)(Oyster::Physics::ICustomBody *proto,Oyster::Physics::ICustomBody *deuter,Oyster::Math::Float kineticEnergyLoss), ObjectSpecialType type, int objectID, Oyster::Math::Float extraDamageOnCollision)
|
||||
|
@ -36,6 +39,7 @@ DynamicObject::DynamicObject(Oyster::Physics::ICustomBody *rigidBody , void (*Ev
|
|||
this->isReleased = false;
|
||||
this->isActive = true;
|
||||
this->affectedBy = NULL;
|
||||
this->manipulatedBy = NULL;
|
||||
}
|
||||
|
||||
DynamicObject::DynamicObject(Oyster::Physics::ICustomBody *rigidBody , Oyster::Physics::ICustomBody::SubscriptMessage (*EventOnCollision)(Oyster::Physics::ICustomBody *proto,Oyster::Physics::ICustomBody *deuter,Oyster::Math::Float kineticEnergyLoss), ObjectSpecialType type, int objectID, Oyster::Math::Float extraDamageOnCollision)
|
||||
|
@ -45,6 +49,7 @@ DynamicObject::DynamicObject(Oyster::Physics::ICustomBody *rigidBody , Oyster::P
|
|||
this->isReleased = false;
|
||||
this->isActive = true;
|
||||
this->affectedBy = NULL;
|
||||
this->manipulatedBy = NULL;
|
||||
}
|
||||
DynamicObject::~DynamicObject(void)
|
||||
{
|
||||
|
@ -100,4 +105,19 @@ Player* DynamicObject::getAffectingPlayer()
|
|||
void DynamicObject::RemoveAffectedBy()
|
||||
{
|
||||
this->affectedBy = NULL;
|
||||
}
|
||||
|
||||
GameLogic::Player* DynamicObject::getManipulatingPlayer()
|
||||
{
|
||||
return this->manipulatedBy;
|
||||
}
|
||||
|
||||
void DynamicObject::SetManipulatingPlayer(GameLogic::Player &player)
|
||||
{
|
||||
this->manipulatedBy = &player;
|
||||
}
|
||||
|
||||
void DynamicObject::RemoveManipulation()
|
||||
{
|
||||
this->manipulatedBy = NULL;
|
||||
}
|
|
@ -30,8 +30,11 @@ namespace GameLogic
|
|||
void Activate();
|
||||
|
||||
void SetAffectedBy(GameLogic::Player &player);
|
||||
void SetManipulatingPlayer(GameLogic::Player &player);
|
||||
void RemoveAffectedBy();
|
||||
void RemoveManipulation();
|
||||
GameLogic::Player* getAffectingPlayer();
|
||||
GameLogic::Player* getManipulatingPlayer();
|
||||
|
||||
static void DynamicObject::DynamicDefaultOnCollision(Oyster::Physics::ICustomBody *rigidBodyObject, Oyster::Physics::ICustomBody *obj, Oyster::Math::Float kineticEnergyLoss);
|
||||
|
||||
|
@ -40,6 +43,8 @@ namespace GameLogic
|
|||
bool isReleased;
|
||||
protected:
|
||||
GameLogic::Player *affectedBy;
|
||||
GameLogic::Player *manipulatedBy;
|
||||
|
||||
|
||||
};
|
||||
|
||||
|
|
|
@ -221,7 +221,7 @@ void Player::EndFrame()
|
|||
//check if there are any objects that can be removed from the AffectedObjects list
|
||||
for(int i = 0; i < this->AffectedObjects.Size(); i++)
|
||||
{
|
||||
if((this->AffectedObjects[i]->GetRigidBody()->GetState().previousVelocity).GetMagnitude() <= 0.1f)
|
||||
if(this->AffectedObjects[i] && (this->AffectedObjects[i]->GetRigidBody()->GetState().previousVelocity).GetMagnitude() <= 0.1f)
|
||||
{
|
||||
this->AffectedObjects[i]->RemoveAffectedBy();
|
||||
this->AffectedObjects.Remove(i);
|
||||
|
|
Loading…
Reference in New Issue