Reporting these since the component and its functionality is being tweaked.
First, the max amount of entities can sometimes be a float. This is notable on spider dens and bee hives and similar, where they set these amounts during spring as shown below, without rounding:
inst.components.childspawner:SetMaxChildren(TUNING.BEEBOX_BEES * TUNING.SPRING_COMBAT_MOD)
You could either round it manually for these cases, or have the functions themselves round the values automatically or something. Maybe rounding from the function would be the way to go to future-proof it and prevent weird behavior with mods as well.
Also, on load, the onoccupied function can be called twice:
if data.childreninside ~= nil then self.childreninside = 0 self:AddChildrenInside(data.childreninside) if self.childreninside > 0 and self.onoccupied ~= nil then self.onoccupied(self.inst) elseif self.childreninside == 0 and self.onvacate ~= nil then self.onvacate(self.inst) end end
The AddChildrenInside function will already call it, there's no need for it here, the onvacate call should still be kept though, data.childreninside could be 0. If anything, AddChildrenInside should be checking if count is higher than 0 before calling it.
So like this:
function ChildSpawner:AddChildrenInside(count) if self.childreninside == 0 and count > 0 and self.onoccupied then self.onoccupied(self.inst) end self.childreninside = self.childreninside + count if self.maxchildren ~= nil then self.childreninside = math.min(self.maxchildren, self.childreninside) end if self.onaddchild ~= nil then self.onaddchild(self.inst, count) end self:TryStopUpdate() --try to stop the update because regening conditions might be invalid now. self:StartUpdate() --try to start the update because spawning conditions might be valid now. end
And this:
-- OnLoad if data.childreninside ~= nil then self.childreninside = 0 self:AddChildrenInside(data.childreninside) if self.childreninside == 0 and self.onvacate ~= nil then self.onvacate(self.inst) end end
I don't remember this having any impact on anything, just a waste by calling the function twice.
EDIT: oh and there's an older report I made related to this component, spawner, and homeseeker, here.
- Debug check a spider den, or beehive, or any childspawner entities that get increased amounts during spring.
- Notice how the values can be floats.
-
2
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 accountSign in
Already have an account? Sign in here.
Sign In Now