Differential D1840 Diff 7971 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 20 Lines | let cmpUnitMotionFlying = ConstructComponent(entity, "UnitMotionFlying", { | ||||
"TurnRate": 0.1, | "TurnRate": 0.1, | ||||
"OvershootTime": 10, | "OvershootTime": 10, | ||||
"FlyingHeight": 100, | "FlyingHeight": 100, | ||||
"ClimbRate": 0.1, | "ClimbRate": 0.1, | ||||
"DiesInWater": false, | "DiesInWater": false, | ||||
"PassabilityClass": "unrestricted" | "PassabilityClass": "unrestricted" | ||||
}); | }); | ||||
TS_ASSERT_EQUALS(cmpUnitMotionFlying.GetSpeedRatio(), 0); | TS_ASSERT_EQUALS(cmpUnitMotionFlying.GetSpeedMultiplier(), 0); | ||||
TS_ASSERT_EQUALS(cmpUnitMotionFlying.GetRunSpeedMultiplier(), 1); | TS_ASSERT_EQUALS(cmpUnitMotionFlying.GetRunMultiplier(), 1); | ||||
TS_ASSERT_EQUALS(cmpUnitMotionFlying.GetCurrentSpeed(), 0); | TS_ASSERT_EQUALS(cmpUnitMotionFlying.GetCurrentSpeed(), 0); | ||||
cmpUnitMotionFlying.SetSpeedRatio(2); | cmpUnitMotionFlying.SetSpeedMultiplier(2); | ||||
TS_ASSERT_EQUALS(cmpUnitMotionFlying.GetSpeedRatio(), 0); | TS_ASSERT_EQUALS(cmpUnitMotionFlying.GetSpeedMultiplier(), 0); | ||||
TS_ASSERT_EQUALS(cmpUnitMotionFlying.GetRunSpeedMultiplier(), 1); | TS_ASSERT_EQUALS(cmpUnitMotionFlying.GetRunMultiplier(), 1); | ||||
TS_ASSERT_EQUALS(cmpUnitMotionFlying.GetCurrentSpeed(), 0); | TS_ASSERT_EQUALS(cmpUnitMotionFlying.GetCurrentSpeed(), 0); | ||||
elexis: (Looks better than before, no?) | |||||
TS_ASSERT_EQUALS(cmpUnitMotionFlying.GetPassabilityClassName(), "unrestricted"); | TS_ASSERT_EQUALS(cmpUnitMotionFlying.GetPassabilityClassName(), "unrestricted"); | ||||
TS_ASSERT_EQUALS(cmpUnitMotionFlying.GetPassabilityClass(), 1 << 8); | 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 }; }, | ||||
Show All 31 Lines | |||||
AddMock(entity, IID_WaterManager, { | 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.GetSpeedMultiplier(), 0); | ||||
TS_ASSERT_EQUALS(cmpUnitMotionFlying.MoveToTargetRange(target, 0, 10), true); | TS_ASSERT_EQUALS(cmpUnitMotionFlying.MoveToTargetRange(target, 0, 10), true); | ||||
TS_ASSERT_EQUALS(cmpUnitMotionFlying.MoveToPointRange(100, 200, 0, 20), true); | TS_ASSERT_EQUALS(cmpUnitMotionFlying.MoveToPointRange(100, 200, 0, 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); | ||||
cmpUnitMotionFlying.OnUpdate({ "turnLength": 0 }); | cmpUnitMotionFlying.OnUpdate({ "turnLength": 0 }); | ||||
TS_ASSERT_EQUALS(cmpUnitMotionFlying.GetCurrentSpeed(), 0.5); | TS_ASSERT_EQUALS(cmpUnitMotionFlying.GetCurrentSpeed(), 0.5); | ||||
TS_ASSERT_EQUALS(height, 5); | TS_ASSERT_EQUALS(height, 5); | ||||
cmpUnitMotionFlying.OnUpdate({ "turnLength": 500 }); | cmpUnitMotionFlying.OnUpdate({ "turnLength": 500 }); | ||||
TS_ASSERT_EQUALS(cmpUnitMotionFlying.GetCurrentSpeed(), 0.75); | TS_ASSERT_EQUALS(cmpUnitMotionFlying.GetCurrentSpeed(), 0.75); | ||||
TS_ASSERT_EQUALS(height, 55); | TS_ASSERT_EQUALS(height, 55); | ||||
cmpUnitMotionFlying.OnUpdate({ "turnLength": 500 }); | cmpUnitMotionFlying.OnUpdate({ "turnLength": 500 }); | ||||
TS_ASSERT_EQUALS(cmpUnitMotionFlying.GetCurrentSpeed(), 1); | TS_ASSERT_EQUALS(cmpUnitMotionFlying.GetCurrentSpeed(), 1); | ||||
TS_ASSERT_EQUALS(cmpUnitMotionFlying.GetSpeedRatio(), 1); | TS_ASSERT_EQUALS(cmpUnitMotionFlying.GetSpeedMultiplier(), 1); | ||||
TS_ASSERT_EQUALS(height, 105); | TS_ASSERT_EQUALS(height, 105); | ||||
// Fly | // Fly | ||||
cmpUnitMotionFlying.OnUpdate({ "turnLength": 100 }); | cmpUnitMotionFlying.OnUpdate({ "turnLength": 100 }); | ||||
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(), 1); | TS_ASSERT_EQUALS(cmpUnitMotionFlying.GetCurrentSpeed(), 1); | ||||
Show All 36 Lines |
Wildfire Games · Phabricator
(Looks better than before, no?)