Skip to content

Commit 26aa122

Browse files
committed
performance: Allow entities without a stable target to sleep when selected inventory type is "none"
1 parent 734ab4b commit 26aa122

File tree

1 file changed

+4
-1
lines changed

1 file changed

+4
-1
lines changed

script/selector.lua

Lines changed: 4 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -342,7 +342,7 @@ function selector:update_proxy_target(target)
342342

343343
-- If the new target is nil or a car type, it should be in the floating list.
344344
-- These could become invalid without warning (no useful events), so they must be polled regularly for changes.
345-
if not target or target.type == "car" or target.train and target.train.state == defines.train_state.manual_control then
345+
if self.actual_inventory_type ~= "none" and (not target or target.type == "car" or target.train and target.train.state == defines.train_state.manual_control) then
346346
storage.floating[id] = true
347347
else
348348
storage.floating[id] = nil
@@ -487,6 +487,9 @@ local function set(entity, mode, inventory_type, immediate)
487487

488488
if not inventory_type and not data.inventory_type then
489489
data:destroy()
490+
elseif data.actual_inventory_type == "none" then
491+
data.actual_inventory_type = inventory_type
492+
data:update_proxy_target()
490493
else
491494
data.actual_inventory_type = inventory_type
492495
data:update_proxy_inventory()

0 commit comments

Comments
 (0)