MCPcopy Create free account
hub / github.com/BohemiaInteractive/CWR / ObjMoveInDriver

Function ObjMoveInDriver

engine/Poseidon/Game/Commands/GameStateExtUi.cpp:2675–2730  ·  view source on GitHub ↗

Source from the content-addressed store, hash-verified

2673 {
2674 GWorld->SwitchCameraTo(veh, ValidateCamera(GWorld->GetCameraType()));
2675 }
2676 }
2677 return NOTHING;
2678}
2679
2680GameValue ObjMoveInDriver(const GameState* state, GameValuePar oper1, GameValuePar oper2)
2681{
2682 Object* obj1 = GetObject(oper1);
2683 if (!obj1)
2684 {
2685 return NOTHING;
2686 }
2687 Person* soldier = dyn_cast<Person>(obj1);
2688 if (!soldier)
2689 {
2690 return NOTHING;
2691 }
2692 if (!soldier->IsLocal())
2693 {
2694 return NOTHING;
2695 }
2696 AIUnit* unit = soldier->Brain();
2697 if (!unit)
2698 {
2699 return NOTHING;
2700 }
2701
2702 Object* obj2 = GetObject(oper2);
2703 if (!obj2)
2704 {
2705 return NOTHING;
2706 }
2707 Transport* veh = dyn_cast<Transport>(obj2);
2708 if (!veh)
2709 {
2710 return NOTHING;
2711 }
2712 if (!PrepareMoveIn(unit, veh))
2713 {
2714 return NOTHING;
2715 }
2716
2717 if (veh->QCanIGetIn(soldier))
2718 {
2719 if (veh->IsLocal())
2720 {
2721 veh->GetInDriver(soldier, false);
2722 }
2723 else
2724 {
2725 GetNetworkManager().AskForGetIn(soldier, veh, GIPDriver);
2726 }
2727 soldier->Brain()->AssignAsDriver(veh);
2728 soldier->Brain()->OrderGetIn(true);
2729 if (GWorld->FocusOn() == soldier->Brain() && veh->IsLocal())
2730 {
2731 GWorld->SwitchCameraTo(veh, ValidateCamera(GWorld->GetCameraType()));
2732 }

Callers

nothing calls this directly

Calls 13

PrepareMoveInFunction · 0.85
ValidateCameraFunction · 0.85
BrainMethod · 0.80
GetInDriverMethod · 0.80
AssignAsDriverMethod · 0.80
OrderGetInMethod · 0.80
FocusOnMethod · 0.80
SwitchCameraToMethod · 0.80
GetCameraTypeMethod · 0.80
GetObjectFunction · 0.70
IsLocalMethod · 0.45
QCanIGetInMethod · 0.45

Tested by

no test coverage detected