diff --git a/binaries/data/mods/_test.sim/simulation/components/test-addentity.js b/binaries/data/mods/_test.sim/simulation/components/test-addentity.js
index c0dce2cc6a..ee0bb7361d 100644
--- a/binaries/data/mods/_test.sim/simulation/components/test-addentity.js
+++ b/binaries/data/mods/_test.sim/simulation/components/test-addentity.js
@@ -9,3 +9,17 @@ TestScript1_AddEntity.prototype.GetX = function()
};
Engine.RegisterComponentType(IID_Test1, "TestScript1_AddEntity", TestScript1_AddEntity);
+
+
+
+function TestScript1_AddLocalEntity() {}
+
+TestScript1_AddLocalEntity.prototype.GetX = function()
+{
+ if (Engine.AddLocalEntity("bogus-template-name") !== 0)
+ throw new Error("bogus AddLocalEntity failed");
+
+ return Engine.AddLocalEntity("test1");
+};
+
+Engine.RegisterComponentType(IID_Test1, "TestScript1_AddLocalEntity", TestScript1_AddLocalEntity);
diff --git a/binaries/data/mods/_test.sim/simulation/components/test-destroyentity.js b/binaries/data/mods/_test.sim/simulation/components/test-destroyentity.js
new file mode 100644
index 0000000000..2920a6423d
--- /dev/null
+++ b/binaries/data/mods/_test.sim/simulation/components/test-destroyentity.js
@@ -0,0 +1,8 @@
+function TestScript1_DestroyEntity() {}
+
+TestScript1_DestroyEntity.prototype.GetX = function()
+{
+ Engine.DestroyEntity(10);
+};
+
+Engine.RegisterComponentType(IID_Test1, "TestScript1_DestroyEntity", TestScript1_DestroyEntity);
diff --git a/binaries/data/mods/_test.sim/simulation/components/test-hotload1.js b/binaries/data/mods/_test.sim/simulation/components/test-hotload1.js
index a94774fb7f..60b2e2d499 100644
--- a/binaries/data/mods/_test.sim/simulation/components/test-hotload1.js
+++ b/binaries/data/mods/_test.sim/simulation/components/test-hotload1.js
@@ -10,6 +10,7 @@ HotloadA.prototype.GetX = function() {
Engine.RegisterComponentType(IID_Test1, "HotloadA", HotloadA);
+
function HotloadB() {}
HotloadB.prototype.Init = function() {
@@ -20,4 +21,13 @@ HotloadB.prototype.GetX = function() {
return this.x*2;
};
-Engine.RegisterComponentType(IID_Test1, "HotloadB", HotloadB);
\ No newline at end of file
+Engine.RegisterComponentType(IID_Test1, "HotloadB", HotloadB);
+
+
+function HotloadC() {}
+
+Engine.RegisterInterface("HotloadInterface");
+Engine.RegisterComponentType(IID_HotloadInterface, "HotloadC", HotloadC);
+
+
+Engine.RegisterGlobal("HotloadGlobal", 1);
diff --git a/binaries/data/mods/_test.sim/simulation/components/test-hotload2.js b/binaries/data/mods/_test.sim/simulation/components/test-hotload2.js
index 8f4690093b..7fedc26506 100644
--- a/binaries/data/mods/_test.sim/simulation/components/test-hotload2.js
+++ b/binaries/data/mods/_test.sim/simulation/components/test-hotload2.js
@@ -9,3 +9,12 @@ HotloadA.prototype.GetX = function() {
};
Engine.RegisterComponentType(IID_Test1, "HotloadA", HotloadA);
+
+
+function HotloadC() {}
+
+Engine.RegisterInterface("HotloadInterface");
+Engine.RegisterComponentType(IID_HotloadInterface, "HotloadC", HotloadC);
+
+
+Engine.RegisterGlobal("HotloadGlobal", 2);
diff --git a/binaries/data/mods/public/gui/session_new/input.js b/binaries/data/mods/public/gui/session_new/input.js
index 471ee8ad14..66a01d993b 100644
--- a/binaries/data/mods/public/gui/session_new/input.js
+++ b/binaries/data/mods/public/gui/session_new/input.js
@@ -7,9 +7,12 @@ const SDL_BUTTON_RIGHT = 3;
var INPUT_NORMAL = 0;
var INPUT_DRAGGING = 1;
+var INPUT_BUILDING_PLACEMENT = 2;
var inputState = INPUT_NORMAL;
+var placementEntity = "";
+
function handleInputBeforeGui(ev)
{
return false;
@@ -67,6 +70,43 @@ function handleInputAfterGui(ev)
}
}
break;
+
+ case INPUT_BUILDING_PLACEMENT:
+ switch (ev.type)
+ {
+ case "mousemotion":
+ var target = Engine.GetTerrainAtPoint(ev.x, ev.y);
+ var angle = Math.PI;
+ Engine.GuiInterfaceCall("SetBuildingPlacementPreview", {"template": placementEntity, "x": target.x, "z": target.z, "angle": angle});
+
+ return false; // continue processing mouse motion
+
+ case "mousebuttondown":
+ if (ev.button == SDL_BUTTON_LEFT)
+ {
+ var target = Engine.GetTerrainAtPoint(ev.x, ev.y);
+ var angle = Math.PI;
+ Engine.GuiInterfaceCall("SetBuildingPlacementPreview", {"template": ""});
+ Engine.PostNetworkCommand({"type": "construct", "template": placementEntity, "x": target.x, "z": target.z, "angle": angle});
+
+ inputState = INPUT_NORMAL;
+ return true;
+ }
+ else if (ev.button == SDL_BUTTON_RIGHT)
+ {
+ Engine.GuiInterfaceCall("SetBuildingPlacementPreview", {"template": ""});
+
+ inputState = INPUT_NORMAL;
+ return true;
+ }
+ }
+ break;
}
return false;
}
+
+function testBuild(ent)
+{
+ placementEntity = ent;
+ inputState = INPUT_BUILDING_PLACEMENT;
+}
diff --git a/binaries/data/mods/public/gui/session_new/session.js b/binaries/data/mods/public/gui/session_new/session.js
index 49b2a8f4c4..251a6deff3 100644
--- a/binaries/data/mods/public/gui/session_new/session.js
+++ b/binaries/data/mods/public/gui/session_new/session.js
@@ -6,6 +6,8 @@ function init()
function onSimulationUpdate()
{
updateDebug();
+
+ updateBuildButton();
}
function updateDebug()
@@ -20,3 +22,21 @@ function updateDebug()
}
debug.caption = text;
}
+
+function updateBuildButton()
+{
+ var selection = getEntitySelection();
+ if (selection.length)
+ {
+ var entity = Engine.GetEntityState(selection[0]);
+ if (entity.buildEntities && entity.buildEntities.length)
+ {
+ var ent = entity.buildEntities[0];
+ getGUIObjectByName("testBuild").caption = "Construct "+ent;
+ getGUIObjectByName("testBuild").onpress = function() { testBuild(ent) };
+ getGUIObjectByName("testBuild").hidden = false;
+ return;
+ }
+ }
+ getGUIObjectByName("testBuild").hidden = true;
+}
diff --git a/binaries/data/mods/public/gui/session_new/session.xml b/binaries/data/mods/public/gui/session_new/session.xml
index ecaf2b59a5..626fb31398 100644
--- a/binaries/data/mods/public/gui/session_new/session.xml
+++ b/binaries/data/mods/public/gui/session_new/session.xml
@@ -39,6 +39,15 @@
this.hidden = !this.hidden;
+
+