Index: binaries/data/mods/public/simulation/components/BuildRestrictions.js
===================================================================
--- binaries/data/mods/public/simulation/components/BuildRestrictions.js
+++ binaries/data/mods/public/simulation/components/BuildRestrictions.js
@@ -17,7 +17,8 @@
"" +
"land" +
"shore" +
- "land-shore"+
+ "land-shore" +
+ "socket" +
"" +
"" +
"" +
@@ -45,11 +46,18 @@
"" +
"" +
"" +
+ "" +
+ "" +
+ "" +
+ "" +
+ "" +
"";
BuildRestrictions.prototype.Init = function()
{
this.territories = this.template.Territory.split(/\s+/);
+ if (this.template.PlacementType == "socket" && !this.template.Socket)
+ warn("Placement type 'Socket' without a socket specified, this building cannot be built.");
};
/**
@@ -124,6 +132,10 @@
passClassName = "default-terrain-only";
break;
+ case "socket":
+ passClassName = "socket";
+ break;
+
case "land":
default:
passClassName = "building-land";
@@ -133,15 +145,20 @@
if (!cmpObstruction)
return result; // Fail
-
+ let ret;
if (this.template.Category == "Wall")
{
// for walls, only test the center point
- var ret = cmpObstruction.CheckFoundation(passClassName, true);
+ ret = cmpObstruction.CheckFoundation(passClassName, true);
+ }
+ else if (passClassName == "socket")
+ {
+// ret = cmpObstruction.CheckFoundation(passClassName, false, this.template.Socket);
+//return result;
}
else
{
- var ret = cmpObstruction.CheckFoundation(passClassName, false);
+ ret = cmpObstruction.CheckFoundation(passClassName, false);
}
if (ret != "success")
@@ -155,6 +172,10 @@
case "fail_obstructs_foundation":
result.message = markForTranslation("%(name)s cannot be built on another building or resource");
break;
+ case "fail_no_socket":
+ // ToDo: Send the name of the socket where this building ought to be build upon.
+ result.message = markForTranslation("%(name)s can only be built on a specific socket");
+ break;
case "fail_terrain_class":
// TODO: be more specific and/or list valid terrain?
result.message = markForTranslation("%(name)s cannot be built on invalid terrain");
Index: binaries/data/mods/public/simulation/components/BuildSlot.js
===================================================================
--- /dev/null
+++ binaries/data/mods/public/simulation/components/BuildSlot.js
@@ -0,0 +1,44 @@
+function BuildSlot() {}
+
+BuildSlot.prototype.Schema =
+ "Specifies this is a building slot, a entity where a building can be placed upon." +
+ "" +
+ "" +
+ "true" +
+ "" +
+ "" +
+ "" +
+ "" +
+ "";
+
+BuildSlot.prototype.Init = function()
+{
+};
+
+BuildSlot.prototype.InitConstruction = function()
+{
+ if (this.template.HideUponConstruction != "true")
+ return true;
+
+ let cmpPosition = Engine.QueryInterface(this.entity, IID_Position);
+ if (!cmpPosition)
+ return false;
+
+ this.previousPosition = cmpPosition.GetPosition();
+ cmpPosition.MoveOutOfWorld();
+
+ return true;
+};
+
+BuildSlot.prototype.Reset = function()
+{
+ if (!this.previousPosition)
+ return;
+
+ let cmpPosition = Engine.QueryInterface(this.entity, IID_Position);
+ if (!cmpPosition)
+ return;
+
+ cmpPosition.JumpTo(this.previousPosition.x, this.previousPosition.z);
+ delete this.previousPosition;
+};
Index: binaries/data/mods/public/simulation/components/interfaces/BuildSlot.js
===================================================================
--- /dev/null
+++ binaries/data/mods/public/simulation/components/interfaces/BuildSlot.js
@@ -0,0 +1 @@
+Engine.RegisterInterface("BuildSlot");
Index: binaries/data/mods/public/simulation/templates/template_formation.xml
===================================================================
--- binaries/data/mods/public/simulation/templates/template_formation.xml
+++ binaries/data/mods/public/simulation/templates/template_formation.xml
@@ -43,6 +43,7 @@
false
false
false
+ false
false
false
false
Index: binaries/data/mods/public/simulation/templates/template_gaia.xml
===================================================================
--- binaries/data/mods/public/simulation/templates/template_gaia.xml
+++ binaries/data/mods/public/simulation/templates/template_gaia.xml
@@ -13,6 +13,7 @@
true
true
true
+ false
false
false
false
Index: binaries/data/mods/public/simulation/templates/template_structure.xml
===================================================================
--- binaries/data/mods/public/simulation/templates/template_structure.xml
+++ binaries/data/mods/public/simulation/templates/template_structure.xml
@@ -79,6 +79,7 @@
true
true
false
+ false
false
false
false
Index: binaries/data/mods/public/simulation/templates/template_structure_civic_house.xml
===================================================================
--- binaries/data/mods/public/simulation/templates/template_structure_civic_house.xml
+++ binaries/data/mods/public/simulation/templates/template_structure_civic_house.xml
@@ -2,6 +2,8 @@
House
+ socket
+ template_socket_house
300
Index: binaries/data/mods/public/simulation/templates/template_unit.xml
===================================================================
--- binaries/data/mods/public/simulation/templates/template_unit.xml
+++ binaries/data/mods/public/simulation/templates/template_unit.xml
@@ -65,6 +65,7 @@
false
false
true
+ false
false
false
false
Index: source/simulation2/components/CCmpObstruction.cpp
===================================================================
--- source/simulation2/components/CCmpObstruction.cpp
+++ source/simulation2/components/CCmpObstruction.cpp
@@ -164,6 +164,9 @@
""
""
""
+ ""
+ ""
+ ""
""
""
""
@@ -196,6 +199,8 @@
m_TemplateFlags |= ICmpObstructionManager::FLAG_BLOCK_CONSTRUCTION;
if (paramNode.GetChild("DeleteUponConstruction").ToBool())
m_TemplateFlags |= ICmpObstructionManager::FLAG_DELETE_UPON_CONSTRUCTION;
+ if (paramNode.GetChild("IsSocket").ToBool())
+ m_TemplateFlags |= ICmpObstructionManager::FLAG_IS_SOCKET;
m_Flags = m_TemplateFlags;
if (paramNode.GetChild("DisableBlockMovement").ToBool())
Index: source/simulation2/components/ICmpObstruction.h
===================================================================
--- source/simulation2/components/ICmpObstruction.h
+++ source/simulation2/components/ICmpObstruction.h
@@ -35,6 +35,7 @@
FOUNDATION_CHECK_FAIL_ERROR,
FOUNDATION_CHECK_FAIL_NO_OBSTRUCTION,
FOUNDATION_CHECK_FAIL_OBSTRUCTS_FOUNDATION,
+ FOUNDATION_CHECK_FAIL_NO_SOCKET,
FOUNDATION_CHECK_FAIL_TERRAIN_CLASS
};
Index: source/simulation2/components/ICmpObstruction.cpp
===================================================================
--- source/simulation2/components/ICmpObstruction.cpp
+++ source/simulation2/components/ICmpObstruction.cpp
@@ -37,6 +37,8 @@
return "fail_no_obstruction";
case FOUNDATION_CHECK_FAIL_OBSTRUCTS_FOUNDATION:
return "fail_obstructs_foundation";
+ case FOUNDATION_CHECK_FAIL_NO_SOCKET:
+ return "fail_no_socket";
case FOUNDATION_CHECK_FAIL_TERRAIN_CLASS:
return "fail_terrain_class";
default:
Index: source/simulation2/components/ICmpObstructionManager.h
===================================================================
--- source/simulation2/components/ICmpObstructionManager.h
+++ source/simulation2/components/ICmpObstructionManager.h
@@ -86,7 +86,8 @@
FLAG_BLOCK_CONSTRUCTION = (1 << 2), // prevents buildings being constructed on this shape
FLAG_BLOCK_PATHFINDING = (1 << 3), // prevents the tile pathfinder choosing paths through this shape
FLAG_MOVING = (1 << 4), // indicates this unit is currently moving
- FLAG_DELETE_UPON_CONSTRUCTION = (1 << 5) // this entity is deleted when construction of a building placed on top of this entity starts
+ FLAG_DELETE_UPON_CONSTRUCTION = (1 << 5), // this entity is deleted when construction of a building placed on top of this entity starts
+ FLAG_IS_SOCKET = (1 << 6) // this entity is a slot where construction of a building placed on top of this entity starts
};
/**