Clean ResourceSupply up.
Add documentation
Reviewed by: @Imarok
Authored by: @Stan
Differential Revision: https://code.wildfiregames.com/D1771
Clean ResourceSupply up.
Description
Details
Event TimelineComment Actions
Is this is the only behavior change in this commit? Behavior changes should be mentioned in the commit message (and before cosmetics). @Imarok, do you have an opinion on the implementation of the serialization change? Comment Actions Okay noted for next time. Comment Actions Oh, f*ck. Have overlooked that. Thank you for noticing. Comment Actions The default review questions are:
Comment Actions Sure. Guess what I thought about before doing my last post. ^^ I even looked through the whole history of that property. But as I'm not that experienced with simulation, I can't say for sure that not serializing that property is ok. For me it seems to be good and won't cause issues, but I can't say for sure because of a lack of experience in that field. Comment Actions The only alternative implementation that I can imagine is to keep the cache property, thus avoid the repeated parsing + infinity test, while still not serializing the property. Secondly, there is at least one more cache variable, why not treat that equally. Serialization is easy, there is a default serialization function that just converts every member property to bytes. If the simulation component has an own Serialize function, that one will be called instead, and the return object will be serialized. Same with the deserialize function. (It's in the ComponentManager cpp file IIRC) From D1718#inline-34356
Comment Actions So the question is whether IsInfinite is called so often that it's worth the cache variable, considering that there can be 10k resource supply entities (trees), or whether the additional memory usage is worse; same for this.cachedType. Comment Actions In this patch, IsInfinite() is called only in TakeResources, i.e. comparatively rarely, the string to number conversion is cheap and the isinfinity test is cheap too. So the question is probably more whether we want to recommend using unserialized cache variables in general or whether we want to recommend not using them in general. Perhaps even better would be not having to convert to a number to begin with using +this.template.Amount, but changing the template manager to construct an object where that property is a number already. (TLDR: blabla no concern) |