Changeset View
Changeset View
Standalone View
Standalone View
binaries/data/mods/public/simulation/components/tests/test_UnitAI.js
Show First 20 Lines • Show All 86 Lines • ▼ Show 20 Lines | TestTargetEntityRenaming( | ||||
(unitAI, player_ent, target_ent) => { | (unitAI, player_ent, target_ent) => { | ||||
DistanceBetweenEntities = () => 10; | DistanceBetweenEntities = () => 10; | ||||
unitAI.CheckTargetRangeExplicit = () => false; | unitAI.CheckTargetRangeExplicit = () => false; | ||||
AddMock(player_ent, IID_UnitMotion, { | AddMock(player_ent, IID_UnitMotion, { | ||||
"MoveToTargetRange": () => true, | "MoveToTargetRange": () => true, | ||||
"GetRunMultiplier": () => 1, | "GetRunMultiplier": () => 1, | ||||
"SetSpeedMultiplier": () => {}, | "SetSpeedMultiplier": () => {}, | ||||
"GetAcceleration": () => 1, | |||||
"StopMoving": () => {} | "StopMoving": () => {} | ||||
}); | }); | ||||
unitAI.Flee(target_ent, false); | unitAI.Flee(target_ent, false); | ||||
} | } | ||||
); | ); | ||||
/* Regression test. | /* Regression test. | ||||
▲ Show 20 Lines • Show All 63 Lines • ▼ Show 20 Lines | AddMock(unit, IID_Position, { | ||||
GetPosition: function() { return new Vector3D(); }, | GetPosition: function() { return new Vector3D(); }, | ||||
GetPosition2D: function() { return new Vector2D(); }, | GetPosition2D: function() { return new Vector2D(); }, | ||||
GetRotation: function() { return { "y": 0 }; }, | GetRotation: function() { return { "y": 0 }; }, | ||||
IsInWorld: function() { return true; }, | IsInWorld: function() { return true; }, | ||||
}); | }); | ||||
AddMock(unit, IID_UnitMotion, { | AddMock(unit, IID_UnitMotion, { | ||||
"GetWalkSpeed": () => 1, | "GetWalkSpeed": () => 1, | ||||
"GetAcceleration": () => 1, | |||||
"MoveToFormationOffset": (target, x, z) => {}, | "MoveToFormationOffset": (target, x, z) => {}, | ||||
"MoveToTargetRange": (target, min, max) => true, | "MoveToTargetRange": (target, min, max) => true, | ||||
"StopMoving": () => {}, | "StopMoving": () => {}, | ||||
"SetFacePointAfterMove": () => {}, | "SetFacePointAfterMove": () => {}, | ||||
"GetFacePointAfterMove": () => true, | "GetFacePointAfterMove": () => true, | ||||
"GetPassabilityClassName": () => "default" | "GetPassabilityClassName": () => "default" | ||||
}); | }); | ||||
▲ Show 20 Lines • Show All 55 Lines • ▼ Show 20 Lines | AddMock(controller, IID_Position, { | ||||
IsInWorld: function() { return true; }, | IsInWorld: function() { return true; }, | ||||
MoveOutOfWorld: () => {} | MoveOutOfWorld: () => {} | ||||
}); | }); | ||||
AddMock(controller, IID_UnitMotion, { | AddMock(controller, IID_UnitMotion, { | ||||
"GetWalkSpeed": () => 1, | "GetWalkSpeed": () => 1, | ||||
"StopMoving": () => {}, | "StopMoving": () => {}, | ||||
"SetSpeedMultiplier": () => {}, | "SetSpeedMultiplier": () => {}, | ||||
"SetAcceleration": (accel) => {}, | |||||
"MoveToPointRange": () => true, | "MoveToPointRange": () => true, | ||||
"SetFacePointAfterMove": () => {}, | "SetFacePointAfterMove": () => {}, | ||||
"GetFacePointAfterMove": () => true, | "GetFacePointAfterMove": () => true, | ||||
"GetPassabilityClassName": () => "default" | "GetPassabilityClassName": () => "default" | ||||
}); | }); | ||||
controllerAI.OnCreate(); | controllerAI.OnCreate(); | ||||
▲ Show 20 Lines • Show All 88 Lines • ▼ Show 20 Lines | AddMock(unit + i, IID_Position, { | ||||
GetPosition: function() { return new Vector3D(); }, | GetPosition: function() { return new Vector3D(); }, | ||||
GetPosition2D: function() { return new Vector2D(); }, | GetPosition2D: function() { return new Vector2D(); }, | ||||
GetRotation: function() { return { "y": 0 }; }, | GetRotation: function() { return { "y": 0 }; }, | ||||
IsInWorld: function() { return true; }, | IsInWorld: function() { return true; }, | ||||
}); | }); | ||||
AddMock(unit + i, IID_UnitMotion, { | AddMock(unit + i, IID_UnitMotion, { | ||||
"GetWalkSpeed": () => 1, | "GetWalkSpeed": () => 1, | ||||
"GetAcceleration": () => 1, | |||||
"MoveToFormationOffset": (target, x, z) => {}, | "MoveToFormationOffset": (target, x, z) => {}, | ||||
"MoveToTargetRange": (target, min, max) => true, | "MoveToTargetRange": (target, min, max) => true, | ||||
"StopMoving": () => {}, | "StopMoving": () => {}, | ||||
"SetFacePointAfterMove": () => {}, | "SetFacePointAfterMove": () => {}, | ||||
"GetFacePointAfterMove": () => true, | "GetFacePointAfterMove": () => true, | ||||
"GetPassabilityClassName": () => "default" | "GetPassabilityClassName": () => "default" | ||||
}); | }); | ||||
▲ Show 20 Lines • Show All 46 Lines • ▼ Show 20 Lines | AddMock(controller, IID_Position, { | ||||
"GetRotation": () => ({ "y": 0 }), | "GetRotation": () => ({ "y": 0 }), | ||||
"IsInWorld": () => true, | "IsInWorld": () => true, | ||||
"MoveOutOfWorld": () => {}, | "MoveOutOfWorld": () => {}, | ||||
}); | }); | ||||
AddMock(controller, IID_UnitMotion, { | AddMock(controller, IID_UnitMotion, { | ||||
"GetWalkSpeed": () => 1, | "GetWalkSpeed": () => 1, | ||||
"SetSpeedMultiplier": (speed) => {}, | "SetSpeedMultiplier": (speed) => {}, | ||||
"SetAcceleration": (accel) => {}, | |||||
"MoveToPointRange": (x, z, minRange, maxRange) => {}, | "MoveToPointRange": (x, z, minRange, maxRange) => {}, | ||||
"StopMoving": () => {}, | "StopMoving": () => {}, | ||||
"SetFacePointAfterMove": () => {}, | "SetFacePointAfterMove": () => {}, | ||||
"GetFacePointAfterMove": () => true, | "GetFacePointAfterMove": () => true, | ||||
"GetPassabilityClassName": () => "default" | "GetPassabilityClassName": () => "default" | ||||
}); | }); | ||||
AddMock(controller, IID_Attack, { | AddMock(controller, IID_Attack, { | ||||
Show All 30 Lines |
Wildfire Games · Phabricator