Jump to content

spawner and childspawner components don't remove homeseeker component when entities are detached


hoxi
  • Pending

 Only a few do it manually from their own functions, which isn't ideal.

This results in a bunch of entities not removing their home, but their home entity has forgotten them, meaning they can't enter it or do much with them, and some behaviors are affected due to checking for homeseeker, causing the entity to get leashed to it or, like with bees, not generate new flowers.

This is fixed on saving and loading the world, as homeseeker isn't saved, so, this really should be addressed to not need to do this. This also doesn't apply to entities that came from a stack, because those are new ones which normally don't inherit any of this info (they could by using Stackable:SetOnDeStack, but still).

 

Ideally, "ontrapped" and "detachchild" should be both removing homeseeker from the entity ("death" means it won't be relevant, though you could still do it for that one, same with "onremove" though even less likely), and then run the usual behavior with self._onchildkilled.

local function AddChildListeners(self, child)
    self.inst:ListenForEvent("ontrapped", self._onchildkilled, child)
    self.inst:ListenForEvent("death", self._onchildkilled, child)
    self.inst:ListenForEvent("onremove", self._onchildkilled, child)
    self.inst:ListenForEvent("detachchild", self._onchildkilled, child)
end

This doesn't mean they should forget their "home" location, that should still be dictated by being picked up (if applicable) or similar, because "home" locations are often also set when an entity spawns or their brain initializes, which has issues on its own, which I'll make a separate report about.

 

Also, homeseeker itself could also use an OnRemoveFromEntity function for ease of removal, as simple as this:

function HomeSeeker:OnRemoveFromEntity()
    self:SetHome(nil)
end

Because having to do this is kinda silly:

if inst.components.homeseeker ~= nil then
    inst.components.homeseeker:SetHome(nil)
    inst:RemoveComponent("homeseeker")
end

 


Steps to Reproduce
  • Capture a single bee or killer bee from a bee hive, bee box, or killer bee hive.
  • Drop them.
  • Notice how despite being detached from their home, they'll still behave like they have one, and be unable to go back into it, and affecting their behavior.
  • Now save and load the world, or get a stack of bees, and grab bees from said stack, and drop them.
  • Notice how they're not partially attached to a home and behave as intended.



User Feedback


There are no comments to display.



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