Jump to content

While having the Magician's Top Hat open, item placement gets canceled and restarted repeatedly, degrading performance


rezecib
  • Fixed

In the middle of the component PlayerController:OnUpdate, there's a check:

    if self.handler ~= nil and self.inst:HasTag("usingmagiciantool") then
        self:CancelPlacement()
        self:CancelDeployPlacement()
        self:CancelAOETargeting()
    end

However, below this, there's a check to see if the player has an item on their cursor, which then starts placement mode:

            local placer_item = controller_mode and self:GetCursorInventoryObject() or self.inst.replica.inventory:GetActiveItem()
            --show deploy placer
            if self.deploy_mode and
                self.placer == nil and
                placer_item ~= nil and
                placer_item.replica.inventoryitem ~= nil and
                placer_item.replica.inventoryitem:IsDeployable(self.inst) then

                local placer_name = placer_item.replica.inventoryitem:GetDeployPlacerName()
                local placer_skin = placer_item.AnimState:GetSkinBuild() --hack that relies on the build name to match the linked skinname
                if placer_skin == "" then
                    placer_skin = nil
                end
                if self.deployplacer ~= nil and (self.deployplacer.prefab ~= placer_name or self.deployplacer.skinname ~= placer_skin) then
                    self:CancelDeployPlacement()
                end
                if self.deployplacer == nil then
                    self.deployplacer = SpawnPrefab(placer_name, placer_skin, nil, self.inst.userid )
                    if self.deployplacer ~= nil then
                        self.deployplacer.components.placer:SetBuilder(self.inst, nil, placer_item)
                        self.deployplacer.components.placer.testfn = function(pt)
                            local mouseover = TheInput:GetWorldEntityUnderMouse()
                            return placer_item:IsValid() and
                                placer_item.replica.inventoryitem ~= nil and
                                placer_item.replica.inventoryitem:CanDeploy(pt, mouseover, self.inst, self.deployplacer.Transform:GetRotation()),
                                (mouseover ~= nil and not mouseover:HasTag("walkableplatform") and not mouseover:HasTag("walkableperipheral") and not mouseover:HasTag("ignoremouseover")) or TheInput:GetHUDEntityUnderMouse() ~= nil
                        end
                        self.deployplacer.components.placer:OnUpdate(0) --so that our position is accurate on the first frame
                    end
                end
            else
                self:CancelDeployPlacement()
            end

In the case of deploy-placement, this means that on every frame placement is cancelled and restarted immediately on the same frame.

It seems that the intent here was to not allow placement, but placement is actually functional despite this, somehow. Rather than thrashing on creating and destroying the placer, maybe this should just allow placement? Or the placer creation block should check the same condition to avoid thrashing.

This is particularly problematic with the Geometric Placement mod, because creating placers creates a grid, which is more expensive than just destroying and recreating the placer itself.


Steps to Reproduce

c_give("tophat_magician")

c_give("pinecone")

Put the hat on, open its inventory, then pick up the pinecone on the cursor and move the mouse. Compare to moving the mouse without the hat open.




User Feedback


A developer has marked this issue as fixed. This means that the issue has been addressed in the current development build and will likely be in the next update.

Geometric placement is one of the OG mod for DST that most pp use, and when it's creator ask for a bug fix, i expected dev to update fixed status faster, even when unmodded game doesnt get affected as much by this bug, 90% of players base will face this bug.

Share this comment


Link to comment
Share on other sites



Create an account or sign in to comment

You need to be a member in order to leave a comment

Create an account

Sign up for a new account in our community. It's easy!

Register a new account

Sign in

Already have an account? Sign in here.

Sign In Now

×
  • Create New...