Mhin Ra Posted March 24, 2020 Share Posted March 24, 2020 I am working on a mod that needs to serialize persisted state of an object (in this case, a laser targeting array that will slowly acquire a target over time). I am storing the lockOnPercentage as a StateMachine.<...>.FloatParameter on the TargetingNetwork, which is added as a component to the actual building. This is analogous to the DetectorNetwork that's associated with the CometDetector, although the CometDetector system just recalculates state from scratch on every update, so it doesn't provide the example I'm looking for. What I'm finding is that after loading, the FloatParameter lockOnPercentage is always zero. After testing around it, I think the issue is that the parameter isn't being serialized (although I could be super off). Has anyone done anything like this and\or could anyone offer a framing for how I should think about object serialization in ONI? I can provide my source, but it might be simpler if you just look up DetectorNetwork in the existing Klei assembly. My question more or less boils down to: does a property like DetectorNetwork.selfQuality serialize? And if it doesn't, what should I do to it (or where should I put it) to cause it to get serialized into a save game and then loaded on load? Link to comment Share on other sites More sharing options...
AzeTheGreat Posted March 24, 2020 Share Posted March 24, 2020 Are you using the proper serialization attributes? Here's an example of something I serialize on one of my components. I'm not sure if it'll be able to serialize something of that type, so you may need to serialize a backing field and then set the FloatParameter in initialization. There are also some issues with access modifiers and serialization - you'll frequently need the field to be public. Link to comment Share on other sites More sharing options...
Mhin Ra Posted March 25, 2020 Author Share Posted March 25, 2020 Ah, interesting. I had not considered that. I'll try making the thing into a more simple typed field and then set on init as you suggested. I had found that attribute and tried applying it senselessly liberally, but it didn't have any effect. But, I was trying to serialize the bonkers state machine type, not a simple float I'll let you know how it goes! Link to comment Share on other sites More sharing options...
Recommended Posts
Archived
This topic is now archived and is closed to further replies.
Please be aware that the content of this thread may be outdated and no longer applicable.