feature: Programmable game objects #2721
pandinocoder
started this conversation in
Ideas
Replies: 0 comments
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Uh oh!
There was an error while loading. Please reload this page.
Uh oh!
There was an error while loading. Please reload this page.
-
Description
Types
RenamedFromAttributeThis is used to facilitate identifying objects that were renamed or moved across versions.
[AttributeUsage(AttributeTargets.Assembly | AttributeTargets.Class, Inherits = true, AllowMultiple = true)]Properties:
stringName(positional, required, non-null)boolIsNamespaceQualified(optional, defaultfalse, no effect on assembly attributes)When this is used on assemblies the
IsNamespaceQualifiedproperty has no effect because it is used to determine whether or not to include the current namespace of the attribute target, and assemblies don't have one.Examples
DescriptorDefinitionAttributeThis is used to identify types as descriptor definitions that will be identified by the loader and instantiated.
[AttributeUsage(AttributeTargets.Class, Inherits = true, AllowMultiple = false)]Properties:
GameObjectTypeType(positional, required, non-null) or should this be aType(e.g.typeof(EventDescriptor)?DescriptorDefinition(class?record?, leaning towardsrecordforwithsyntax)Should we have an abstract class for code-based descriptor definitions? No examples of how this would be useful beyond some common API (can be done as an interface too though).
KnownAssembly(readonlysealedrecord)[Key]GuidId(sourced fromassembly-metadata.intersect.json)stringName(most recent assembly name, should not include version or public key)stringVersion(most recent version of the assembly)[NotMapped]AssemblyAssembly(the CLR assembly reference, required for the construction of theKnownAssembly)HashSet<KnownAssemblyAlias>AliasesHashSet<KnownType>TypesKnownAssemblyAlias(readonlysealedrecord)IdandNameGuidId[ForeignKey(nameof(Id))]KnownAssemblyAssemblystringName(assembly alias, should not include version or public key, there will always exist an alias that exactly matches theKnownAssembly)string?Version(most recent version of the renamed assembly, null if the assembly was never loaded with this alias)KnownTypeKind(enum:byte)Unknown=0)Descriptor=1Enum is meant to leave room for other kinds of known types in future features.
KnownType(readonlysealedrecord)GuidAssemblyId[ForeignKey(nameof(AssemblyId))]KnownAssemblyAssembly[Key]GuidId(UUID v5)stringName(this is namespace-qualified, there will always exist an alias that exactly matches theIdandName)KnownTypeKindKind[NotMapped]TypeCLRType(required for construction of theKnownType)HashSet<KnownTypeAlias>AliasesKnownTypeAlias(readonlysealedrecord)TypeIdandNameGuidId(UUID v5)GuidAssemblyId[ForeignKey(nameof(AssemblyId))]KnownAssemblyAssemblyGuidTypeId(UUID v5)[ForeignKey(nameof(TypeId))]KnownTypeTypestringName(this is namespace-qualified)Source Generators
We need a source generator to generate a
assembly-metadata.intersect.jsonfilePropertiesfolder of all assembliesIntersect.propsandIntersectPlugin.propsfiles so each individual assembly doesn't need to add it (the source generator will also be referenced in those files for the same reason, this can get put into Intersect.Building with the key generator task)Current structure:
{ "Version": 1, "AssemblyId": "<UUIDv4 or UUIDv7>" }Database Tables
KnownAssembliesIdId(UUID v4 or v7), not database-generated, this is sourced fromassembly-metadata.intersect.jsonKnownAs(string, not nullable) this is the most recently seen assembly nameLatestVersion(string, not nullable) this is the most recently seen assembly versionIdand is unique (in this table, seeKnownAssemblyAliasesfor rename-aware aliases)KnownAssemblyAliasesIdandNameId(UUID v4 or v7), foreign key toKnownAssembliesName(string, not nullable) this is an assembly name either sourced from the assembly or[assembly: RenamedFrom(...)]attributes, not necessarily the latestVersion(string, not nullable) this is the most recently seen assembly version for the given aliasKnownTypesIdAssemblyId, foreign key toKnownAssembliesId(UUID v5), generated using theAssemblyIdas the base andNameas the extra informationName(string), namespace-qualified most recently seen type name (not unique)KnownTypeAliasesIdCurrentIdandNameAssemblyId, foreign key toKnownAssembliesCurrentTypeId, foreign key toKnownTypesId(UUID v5), generated using theAssemblyIdas the base and theNameof this row (not the current type name) as the extra informationName, the namespace-qualified name of the type (sourced from current type name andRenamedFromattributes)Loader
Success/Error Handling
Identifying Known Types
assembly-metadata.intersect.jsonfile will be loadedKnownAssembliesis checked for a row with a matchingId, if it found the current assembly name (not version qualified) will be compared againstKnownAs[assembly: RenamedFrom(...)]attributes, and if a match to the currentKnownAsis found it will move to step 2[assembly: RenamedFrom(...)]attributes match, it will check theKnownAssemblyAliasesfor a match, first with the current name and then by all of the renames -- if a match is found it will move to step 2KnownAssemblyAliasesthey will be addedLatestVersionofKnownAssembliesandKnownAssemblyAliasesin the row specific to the current alias[DescriptorDefinition]annotated classes will be fetched, and will be checked just like the assembliesKnownTypesand it does not match directly, has no matchingRenamedFromattributes, and it doesn't directly match or have anyRenamedFromoverlap inKnownTypeAliases, loading will be refusedKnownTypesentry (identified by foreign keyCurrentTypeIdinKnownTypeAliases) does not directly match, the entry will be replaced with the appropriate entry for the current type, and all aliases for the previous entry will have theirCurrentTypeIdcolumn updated to the newIdRenamedFromIntended Use-Case
Allow game objects, principally events, to be written in code for those who would prefer to not use things like the event editor.
This also facilitates forks and plugins with built-in/portable game objects.
Duplicate Check
Beta Was this translation helpful? Give feedback.
All reactions