You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
{{ message }}
This repository has been archived by the owner on Oct 25, 2021. It is now read-only.
(Sorry if this is out of place or too simple a question.)
Why do these components have static new methods if all of their fields are public? Aren't they construct-able outside the module by listing all the fields regardless? Is it still worth doing assuming that the rest of the code will call the new methods idiomatically? Could you prevent using the direct struct making by adding a private field with the () type? Is there any value in that?
Sorry for the late response. It is perfectly fine to ask here :)
We started out without prefabs, so we manually created the Damage struct using Damage::new. This doesn't happen anymore because the prefabs take care of creating the data.
If you want to prevent creating the structs manually, you can set their fields as private by removing the pub qualifier.
I think what makes more sense depends on your use case. If you have complex data structs, I'd hide their implementation behind new. An example would be Perspective. Perspective stores a matrix internally and you don't want the user to create that matrix manually.
I hope that helps
Sign up for freeto subscribe to this conversation on GitHub.
Already have an account?
Sign in.
(Sorry if this is out of place or too simple a question.)
Why do these components have static new methods if all of their fields are public? Aren't they construct-able outside the module by listing all the fields regardless? Is it still worth doing assuming that the rest of the code will call the new methods idiomatically? Could you prevent using the direct struct making by adding a private field with the
()
type? Is there any value in that?evoli/src/components/combat.rs
Line 47 in efaf66d
The text was updated successfully, but these errors were encountered: