About entities not all being initialized on the client side.
6 replies, posted
I know that not all ents are networked to the client until the player is close enough to them. But do entities ever get unloaded? Should I trust that once they initialize they'll always be valid?
They should be until they're removed. Although stuff like their position will stop being updated if they get outside of client's PVS again.
BTW, the reason they aren't available initially is that there was no data about them transmitted to a client yet.
They won't be valid during fullupdates either
[QUOTE=Luni;51118579]They won't be valid during fullupdates either[/QUOTE]
Ah, yes. This also had (most likely still has) an issue with [I]:OnRemove()[/I] getting called clientside even if an entity didn't actually get removed. I had to use a timer with IsValid check to verify if the entity was actually removed.
[QUOTE=mijyuoon;51118871]Ah, yes. This also had (most likely still has) an issue with [I]:OnRemove()[/I] getting called clientside even if an entity didn't actually get removed. I had to use a timer with IsValid check to verify if the entity was actually removed.[/QUOTE]
And I assume after an entity is "removed" on the client, ":Initialize()" will be called again?
[QUOTE=LegoGuy;51118992]And I assume after an entity is "removed" on the client, ":Initialize()" will be called again?[/QUOTE]
That's the point, it isn't. And it's actually preferred that way. With unwanted OnRemove calls you can easily deal by using a timer and [I]if IsValid(self) then return end[/I] type of thing, bullshit Initialize calls would just give you trouble by breaking current entity state. If it would be called you'd most likely just have to shove another guard check into it so your entity won't get "initialized" for the second time.
[QUOTE=mijyuoon;51119096]That's the point, it isn't. And it's actually preferred that way. With unwanted OnRemove calls you can easily deal by using a timer and [I]if IsValid(self) then return end[/I] type of thing, bullshit Initialize calls would just give you trouble by breaking current entity state. If it would be called you'd most likely just have to shove another guard check into it so your entity won't get "initialized" for the second time.[/QUOTE]
ENT:OnRemoved() is called as well? I've never seen that happen -- only EntityRemoved called for every replicated entity.
However the game will call NotifyShouldTransmit(ent, true) for all visible entities after the fullupdate, so you can probably use that for some kind of detection?
Sorry, you need to Log In to post a reply to this thread.