Jump to content

Ice Maker is bugged during offscreen


PuffinBy
  • Version: PC/MAC/Linux Pending

If you go away after fueling an ice maker, you will get more ice than usual, at the expense of the same amount of fuel.

I suppose it's because the fuel consumption is paused while the task that spawns ice is not.

(It's not resuming because animations don't play when prefab is offscreen?)

 

prefabs/icemaker.lua : line 90, runs "fueltask" multiple times even though fuel is not consuming.

inst.fueltask = inst:DoPeriodicTask(TUNING.ICEMAKER_SPAWN_TIME, fueltaskfn)

line 46, 1) stops consuming  2) but doesn't play animation until back on screen  3) runs "ListonForEvent" many times resulting 
in more ice.

local function fueltaskfn(inst)
	inst.AnimState:PlayAnimation("use")
	inst.SoundEmitter:PlaySound("dontstarve_DLC002/common/icemachine_start")
	inst.components.fueled:StopConsuming() --temp pause fuel so we don't run out in the animation.
	inst:ListenForEvent("animover", spawnice)
end

line 21,  does not resume consuming fuel because there is no offscreen animation

local function spawnice(inst)
	inst:RemoveEventCallback("animover", spawnice)

    local ice = SpawnPrefab("ice")
    local pt = Vector3(inst.Transform:GetWorldPosition()) + Vector3(0,2,0)
    ice.Transform:SetPosition(pt:Get())
    local down = TheCamera:GetDownVec()
    local angle = math.atan2(down.z, down.x) + (math.random()*60)*DEGREES
    local sp = 3 + math.random()
    ice.Physics:SetVel(sp*math.cos(angle), math.random()*2+8, sp*math.sin(angle))
    ice.components.inventoryitem:OnStartFalling()

    --Machine should only ever be on after spawning an ice
	inst.components.fueled:StartConsuming()
	inst.AnimState:PlayAnimation("idle_on", true)
end
 

Steps to Reproduce
Build an icemaker and fuel it to max. Then run away. Wait a while (more than 90 seconds) and go back. You'll get 3 ice. Repeat and get a total of 9 ice. (Normally, there would be only 3. )



User Feedback


There are no comments to display.


×
  • Create New...