Differential D13 Diff 6558 binaries/data/mods/public/simulation/components/tests/test_UnitMotionFlying.js
Changeset View
Changeset View
Standalone View
Standalone View
binaries/data/mods/public/simulation/components/tests/test_UnitMotionFlying.js
Show All 28 Lines | |||||
TS_ASSERT_EQUALS(cmpUnitMotionFlying.GetSpeedRatio(), 0); | TS_ASSERT_EQUALS(cmpUnitMotionFlying.GetSpeedRatio(), 0); | ||||
TS_ASSERT_EQUALS(cmpUnitMotionFlying.GetRunSpeedMultiplier(), 1); | TS_ASSERT_EQUALS(cmpUnitMotionFlying.GetRunSpeedMultiplier(), 1); | ||||
TS_ASSERT_EQUALS(cmpUnitMotionFlying.GetCurrentSpeed(), 0); | TS_ASSERT_EQUALS(cmpUnitMotionFlying.GetCurrentSpeed(), 0); | ||||
cmpUnitMotionFlying.SetSpeedRatio(2); | cmpUnitMotionFlying.SetSpeedRatio(2); | ||||
TS_ASSERT_EQUALS(cmpUnitMotionFlying.GetSpeedRatio(), 0); | TS_ASSERT_EQUALS(cmpUnitMotionFlying.GetSpeedRatio(), 0); | ||||
TS_ASSERT_EQUALS(cmpUnitMotionFlying.GetRunSpeedMultiplier(), 1); | TS_ASSERT_EQUALS(cmpUnitMotionFlying.GetRunSpeedMultiplier(), 1); | ||||
TS_ASSERT_EQUALS(cmpUnitMotionFlying.GetCurrentSpeed(), 0); | TS_ASSERT_EQUALS(cmpUnitMotionFlying.GetCurrentSpeed(), 0); | ||||
TS_ASSERT_EQUALS(cmpUnitMotionFlying.GetPassabilityClassName(), "unrestricted"); | |||||
TS_ASSERT_EQUALS(cmpUnitMotionFlying.GetPassabilityClass(), 1 << 8); | |||||
AddMock(entity, IID_Position, { | AddMock(entity, IID_Position, { | ||||
"IsInWorld": () => true, | "IsInWorld": () => true, | ||||
"GetPosition2D": () => { return { "x": 50, "y": 100 }; }, | "GetPosition2D": () => { return { "x": 50, "y": 100 }; }, | ||||
"GetPosition": () => { return { "x": 50, "y": height, "z": 100 }; }, | "GetPosition": () => { return { "x": 50, "y": height, "z": 100 }; }, | ||||
"GetRotation": () => { return { "y": 3.14 }; }, | "GetRotation": () => { return { "y": 3.14 }; }, | ||||
"SetHeightFixed": (y) => height = y, | "SetHeightFixed": (y) => height = y, | ||||
"TurnTo": () => {}, | "TurnTo": () => {}, | ||||
"SetXZRotation": () => {}, | "SetXZRotation": () => {}, | ||||
Show All 25 Lines | AddMock(entity, IID_WaterManager, { | ||||
"GetWaterLevel": () => 5 | "GetWaterLevel": () => 5 | ||||
}); | }); | ||||
TS_ASSERT_EQUALS(cmpUnitMotionFlying.GetCurrentSpeed(), 0); | TS_ASSERT_EQUALS(cmpUnitMotionFlying.GetCurrentSpeed(), 0); | ||||
cmpUnitMotionFlying.OnUpdate({ "turnLength": 500 }); | cmpUnitMotionFlying.OnUpdate({ "turnLength": 500 }); | ||||
TS_ASSERT_EQUALS(cmpUnitMotionFlying.GetCurrentSpeed(), 0); | TS_ASSERT_EQUALS(cmpUnitMotionFlying.GetCurrentSpeed(), 0); | ||||
TS_ASSERT_EQUALS(cmpUnitMotionFlying.GetSpeedRatio(), 0); | TS_ASSERT_EQUALS(cmpUnitMotionFlying.GetSpeedRatio(), 0); | ||||
TS_ASSERT_EQUALS(cmpUnitMotionFlying.MoveToTargetRange(target, 0, 10), true); | TS_ASSERT_EQUALS(cmpUnitMotionFlying.SetNewDestinationAsEntity(target, 10), true); | ||||
TS_ASSERT_EQUALS(cmpUnitMotionFlying.MoveToPointRange(100, 200, 0, 20), true); | TS_ASSERT_EQUALS(cmpUnitMotionFlying.SetNewDestinationAsPosition(100, 200, 20), true); | ||||
// Take Off | // Take Off | ||||
cmpUnitMotionFlying.OnUpdate({ "turnLength": 500 }); | cmpUnitMotionFlying.OnUpdate({ "turnLength": 500 }); | ||||
TS_ASSERT_EQUALS(cmpUnitMotionFlying.GetCurrentSpeed(), 0.25); | TS_ASSERT_EQUALS(cmpUnitMotionFlying.GetCurrentSpeed(), 0.25); | ||||
TS_ASSERT_EQUALS(height, 5); | TS_ASSERT_EQUALS(height, 5); | ||||
cmpUnitMotionFlying.OnUpdate({ "turnLength": 500 }); | cmpUnitMotionFlying.OnUpdate({ "turnLength": 500 }); | ||||
TS_ASSERT_EQUALS(cmpUnitMotionFlying.GetCurrentSpeed(), 0.5); | TS_ASSERT_EQUALS(cmpUnitMotionFlying.GetCurrentSpeed(), 0.5); | ||||
TS_ASSERT_EQUALS(height, 5); | TS_ASSERT_EQUALS(height, 5); | ||||
Show All 15 Lines | |||||
cmpUnitMotionFlying.OnUpdate({ "turnLength": 500 }); | cmpUnitMotionFlying.OnUpdate({ "turnLength": 500 }); | ||||
TS_ASSERT_EQUALS(cmpUnitMotionFlying.GetCurrentSpeed(), 1); | TS_ASSERT_EQUALS(cmpUnitMotionFlying.GetCurrentSpeed(), 1); | ||||
TS_ASSERT_EQUALS(height, 105); | TS_ASSERT_EQUALS(height, 105); | ||||
cmpUnitMotionFlying.OnUpdate({ "turnLength": 0 }); | cmpUnitMotionFlying.OnUpdate({ "turnLength": 0 }); | ||||
TS_ASSERT_EQUALS(cmpUnitMotionFlying.GetCurrentSpeed(), 1); | TS_ASSERT_EQUALS(cmpUnitMotionFlying.GetCurrentSpeed(), 1); | ||||
TS_ASSERT_EQUALS(height, 105); | TS_ASSERT_EQUALS(height, 105); | ||||
// Land | // Land | ||||
cmpUnitMotionFlying.StopMoving(); | cmpUnitMotionFlying.DiscardMove(); | ||||
cmpUnitMotionFlying.OnUpdate({ "turnLength": 0 }); | cmpUnitMotionFlying.OnUpdate({ "turnLength": 0 }); | ||||
TS_ASSERT_EQUALS(cmpUnitMotionFlying.GetCurrentSpeed(), 1); | TS_ASSERT_EQUALS(cmpUnitMotionFlying.GetCurrentSpeed(), 1); | ||||
TS_ASSERT_EQUALS(height, 105); | TS_ASSERT_EQUALS(height, 105); | ||||
cmpUnitMotionFlying.OnUpdate({ "turnLength": 500 }); | cmpUnitMotionFlying.OnUpdate({ "turnLength": 500 }); | ||||
TS_ASSERT_EQUALS(cmpUnitMotionFlying.GetCurrentSpeed(), 0.5); | TS_ASSERT_EQUALS(cmpUnitMotionFlying.GetCurrentSpeed(), 0.5); | ||||
TS_ASSERT_EQUALS(height, 5); | TS_ASSERT_EQUALS(height, 5); | ||||
// Slide | // Slide | ||||
Show All 21 Lines |
Wildfire Games · Phabricator