Vegastrike 0.5.1 rc1  1.0
Original sources for Vegastrike Evolved
 All Classes Namespaces Files Functions Variables Typedefs Enumerations Enumerator Friends Macros Groups Pages
BaseInterface::Room::Eject Class Reference

#include <base.h>

Inheritance diagram for BaseInterface::Room::Eject:
BaseInterface::Room::Link

Public Member Functions

virtual void Click (::BaseInterface *base, float x, float y, int button, int state)
 
virtual ~Eject ()
 
 Eject (const std::string &ind, const std::string &pythonfile)
 

Additional Inherited Members

Detailed Description

Definition at line 107 of file base.h.

Constructor & Destructor Documentation

virtual BaseInterface::Room::Eject::~Eject ( )
inlinevirtual

Definition at line 111 of file base.h.

111 {}
BaseInterface::Room::Eject::Eject ( const std::string &  ind,
const std::string &  pythonfile 
)
inlineexplicit

Definition at line 112 of file base.h.

112 : Link( ind, pythonfile ) {}

Member Function Documentation

void BaseInterface::Room::Eject::Click ( ::BaseInterface base,
float  x,
float  y,
int  button,
int  state 
)
virtual

Reimplemented from BaseInterface::Room::Link.

Definition at line 1254 of file base_interface.cpp.

References abletodock(), BaseInterface::baseun, c, BaseInterface::caller, BaseInterface::Room::Link::Click(), Order::Communicate(), Unit::EjectCargo(), CommunicationMessage::fsm, Unit::getAIState(), FSM::GetUnDockNode(), UnitContainer::GetUnit(), VegaConfig::getVariable(), Unit::Kill(), Unit::name, XMLSupport::parse_bool(), XMLSupport::parse_float(), randyVector(), Unit::SetAngularVelocity(), CommunicationMessage::SetCurrentState(), Unit::SetOwner(), Unit::SetPosAndCumPos(), Unit::SetVelocity(), BaseInterface::Terminate(), Unit::UnDock(), Vector, Unit::Velocity, vs_config, and WS_MOUSE_UP.

1255 {
1256  if (state == WS_MOUSE_UP) {
1257  Link::Click( base, x, y, button, state );
1258  XMLSupport::parse_bool( vs_config->getVariable( "physics", "AutomaticUnDock", "true" ) );
1259  Unit *bas = base->baseun.GetUnit();
1260  Unit *playa = base->caller.GetUnit();
1261  if (playa && bas) {
1262  if (playa->name == "return_to_cockpit") {
1263  playa->name = "ejecting";
1264  Vector tmpvel = bas->Velocity* -1;
1265  if (tmpvel.MagnitudeSquared() < .00001) {
1266  tmpvel = randyVector( -( bas->rSize() ), bas->rSize() ).Cast();
1267  if (tmpvel.MagnitudeSquared() < .00001)
1268  tmpvel = Vector( 1, 1, 1 );
1269  }
1270  tmpvel.Normalize();
1271  playa->SetPosAndCumPos( bas->Position()+tmpvel*1.5*bas->rSize()+randyVector( -.5*bas->rSize(), .5*bas->rSize() ) );
1272  playa->SetAngularVelocity( bas->AngularVelocity );
1273  playa->SetOwner( bas );
1274  static float velmul = XMLSupport::parse_float( vs_config->getVariable( "physics", "eject_cargo_speed", "1" ) );
1275  playa->SetVelocity( bas->Velocity*velmul+randyVector( -.25, .25 ).Cast() );
1276  }
1277  playa->UnDock( bas );
1278  CommunicationMessage c( bas, playa, NULL, 0 );
1279  c.SetCurrentState( c.fsm->GetUnDockNode(), NULL, 0 );
1280  if ( playa->getAIState() )
1281  playa->getAIState()->Communicate( c );
1282  abletodock( 5 );
1283  playa->EjectCargo( (unsigned int) -1 );
1284  if ( (playa->name == "return_to_cockpit") || (playa->name == "ejecting") || (playa->name == "eject")
1285  || (playa->name == "Eject") || (playa->name == "Pilot") || (playa->name == "pilot") )
1286  playa->Kill();
1287  }
1288  base->Terminate();
1289  }
1290 }

The documentation for this class was generated from the following files: