Jump to content

Whirly Fan's benefits can be active even when standing still, without losing durability


hoxi
  • Fixed

The issue stems from the insulation and cooling benefits not being disabled on being unequipped, and/or not checking if the owner is moving after being equipped. Normally, only durability consumption is disabled on being unequipped.

A simple solution would be to modify the _onlocomote function to account for not having an owner, or an owner without a locomotor component, and let it fall back to the "not moving" behavior. Then, calling this function on equipping it (and passing the owner), and calling it without passing an owner when unequipping or if it's equipped on a model.

Something like this:

local function onequip(inst, owner)
	owner.AnimState:OverrideSymbol("swap_object", "swap_minifan", "swap_minifan")
	owner.AnimState:Show("ARM_carry")
	owner.AnimState:Hide("ARM_normal")

	if inst._wheel ~= nil then
		inst._wheel:Remove()
	end
	inst._wheel = SpawnPrefab("fan_wheel")
	inst._wheel.entity:SetParent(owner.entity)
	inst._wheel:ListenForEvent("onremove", onremove, inst)

	if inst._owner ~= nil then
		inst:RemoveEventCallback("locomote", inst._onlocomote, inst._owner)
	end
	inst._owner = owner
	inst:ListenForEvent("locomote", inst._onlocomote, owner)
	inst._onlocomote(owner) -- check owner locomotion state right away
end

local function onunequip(inst, owner)
	if inst._wheel ~= nil then
		inst._wheel:StartUnequipping(inst)
		inst._wheel = nil
	end

	if inst._owner ~= nil then
		inst:RemoveEventCallback("locomote", inst._onlocomote, inst._owner)
		inst._owner = nil
	end

	-- checked with _onlocomote
	--if inst.components.fueled ~= nil then
	--	inst.components.fueled:StopConsuming()
	--end

	owner.AnimState:Hide("ARM_carry")
	owner.AnimState:Show("ARM_normal")

	inst._onlocomote(nil) -- stop consuming
end

local function onequiptomodel(inst, owner, from_ground)
	-- checked with _onlocomote
	--if inst.components.fueled ~= nil then
	--	inst.components.fueled:StopConsuming()
	--end
	inst._onlocomote(nil) -- stop consuming
end


-- given that the functions above check for inst.components.fueled ~= nil, this could be added below too
inst._onlocomote = function(owner)
	-- if owner.components.locomotor.wantstomoveforward then
	if owner ~= nil and owner.components.locomotor ~= nil and owner.components.locomotor.wantstomoveforward then
		if not inst.components.fueled.consuming then
			inst.components.fueled:StartConsuming()
			inst.components.insulator:SetInsulation(TUNING.INSULATION_SMALL)
			inst.components.heater:SetThermics(false, true)
			inst._wheel:SetSpinning(true)
		end
	elseif inst.components.fueled.consuming then
		inst.components.fueled:StopConsuming()
		inst.components.insulator:SetInsulation(0)
		inst.components.heater:SetThermics(false, false)
		inst._wheel:SetSpinning(false)
	end
end

 


Steps to Reproduce
  1. Equip the whirly fan.
  2. Move and then unequip it.
  3. Stand still.
  4. Equip the same whirly fan again and don't move.
  5. Notice how its benefits still apply until you move and stop again.



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.


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...