Index: ps/trunk/binaries/data/mods/public/maps/scenarios/Units_demo.js
===================================================================
--- ps/trunk/binaries/data/mods/public/maps/scenarios/Units_demo.js (nonexistent)
+++ ps/trunk/binaries/data/mods/public/maps/scenarios/Units_demo.js (revision 19399)
@@ -0,0 +1,84 @@
+/**
+ * Whether to also place all actors.
+ */
+let actors = false;
+
+/**
+ * Coordinates of the first entity.
+ */
+let startX = 20;
+let startZ = 20;
+
+/**
+ * Horizontal coordinate of the last entity in the current row.
+ */
+let stopX = 1580;
+
+/**
+ * Coordinates of the current entity.
+ */
+let x = startX;
+let z = startZ;
+
+/**
+ * Recall the greatest length in the current row to prevent overlapping.
+ */
+let maxh = 0;
+
+/**
+ * Space between entities.
+ */
+let gap = 14;
+
+let cmpTemplateManager = Engine.QueryInterface(SYSTEM_ENTITY, IID_TemplateManager);
+for (let template of cmpTemplateManager.FindAllPlaceableTemplates(actors))
+{
+ print(template + "...\n");
+
+ let ent = Engine.AddEntity(template);
+ if (!ent)
+ {
+ error("Failed to load " + template + "\n");
+ continue;
+ }
+
+ let cmpFootprint = Engine.QueryInterface(ent, IID_Footprint);
+ if (!cmpFootprint)
+ {
+ print(template + " has no footprint\n");
+ continue;
+ }
+
+ let shape = cmpFootprint.GetShape();
+ let w = shape.width;
+ let h = shape.depth;
+
+ if (shape.type == 'circle')
+ w = h = shape.radius * 2;
+
+ if (x + w >= stopX)
+ {
+ // Start a new row
+ x = startX;
+ z += maxh + gap;
+ maxh = 0;
+ }
+
+ let cmpPosition = Engine.QueryInterface(ent, IID_Position);
+ if (!cmpPosition)
+ {
+ warn(template + " has no position\n");
+ Engine.DestroyEntity(ent);
+ continue;
+ }
+
+ cmpPosition.MoveTo(x + w / 2, z);
+ cmpPosition.SetYRotation(Math.PI * 3 / 4);
+
+ let cmpOwnership = Engine.QueryInterface(ent, IID_Ownership);
+ if (cmpOwnership)
+ cmpOwnership.SetOwner(1);
+
+ x += w + gap;
+ maxh = Math.max(maxh, h);
+}
Property changes on: ps/trunk/binaries/data/mods/public/maps/scenarios/Units_demo.js
___________________________________________________________________
Added: svn:eol-style
## -0,0 +1 ##
+native
\ No newline at end of property
Index: ps/trunk/binaries/data/mods/public/maps/scenarios/Units_demo.xml
===================================================================
--- ps/trunk/binaries/data/mods/public/maps/scenarios/Units_demo.xml (revision 19398)
+++ ps/trunk/binaries/data/mods/public/maps/scenarios/Units_demo.xml (revision 19399)
@@ -1,115 +1,51 @@
-
default
lake
5
4.0
0.45
Index: ps/trunk/binaries/data/mods/public/simulation/data/placeablesFilter.json
===================================================================
--- ps/trunk/binaries/data/mods/public/simulation/data/placeablesFilter.json (revision 19398)
+++ ps/trunk/binaries/data/mods/public/simulation/data/placeablesFilter.json (revision 19399)
@@ -1,13 +1,14 @@
{
"templates": [
{"directory": "campaigns", "file": "*.xml"},
{"directory": "gaia", "file": "*.xml"},
{"directory": "other", "file": "*.xml"},
{"directory": "structures", "file": "*.xml"},
{"directory": "units", "file": "*.xml"},
+ {"directory": "trigger", "file": "*.xml"},
{"directory": "skirmish/structures", "file": "*.xml"},
{"directory": "skirmish/units", "file": "*.xml"},
{"directory": "special", "file": "trigger_point*.xml"},
{"directory": "special", "file": "territory*.xml"}
]
}
Index: ps/trunk/source/simulation2/components/ICmpTemplateManager.cpp
===================================================================
--- ps/trunk/source/simulation2/components/ICmpTemplateManager.cpp (revision 19398)
+++ ps/trunk/source/simulation2/components/ICmpTemplateManager.cpp (revision 19399)
@@ -1,31 +1,32 @@
/* Copyright (C) 2017 Wildfire Games.
* This file is part of 0 A.D.
*
* 0 A.D. is free software: you can redistribute it and/or modify
* it under the terms of the GNU General Public License as published by
* the Free Software Foundation, either version 2 of the License, or
* (at your option) any later version.
*
* 0 A.D. is distributed in the hope that it will be useful,
* but WITHOUT ANY WARRANTY; without even the implied warranty of
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
* GNU General Public License for more details.
*
* You should have received a copy of the GNU General Public License
* along with 0 A.D. If not, see .
*/
#include "precompiled.h"
#include "ICmpTemplateManager.h"
#include "simulation2/system/InterfaceScripted.h"
BEGIN_INTERFACE_WRAPPER(TemplateManager)
DEFINE_INTERFACE_METHOD_1("GetTemplate", const CParamNode*, ICmpTemplateManager, GetTemplate, std::string)
DEFINE_INTERFACE_METHOD_1("GetTemplateWithoutValidation", const CParamNode*, ICmpTemplateManager, GetTemplateWithoutValidation, std::string)
DEFINE_INTERFACE_METHOD_CONST_1("TemplateExists", bool, ICmpTemplateManager, TemplateExists, std::string)
DEFINE_INTERFACE_METHOD_CONST_1("GetCurrentTemplateName", std::string, ICmpTemplateManager, GetCurrentTemplateName, entity_id_t)
DEFINE_INTERFACE_METHOD_CONST_1("FindAllTemplates", std::vector, ICmpTemplateManager, FindAllTemplates, bool)
+DEFINE_INTERFACE_METHOD_CONST_1("FindAllPlaceableTemplates", std::vector, ICmpTemplateManager, FindAllPlaceableTemplates, bool)
DEFINE_INTERFACE_METHOD_CONST_1("GetEntitiesUsingTemplate", std::vector, ICmpTemplateManager, GetEntitiesUsingTemplate, std::string)
END_INTERFACE_WRAPPER(TemplateManager)