Changeset View
Changeset View
Standalone View
Standalone View
binaries/data/mods/public/simulation/components/tests/test_UnitAI.js
Engine.LoadHelperScript("Player.js"); | Engine.LoadHelperScript("Player.js"); | ||||
Engine.LoadHelperScript("Position.js"); | Engine.LoadHelperScript("Position.js"); | ||||
Engine.LoadHelperScript("Sound.js"); | Engine.LoadHelperScript("Sound.js"); | ||||
Engine.LoadComponentScript("interfaces/Auras.js"); | Engine.LoadComponentScript("interfaces/Auras.js"); | ||||
Engine.LoadComponentScript("interfaces/Builder.js"); | Engine.LoadComponentScript("interfaces/Builder.js"); | ||||
Engine.LoadComponentScript("interfaces/BuildingAI.js"); | Engine.LoadComponentScript("interfaces/BuildingAI.js"); | ||||
Engine.LoadComponentScript("interfaces/Capturable.js"); | Engine.LoadComponentScript("interfaces/Capturable.js"); | ||||
Engine.LoadComponentScript("interfaces/Diplomacy.js"); | |||||
Engine.LoadComponentScript("interfaces/Garrisonable.js"); | Engine.LoadComponentScript("interfaces/Garrisonable.js"); | ||||
Engine.LoadComponentScript("interfaces/Resistance.js"); | Engine.LoadComponentScript("interfaces/Resistance.js"); | ||||
Engine.LoadComponentScript("interfaces/Formation.js"); | Engine.LoadComponentScript("interfaces/Formation.js"); | ||||
Engine.LoadComponentScript("interfaces/Heal.js"); | Engine.LoadComponentScript("interfaces/Heal.js"); | ||||
Engine.LoadComponentScript("interfaces/Health.js"); | Engine.LoadComponentScript("interfaces/Health.js"); | ||||
Engine.LoadComponentScript("interfaces/Pack.js"); | Engine.LoadComponentScript("interfaces/Pack.js"); | ||||
Engine.LoadComponentScript("interfaces/ResourceSupply.js"); | Engine.LoadComponentScript("interfaces/ResourceSupply.js"); | ||||
Engine.LoadComponentScript("interfaces/ResourceGatherer.js"); | Engine.LoadComponentScript("interfaces/ResourceGatherer.js"); | ||||
▲ Show 20 Lines • Show All 123 Lines • ▼ Show 20 Lines | AddMock(SYSTEM_ENTITY, IID_TemplateManager, { | ||||
"GetCurrentTemplateName": function(ent) { return "special/formations/line_closed"; }, | "GetCurrentTemplateName": function(ent) { return "special/formations/line_closed"; }, | ||||
}); | }); | ||||
AddMock(SYSTEM_ENTITY, IID_PlayerManager, { | AddMock(SYSTEM_ENTITY, IID_PlayerManager, { | ||||
"GetPlayerByID": function(id) { return playerEntity; }, | "GetPlayerByID": function(id) { return playerEntity; }, | ||||
"GetNumPlayers": function() { return 2; }, | "GetNumPlayers": function() { return 2; }, | ||||
}); | }); | ||||
AddMock(playerEntity, IID_Player, { | AddMock(playerEntity, IID_Diplomacy, { | ||||
"IsAlly": function() { return false; }, | "IsAlly": function() { return false; }, | ||||
"IsEnemy": function() { return true; }, | "IsEnemy": function() { return true; }, | ||||
"GetEnemies": function() { return [2]; }, | "GetEnemies": function() { return [2]; }, | ||||
}); | }); | ||||
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, { | ||||
▲ Show 20 Lines • Show All 165 Lines • ▼ Show 20 Lines | AddMock(SYSTEM_ENTITY, IID_PlayerManager, { | ||||
"GetPlayerByID": function(id) { return playerEntity; }, | "GetPlayerByID": function(id) { return playerEntity; }, | ||||
"GetNumPlayers": function() { return 2; }, | "GetNumPlayers": function() { return 2; }, | ||||
}); | }); | ||||
AddMock(SYSTEM_ENTITY, IID_ObstructionManager, { | AddMock(SYSTEM_ENTITY, IID_ObstructionManager, { | ||||
"IsInTargetRange": (ent, target, min, max) => true | "IsInTargetRange": (ent, target, min, max) => true | ||||
}); | }); | ||||
AddMock(playerEntity, IID_Player, { | AddMock(playerEntity, IID_Diplomacy, { | ||||
"IsAlly": function() { return false; }, | "IsAlly": function() { return false; }, | ||||
"IsEnemy": function() { return true; }, | "IsEnemy": function() { return true; }, | ||||
"GetEnemies": function() { return [2]; }, | "GetEnemies": function() { return [2]; }, | ||||
}); | }); | ||||
// create units | // create units | ||||
for (var i = 0; i < unitCount; i++) | for (var i = 0; i < unitCount; i++) | ||||
{ | { | ||||
▲ Show 20 Lines • Show All 209 Lines • Show Last 20 Lines |
Wildfire Games · Phabricator