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

Function ObjSetPos

engine/Poseidon/Game/Commands/GameStateExtGrp.cpp:1696–1809  ·  view source on GitHub ↗

Source from the content-addressed store, hash-verified

1694}
1695
1696GameValue ObjSetPos(const GameState* state, GameValuePar oper1, GameValuePar oper2)
1697{
1698 Object* obj1 = GetObject(oper1);
1699 if (!obj1)
1700 {
1701 return NOTHING;
1702 }
1703
1704 Vector3 pos;
1705 if (!GetRelPos(state, pos, oper2))
1706 {
1707 return NOTHING;
1708 }
1709 if (obj1->GetType() == Primary || obj1->GetType() == Network)
1710 {
1711 return NOTHING;
1712 }
1713
1714 // let vehicle adjust position
1715
1716 Matrix4 trans = obj1->Transform();
1717
1718 EntityAI* veh = dyn_cast<EntityAI>(obj1);
1719 if (veh)
1720 {
1721 trans.SetPosition(pos);
1722 veh->PlaceOnSurface(trans);
1723 Vector3 surfPos = trans.Position();
1724 surfPos[1] += pos[1];
1725 trans.SetPosition(surfPos);
1726 if (veh->GetType()->HasDriver() && pos[1] > 0.1f)
1727 {
1728 veh->IsMoved();
1729 }
1730 }
1731 else
1732 {
1733 LODShape* shape = obj1->GetShape();
1734 if (!shape)
1735 {
1736 return NOTHING;
1737 }
1738 Shape* geom = shape->LandContactLevel();
1739 if (!geom)
1740 {
1741 geom = shape->GeometryLevel();
1742 }
1743 if (!geom)
1744 {
1745 geom = shape->Level(0);
1746 }
1747 if (geom)
1748 {
1749 pos[1] += geom->Min().Y();
1750 }
1751 else
1752 {
1753 pos[1] += shape->Min().Y();

Callers

nothing calls this directly

Calls 15

GetRelPosFunction · 0.85
IsMovedMethod · 0.80
LandContactLevelMethod · 0.80
GeometryLevelMethod · 0.80
LevelMethod · 0.80
BrainMethod · 0.80
GetVehicleInMethod · 0.80
FocusOnMethod · 0.80
GetOutFinishedMethod · 0.80
DriverMethod · 0.80
GetOutDriverMethod · 0.80

Tested by

no test coverage detected