Reference Type: Difference between revisions

From Resonite Wiki
add a ton of info yAY
cleanup
 
(3 intermediate revisions by the same user not shown)
Line 1: Line 1:
'''Reference Types''' are a designation of types within the [[FrooxEngine]] [[Data Model]]. They are in contrast to [[Value Type|value types]] in that they exist in one place in memory and are "passed around" by reference rather than by value, such as through a [[Type:SyncField`1|SyncRef<T>]].
'''Reference Types''' are a designation of types within the [[FrooxEngine]] [[Data Model]]. They are in contrast to [[Value Type|value types]] in that they exist in one place in memory and are "passed around" by their [[Type:RefID|Reference ID]] rather than by value, such as through a [[Type:SyncRef`1|SyncRef<T>]].


Every type in the game that is defined through a [https://learn.microsoft.com/en-us/dotnet/csharp/fundamentals/types/classes class] is a reference type. Some examples of reference types include [[Slot|Slots]], [[User|Users]], [[Component|Components]], and [[Type:IField|Fields]]. Types defined through a [https://learn.microsoft.com/en-us/dotnet/csharp/language-reference/builtin-types/struct struct] are <em>not</em> reference types, such as the [[Type:Rect|Rect]] type.
All reference types share the following properties:
* Defined with a [https://learn.microsoft.com/en-us/dotnet/csharp/fundamentals/types/classes class], [https://learn.microsoft.com/en-us/dotnet/csharp/language-reference/keywords/interface interface], [https://learn.microsoft.com/en-us/dotnet/csharp/language-reference/builtin-types/reference-types#the-delegate-type delegate], or [https://learn.microsoft.com/en-us/dotnet/csharp/language-reference/builtin-types/record record] internally.
* Referred to and passed around with [[Type:RefID|Reference IDs]], usually through a SyncRef<T> field.
* Implement [[Type:IWorldElement|IWorldElement]], meaning they can be casted to and from IWorldElement.


In general, the analogue to reference types in [[ProtoFlux]] is the [[Type:Object|object]] type. This can cause some confusion when using nodes that interact with FrooxEngine (such as [[ProtoFlux:Data Model Store|Data Model Store]]) vs nodes that are contained entirely within protoflux (such as [[ProtoFlux:Store|Store]]). A slot is an ''Object Ref'' in the Data Model, but an ''Object'' alone in ProtoFlux contexts. A [[Type:string|string]] is a ''value'' in the Data Model, but an ''Object Field'' in ProtoFlux contexts.
Some examples of reference types include [[Slot|Slots]], [[User|Users]], [[Component|Components]], and [[Type:IField|Fields]]. Types defined through a [https://learn.microsoft.com/en-us/dotnet/csharp/language-reference/builtin-types/struct struct] are <em>not</em> reference types, such as the [[Type:Rect|Rect]] type.
 
In general, the analogue to reference types in [[ProtoFlux]] is the [[Type:Object|object]] type. This can cause some confusion when using nodes that interact with FrooxEngine (such as a [[ProtoFlux:Data Model Store|Data Model Store]]) vs nodes that are contained entirely within protoflux (such as a [[ProtoFlux:Local|Local]]). A slot is an ''Object Ref'' in the Data Model, but an ''Object'' alone in ProtoFlux contexts. A [[Type:string|string]] is a ''value'' in the Data Model, but an ''Object Field'' in ProtoFlux contexts.


== See Also ==
== See Also ==
* [[Value Type]]
* [[Value Type]], for the other type of types within the FrooxEngine and ProtoFlux data model.
* [[Type:Object]]
* [[Type:Object]], for the type of types that are not value types within ProtoFlux.
* [https://learn.microsoft.com/en-us/dotnet/csharp/language-reference/keywords/reference-types Microsoft documentation on C# Reference Types]
* [https://learn.microsoft.com/en-us/dotnet/csharp/language-reference/keywords/reference-types Microsoft documentation on C# Reference Types]. Do note that this is ''not'' the same exact implementation as FrooxEngine's reference types, as FrooxEngine "nests" their own data model within C#, but the concepts presented in the article apply to FrooxEngine's data model as well.


[[Category:Type]]
[[Category:Type]]

Latest revision as of 20:09, 13 November 2024

Reference Types are a designation of types within the FrooxEngine Data Model. They are in contrast to value types in that they exist in one place in memory and are "passed around" by their Reference ID rather than by value, such as through a SyncRef<T>.

All reference types share the following properties:

Some examples of reference types include Slots, Users, Components, and Fields. Types defined through a struct are not reference types, such as the Rect type.

In general, the analogue to reference types in ProtoFlux is the object type. This can cause some confusion when using nodes that interact with FrooxEngine (such as a Data Model Store) vs nodes that are contained entirely within protoflux (such as a Local). A slot is an Object Ref in the Data Model, but an Object alone in ProtoFlux contexts. A string is a value in the Data Model, but an Object Field in ProtoFlux contexts.

See Also

  • Value Type, for the other type of types within the FrooxEngine and ProtoFlux data model.
  • Type:Object, for the type of types that are not value types within ProtoFlux.
  • Microsoft documentation on C# Reference Types. Do note that this is not the same exact implementation as FrooxEngine's reference types, as FrooxEngine "nests" their own data model within C#, but the concepts presented in the article apply to FrooxEngine's data model as well.