diff --git a/binaries/data/mods/public/simulation/components/Foundation.js b/binaries/data/mods/public/simulation/components/Foundation.js index 044ac087bf..20cd47bdd5 100644 --- a/binaries/data/mods/public/simulation/components/Foundation.js +++ b/binaries/data/mods/public/simulation/components/Foundation.js @@ -167,7 +167,7 @@ Foundation.prototype.Build = function(builderEnt, work) var cmpObstruction = Engine.QueryInterface(this.entity, IID_Obstruction); if (cmpObstruction && cmpObstruction.GetBlockMovementFlag()) { - var collisions = cmpObstruction.GetEntityCollisions(true, true); + var collisions = cmpObstruction.GetUnitCollisions(); if (collisions.length) { var cmpFoundationOwnership = Engine.QueryInterface(this.entity, IID_Ownership); diff --git a/binaries/data/mods/public/simulation/components/Gate.js b/binaries/data/mods/public/simulation/components/Gate.js index 0c1c59caab..c6e62f7b28 100644 --- a/binaries/data/mods/public/simulation/components/Gate.js +++ b/binaries/data/mods/public/simulation/components/Gate.js @@ -219,7 +219,7 @@ Gate.prototype.CloseGate = function() return; // The gate can't be closed if there are entities colliding with it. - var collisions = cmpObstruction.GetEntityCollisions(false, true); + var collisions = cmpObstruction.GetUnitCollisions(); if (collisions.length) { if (!this.timer) diff --git a/source/simulation2/components/CCmpObstruction.cpp b/source/simulation2/components/CCmpObstruction.cpp index 1bd91664c2..a45b1e4970 100644 --- a/source/simulation2/components/CCmpObstruction.cpp +++ b/source/simulation2/components/CCmpObstruction.cpp @@ -597,7 +597,7 @@ public: return !cmpObstructionManager->TestStaticShape(filter, pos.X, pos.Y, cmpPosition->GetRotation().Y, m_Size0, m_Size1, NULL ); } - virtual std::vector GetEntityCollisions(bool checkStructures, bool checkUnits) + virtual std::vector GetUnitCollisions() { std::vector ret; @@ -605,32 +605,15 @@ public: if (!cmpObstructionManager) return ret; // error - flags_t flags = 0; - bool invertMatch = false; - // There are four 'block' flags: construction, foundation, movement, // and pathfinding. Structures have all of these flags, while units // block only movement and construction. - - // The 'block construction' flag is common to both units and structures. - if (checkStructures && checkUnits) - flags = ICmpObstructionManager::FLAG_BLOCK_CONSTRUCTION; - // The 'block foundation' flag is exclusive to structures. - else if (checkStructures) - flags = ICmpObstructionManager::FLAG_BLOCK_FOUNDATION; - else if (checkUnits) - { - // As structures block a superset of what units do, matching units - // but not structures means excluding entities that contain any of - // the structure-specific flags (foundation and pathfinding). - invertMatch = true; - flags = ICmpObstructionManager::FLAG_BLOCK_FOUNDATION | ICmpObstructionManager::FLAG_BLOCK_PATHFINDING; - } + flags_t flags = ICmpObstructionManager::FLAG_BLOCK_CONSTRUCTION; // Ignore collisions within the same control group, or with other shapes that don't match the filter. // Note that, since the control group for each entity defaults to the entity's ID, this is typically // equivalent to only ignoring the entity's own shape and other shapes that don't match the filter. - SkipControlGroupsRequireFlagObstructionFilter filter(invertMatch, m_ControlGroup, m_ControlGroup2, flags); + SkipControlGroupsRequireFlagObstructionFilter filter(false, m_ControlGroup, m_ControlGroup2, flags); ICmpObstructionManager::ObstructionSquare square; if (!GetObstructionSquare(square)) diff --git a/source/simulation2/components/ICmpObstruction.cpp b/source/simulation2/components/ICmpObstruction.cpp index 81bcb5d125..3216ae90e4 100644 --- a/source/simulation2/components/ICmpObstruction.cpp +++ b/source/simulation2/components/ICmpObstruction.cpp @@ -49,7 +49,7 @@ BEGIN_INTERFACE_WRAPPER(Obstruction) DEFINE_INTERFACE_METHOD_0("GetUnitRadius", entity_pos_t, ICmpObstruction, GetUnitRadius) DEFINE_INTERFACE_METHOD_2("CheckFoundation", std::string, ICmpObstruction, CheckFoundation_wrapper, std::string, bool) DEFINE_INTERFACE_METHOD_0("CheckDuplicateFoundation", bool, ICmpObstruction, CheckDuplicateFoundation) -DEFINE_INTERFACE_METHOD_2("GetEntityCollisions", std::vector, ICmpObstruction, GetEntityCollisions, bool, bool) +DEFINE_INTERFACE_METHOD_0("GetUnitCollisions", std::vector, ICmpObstruction, GetUnitCollisions) DEFINE_INTERFACE_METHOD_1("SetActive", void, ICmpObstruction, SetActive, bool) DEFINE_INTERFACE_METHOD_3("SetDisableBlockMovementPathfinding", void, ICmpObstruction, SetDisableBlockMovementPathfinding, bool, bool, int32_t) DEFINE_INTERFACE_METHOD_0("GetBlockMovementFlag", bool, ICmpObstruction, GetBlockMovementFlag) diff --git a/source/simulation2/components/ICmpObstruction.h b/source/simulation2/components/ICmpObstruction.h index 9f3b8e592e..a3375021c2 100644 --- a/source/simulation2/components/ICmpObstruction.h +++ b/source/simulation2/components/ICmpObstruction.h @@ -84,11 +84,10 @@ public: virtual bool CheckDuplicateFoundation() = 0; /** - * Returns a list of entities that are colliding with this entity, - * filtered depending on type of entities that are requested. - * @return vector of blocking entities + * Returns a list of units that are colliding with this entity, + * @return vector of blocking units */ - virtual std::vector GetEntityCollisions(bool checkStructures, bool checkUnits) = 0; + virtual std::vector GetUnitCollisions() = 0; /** * Detects collisions between foundation-blocking entities and