Jump to content

Drying Racks are unable to dry things hanging on them when gaining protection from an Umbralla dome during rain


hoxi
  • Fixed

A drying rack that had something on it, and is exposed to rain, will be unable to go back to drying on gaining protection from an Umbralla dome, only being able to continue drying if rain stops (this might change on load, haven't verified).

local function IsExposedToRain(inst)
	return TheWorld.state.israining and inst.components.rainimmunity == nil
end

local function OnIsRaining(self, israining)
	if israining and self.inst.components.rainimmunity == nil then
        self:Pause()
    else
        self:Resume()
    end
end

local function OnRainImmunity(inst)
	if IsExposedToRain(inst) then
		inst.components.dryer:Pause()
	else
		inst.components.dryer:Resume()
	end
end

local function StartWatchingRain(self)
    if not self.watchingrain then
        self.watchingrain = true
        self:WatchWorldState("israining", OnIsRaining)
		self.inst:ListenForEvent("gainrainimmunity", OnRainImmunity)
		self.inst:ListenForEvent("loserainimmunity", OnRainImmunity)
    end
end

local function StopWatchingRain(self)
    if self.watchingrain then
        self.watchingrain = nil
        self:StopWatchingWorldState("israining", OnIsRaining)
		self.inst:RemoveEventCallback("gainrainimmunity", OnRainImmunity)
		self.inst:RemoveEventCallback("loserainimmunity", OnRainImmunity)
    end
end

Seems like, due to the "gainrainimmunity" event being pushed on creation of the component (shown further below), the entity technically doesn't have said component at that point in time, resulting inĀ inst.components.rainimmunity being nil for any relevant checks.

Either this should be addressed through the rainimmunity component itself so that this doesn't happen, or the dryer component should be using two different functions, one for each event, and without checking for a rainimmunity component, as that will always be negative.

In case the latter is done, I recommend leaving a comment in:

local RainImmunity = Class(function(self, inst)
	self.inst = inst
	self.sources = {}

	inst:AddTag("rainimmunity")

	self._onremovesource = function(src)
		self.sources[src] = nil
		if next(self.sources) == nil then
			inst:RemoveComponent("rainimmunity")
		end
	end

	inst:PushEvent("gainrainimmunity")
end)

To clarify that inst.component.rainimmunity checks can't be used for "gainrainmmunity", and it should be assumed that the entity has it when this event is pushed.


Steps to Reproduce
  1. Place or spawn two drying racks.
  2. Wait for rain or force it.
  3. Place kelp on one of the drying racks (it can be any product, but kelp dries in two minutes, taking the least amount of time).
  4. Drop and Umbralla near them and activate it. Make sure the dome covers both drying racks.
  5. Place kelp on the other drying rack.
  6. Observe that only the second kelp will dry, while the other one won't until it stops raining.

Do note that using LongUpdate will result in expected behavior instead of the bugged behavior, so don't use that.

You can also test placing an Umbralla dome first, then place what you want to dry, then deactive the dome and activate it again, resulting in no drying as well.

  • Like 1



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.

You and I have come to the same conclusion for this the EntityScript:AddComponent does not add the component until after the event fires making the check not valid for this event callback.

Changed Status to Fixed

  • Like 2

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