#[Core Keeper Modding] Player state detection
1 messages · Page 1 of 1 (latest)
I checked what's wrong and why it doesn't seem to work and, the usage of the State classes like Death etc is controlled by a bursted system PlayerState.UpdatePlayerStateSystem
What does this mean? It means that the code from PlayerState.Death is also compiled as long as the function fulfills bursting requiements, which it does in this case - the code we're reading and modifying is only a c# copy of it, there exists a separate compiled path for this function, so our modifications can't affect it
A few months ago I did some tests and you can circumvent bursting of a system - theoretically unbursting it's usage, but it's very new method with not known boundaries so you know... you could struggle a lot with it's usage and debugging when it doesnt work
Also it requires elevated permission if you don't want to upkeep the code on version updates if function signature would change
Do mods need to be added on a fresh world for them to work? I dont even know how to tell if mods uploaded correctly but everytime I try and join the server it says connection closed
You can use the normal chat, no worries, I just moved this topic to a separate one because it might be usefull for future ^^
Ymm, to update mod you need to restart your host/client if that's what you're asking for, as for the connection lost it really shouldnt show that, does your logs say something?
ok sooo can you explain a bit more about this bursting thing? first time hearing this term...
and also am i to assume my attempt was valid?
but the code is just doing an "unexpected behaviour"
Yeah the patch is valid but the method is "not used"
Basically it has a separate native implementation - that's what bursting is
Sooo... I need to find the right function to patch as this is somehow not the right one??
Aah @flint wadi you probably should ask those in #🥽-modding-help ðŸ¤
Far from it, you actually got the right one, but this path is just not used, the game uses the native compiled version of it, normal modifications of this piece of code won't be called
So the game just ignores harmony patches sometimes?
@quaint herald https://gist.github.com/Sashiri/13cc27f67189062cbacfe0f68c05ca9d
This covers what's needed to unburst a system and a job, but I don't really recommend it for you right now, it's messy and disorganized information
I mean i can always just check if the player is dead in the update function i'm just seeking the optimal way (as i should)
Yeah from our perspective it look just like it would be ignored.
Overall the patch is applied, like if you were to call it manually you would see the effect... but as the system that actually changes the State is bursted -> native, this function also got bursted -> made native
Thats why you don't see this path, it's outside of the c#
That's a weird thing to happen. Is it intentional by the devs?
It's a side effect of optimization, the devs could disable it but the performance would also get a chunky hit if they just unbursted everything
Overall the default position of Unity ECS is to burst where possible
Oh that makes sense
I'll give a shot at making it work and share it, I have one working for StateUpdate, but that was honestly a lucky shot, it could break in the next update
So they basically have a function that once loaded gives the same result each time and is optimised to be unmodifiable
Or am i making a wrong assumption
So what you want to do is replicate the function to try and fool the optimisation system?
But if they update anything in the function you'd have to fix it again?
I am going to implement the functionality by checking player health in Update() function for now as this seems a bit too hard to pull off and maintain
Still interested in seeing a solution for this problem for sure though!
Yeah, gonna check few things and I'll come back to you ^.- Then I can actually explain what's going on
The PlayerState.Death.EnterStatePresentation, PlayerState.Death.UpdateStatePresentation and PlayerState.Death.ExitStatePresentation
Are called by a managed system ChangePlayerStatePresentationSystem so you can always patch those methods, but they run only on client (I mean it doesnt really matter in your case, but could if you wanted to expand to multiplayer later)
You can also get the PlayerState.PlayerStateCD component from player, it's used for those State systems so that's not a bad idea, PlayerController.IsDyingOrDead also takes this component as an argument
"they run only on client" would it work if for the host if the host is running the mod in a multiplayer world with other players?
can confirm that patching PlayerState.Death.EnterStatePresentation works tho!
Yeah, the host is a very special case because it's considered both server and a client so you know, you can do some nasty engeeniering across them 😄
Yeah for now just the host being able to run the mod successfully in a multiplayer environment is more than enough 😅
The mod won't really be public cuz of it's niche use case, but a certain someone will be using it pretty soon :D
Great, hope it all works out 💪
Here's an example of how to unburst the PlayerState.ChangePlayerStateSystem
https://gist.github.com/Sashiri/13cc27f67189062cbacfe0f68c05ca9d#file-3-unburst-playerstate-changeplayerstatesystem-cs
I'm a bit fried from this so there's a lot of stuff that could've been simplified
Overall is it worth it to maintain those changes just have Death state notification? Probably not, but it has many more applications in the modding opportunities I guess 🤔 Or if you would need more states to be detected and directly on the server