Differential D2763 Diff 12577 ps/trunk/binaries/data/mods/public/simulation/components/tests/test_UnitAI.js
Changeset View
Changeset View
Standalone View
Standalone View
ps/trunk/binaries/data/mods/public/simulation/components/tests/test_UnitAI.js
Show First 20 Lines • Show All 142 Lines • ▼ Show 20 Lines | function TestFormationExiting(mode) | ||||
AddMock(playerEntity, IID_Player, { | AddMock(playerEntity, IID_Player, { | ||||
IsAlly: function() { return false; }, | IsAlly: function() { return false; }, | ||||
IsEnemy: function() { return true; }, | IsEnemy: function() { return true; }, | ||||
GetEnemies: function() { return [2]; }, | GetEnemies: function() { return [2]; }, | ||||
}); | }); | ||||
AddMock(SYSTEM_ENTITY, IID_ObstructionManager, { | AddMock(SYSTEM_ENTITY, IID_ObstructionManager, { | ||||
"IsInTargetRange": (ent, target, min, max, opposite) => true | "IsInTargetRange": () => true, | ||||
"IsInPointRange": () => true | |||||
}); | }); | ||||
var unitAI = ConstructComponent(unit, "UnitAI", { "FormationController": "false", "DefaultStance": "aggressive" }); | var unitAI = ConstructComponent(unit, "UnitAI", { "FormationController": "false", "DefaultStance": "aggressive" }); | ||||
AddMock(unit, IID_Identity, { | AddMock(unit, IID_Identity, { | ||||
GetClassesList: function() { return []; }, | GetClassesList: function() { return []; }, | ||||
}); | }); | ||||
▲ Show 20 Lines • Show All 56 Lines • ▼ Show 20 Lines | function TestFormationExiting(mode) | ||||
AddMock(controller, IID_Position, { | AddMock(controller, IID_Position, { | ||||
JumpTo: function(x, z) { this.x = x; this.z = z; }, | JumpTo: function(x, z) { this.x = x; this.z = z; }, | ||||
GetTurretParent: function() { return INVALID_ENTITY; }, | GetTurretParent: function() { return INVALID_ENTITY; }, | ||||
GetPosition: function() { return new Vector3D(this.x, 0, this.z); }, | GetPosition: function() { return new Vector3D(this.x, 0, this.z); }, | ||||
GetPosition2D: function() { return new Vector2D(this.x, this.z); }, | GetPosition2D: function() { return new Vector2D(this.x, this.z); }, | ||||
GetRotation: function() { return { "y": 0 }; }, | GetRotation: function() { return { "y": 0 }; }, | ||||
IsInWorld: function() { return true; }, | IsInWorld: function() { return true; }, | ||||
MoveOutOfWorld: () => {} | |||||
}); | }); | ||||
AddMock(controller, IID_UnitMotion, { | AddMock(controller, IID_UnitMotion, { | ||||
"GetWalkSpeed": () => 1, | "GetWalkSpeed": () => 1, | ||||
"StopMoving": () => {}, | "StopMoving": () => {}, | ||||
"SetSpeedMultiplier": () => {}, | "SetSpeedMultiplier": () => {}, | ||||
"MoveToPointRange": () => true, | "MoveToPointRange": () => true, | ||||
"SetFacePointAfterMove": () => {}, | "SetFacePointAfterMove": () => {}, | ||||
▲ Show 20 Lines • Show All 129 Lines • ▼ Show 20 Lines | function TestMoveIntoFormationWhileAttacking() | ||||
AddMock(enemy, IID_Health, { | AddMock(enemy, IID_Health, { | ||||
GetHitpoints: function() { return 40; }, | GetHitpoints: function() { return 40; }, | ||||
}); | }); | ||||
var controllerFormation = ConstructComponent(controller, "Formation", {"FormationName": "Line Closed", "FormationShape": "square", "ShiftRows": "false", "SortingClasses": "", "WidthDepthRatio": 1, "UnitSeparationWidthMultiplier": 1, "UnitSeparationDepthMultiplier": 1, "SpeedMultiplier": 1, "Sloppyness": 0}); | var controllerFormation = ConstructComponent(controller, "Formation", {"FormationName": "Line Closed", "FormationShape": "square", "ShiftRows": "false", "SortingClasses": "", "WidthDepthRatio": 1, "UnitSeparationWidthMultiplier": 1, "UnitSeparationDepthMultiplier": 1, "SpeedMultiplier": 1, "Sloppyness": 0}); | ||||
var controllerAI = ConstructComponent(controller, "UnitAI", { "FormationController": "true", "DefaultStance": "aggressive" }); | var controllerAI = ConstructComponent(controller, "UnitAI", { "FormationController": "true", "DefaultStance": "aggressive" }); | ||||
AddMock(controller, IID_Position, { | AddMock(controller, IID_Position, { | ||||
GetTurretParent: function() { return INVALID_ENTITY; }, | "GetTurretParent": () => INVALID_ENTITY, | ||||
JumpTo: function(x, z) { this.x = x; this.z = z; }, | "JumpTo": function(x, z) { this.x = x; this.z = z; }, | ||||
GetPosition: function() { return new Vector3D(this.x, 0, this.z); }, | "GetPosition": function(){ return new Vector3D(this.x, 0, this.z); }, | ||||
GetPosition2D: function() { return new Vector2D(this.x, this.z); }, | "GetPosition2D": function(){ return new Vector2D(this.x, this.z); }, | ||||
GetRotation: function() { return { "y": 0 }; }, | "GetRotation": () => ({ "y": 0 }), | ||||
IsInWorld: function() { return true; }, | "IsInWorld": () => true, | ||||
"MoveOutOfWorld": () => {}, | |||||
}); | }); | ||||
AddMock(controller, IID_UnitMotion, { | AddMock(controller, IID_UnitMotion, { | ||||
"GetWalkSpeed": () => 1, | "GetWalkSpeed": () => 1, | ||||
"SetSpeedMultiplier": (speed) => {}, | "SetSpeedMultiplier": (speed) => {}, | ||||
"MoveToPointRange": (x, z, minRange, maxRange) => {}, | "MoveToPointRange": (x, z, minRange, maxRange) => {}, | ||||
"StopMoving": () => {}, | "StopMoving": () => {}, | ||||
"SetFacePointAfterMove": () => {}, | "SetFacePointAfterMove": () => {}, | ||||
Show All 34 Lines |
Wildfire Games · Phabricator