From e58d9e44534c34f9691bedaffc309780ce3219e3 Mon Sep 17 00:00:00 2001 From: Vantha Date: Sat, 8 Aug 2026 17:40:56 +0200 Subject: [PATCH] Replace wasteful GetEntityState calls GetEntityState is a pretty expensive function to call, in the simulation we can check directly whether the entity has the Foundation component. --- .../data/mods/public/simulation/components/GuiInterface.js | 6 ++---- 1 file changed, 2 insertions(+), 4 deletions(-) diff --git a/binaries/data/mods/public/simulation/components/GuiInterface.js b/binaries/data/mods/public/simulation/components/GuiInterface.js index 1aa1ebb71a..5b93dca85f 100644 --- a/binaries/data/mods/public/simulation/components/GuiInterface.js +++ b/binaries/data/mods/public/simulation/components/GuiInterface.js @@ -1445,8 +1445,7 @@ GuiInterface.prototype.SetWallPlacementPreview = function(player, cmd) previewEntities[0].controlGroups = [startEntObstruction.GetControlGroup()]; // If we're snapping to merely a foundation, add an extra preview tower and also set it to the same control group. - const startEntState = this.GetEntityState(player, start.snappedEnt); - if (startEntState.foundation) + if (QueryMiragedInterface(start.snappedEnt, IID_Foundation)) { const cmpPosition = Engine.QueryInterface(start.snappedEnt, IID_Position); if (cmpPosition) @@ -1502,8 +1501,7 @@ GuiInterface.prototype.SetWallPlacementPreview = function(player, cmd) } // If we're snapping to a foundation, add an extra preview tower and also set it to the same control group. - const endEntState = this.GetEntityState(player, end.snappedEnt); - if (endEntState.foundation) + if (QueryMiragedInterface(end.snappedEnt, IID_Foundation)) { const cmpPosition = Engine.QueryInterface(end.snappedEnt, IID_Position); if (cmpPosition)