Repository navigation
Script
Home | API by Category | Complete API Index | API Status
| Field | Value |
|---|---|
| Full name | Electron2D.Script |
| Namespace | Electron2D |
| Kind | class |
| Category | API Resources |
Describes a registered compiled C# Node or Resource and its source, typed schema and construction factory.
public sealed class Electron2D.ScriptProject code remains in the consumer assembly and executes ordinary typed callbacks. Source edits do not replace CLR classes. Loading validates compiler source checksums; build/restart and live reassignment remain explicit. Ordinary nested resource duplication preserves this shared asset. Explicit root/force copies have independent source text with the same compiled registration. Scene-local resources follow their local flag.
Inherits: Resource
Kind: constructor
public Script()Creates an unbound source asset; registration/loading supplies its compiled class association.
Kind: method
public System.Boolean CanInstantiate()Reports whether a concrete exact construction factory is available.
False for unbound or abstract assets.
CopyCustomStateTo(Electron2D.Resource, System.Boolean, Electron2D.DeepDuplicateMode, System.Func<Electron2D.Resource, Electron2D.Resource>, System.Func<Electron2D.Resource, Electron2D.Resource>)
Kind: method
protected override System.Void CopyCustomStateTo(Electron2D.Resource target, System.Boolean deep, Electron2D.DeepDuplicateMode mode, System.Func<Electron2D.Resource, Electron2D.Resource> duplicate, System.Func<Electron2D.Resource, Electron2D.Resource> force)Kind: method
protected override Electron2D.Resource CreateDuplicateInstance()Kind: method
protected override System.Void Dispose(System.Boolean disposing)Kind: method
public Electron2D.Script GetBaseScript()Loads the directly inherited registered script asset, when the project base class has one.
Borrowed cached base Script, or null for a native/unregistered base.
Kind: method
public System.String GetGlobalName()Returns the declared global class name.
The CLR class name with GlobalClassAttribute, or empty.
Kind: method
public System.Type GetInstanceBaseType()Returns the first native engine class inherited by the compiled project class.
Native CLR base type, or null when unbound.
Kind: method
public TValue GetPropertyDefaultValue<TOwner, TValue>(PropertyDescriptor<TOwner, TValue> property, TOwner owner)Reads a typed declared default in an existing compatible owner context.
The declared revert/default value.
-
property: Registered typed descriptor. -
owner: Live owner whose lifetime retains borrowed defaults.
-
T:System.ArgumentException: Owner or descriptor is unrelated. -
T:System.InvalidOperationException: No declared default exists.
Kind: method
protected override System.Collections.Generic.IEnumerable<Electron2D.PropertyDescriptor> GetPropertyDescriptors()Kind: method
public Electron2D.RPCRegistration[] GetRPCConfig()Returns the compiled class's effective typed RPC declarations without constructing an instance.
Most-derived declarations come first, followed by unshadowed registered bases in declaration order. Instance RPCConfig overrides/removals affect only that Node. Editable source text does not change compiled declarations.
A caller-owned snapshot of shared immutable method tokens and copied policies; empty for unbound or Resource roles.
-
T:System.ObjectDisposedException: This script resource is disposed.
Kind: method
public Dictionary<System.String, TValue> GetScriptConstantMap<TValue>()Copies constants of one exact caller-selected value type.
Names and typed values, including project bases.
Kind: method
public System.Reflection.MethodInfo[] GetScriptMethodList()Returns declared project methods and inherited project methods without invoking them.
Copied registration-time CLR method metadata, ordered by name/signature.
Kind: method
public Electron2D.PropertyDescriptor[] GetScriptPropertyList()Returns copied typed project property metadata, including registered script bases.
Descriptors with no untyped access channel.
Kind: method
public System.Reflection.EventInfo[] GetScriptSignalList()Returns copied registration-time CLR event metadata for project-defined signals.
Project event declarations including project bases.
Kind: method
public System.Boolean HasScriptMethod(System.String methodName)Reports a project method name across the compiled script inheritance chain.
Whether such a method is declared.
-
methodName: Nonnull metadata name.
Kind: method
public System.Boolean HasScriptSignal(System.String signalName)Reports a project event name across script inheritance.
Whether the signal is declared.
-
signalName: Nonnull event name.
Kind: method
public System.Boolean HasSourceCode()Reports whether source text is nonempty.
Whether SourceCode contains text.
Kind: method
public System.Boolean IsAbstract()Reports whether the associated compiled class is abstract.
False when unbound.
Kind: method
public System.Boolean IsTool()Reports the compiled class's editor tool declaration.
Whether the class carries ToolAttribute.
Kind: method
public T New<T>()Creates a caller-owned instance through the registered exact factory.
The registered factory must construct its result within this call's execution context or engine worker tasks. Pre-existing objects are never acquired or cleaned up.
The actual project class instance.
-
T:System.InvalidOperationException: No factory exists, the expected role is incompatible or the result is invalid or pre-existing. -
T:System.AggregateException: Both result validation and cleanup fail. -
T:System.Exception: The project constructor/schema hook fails.
Kind: method
public T New<T>(Func<T> constructor)Creates a typed instance using a direct C# constructor expression, including constructor arguments.
The constructor is an explicit cold operation. It does not introduce string invocation or a frame dispatcher. Construct the returned object within this invocation's execution context or engine worker tasks. Pre-existing results reject before metadata validation or ownership acquisition. Failure cleanup attempts only a newly constructed result; cleanup errors are retained alongside the original validation error.
Caller-owned exact compiled instance.
-
constructor: Typed constructor, or null for the registered factory.
-
T:System.InvalidOperationException: The class cannot instantiate the role, or the result is pre-existing, null, disposed, the wrong exact class or schema. -
T:System.AggregateException: Both result validation and cleanup fail.
Kind: method
public static System.Void RegisterAbstract<T>(System.String id, System.String sourcePath, Electron2D.PropertyDescriptor[] properties)Registers an abstract project type for inherited source/metadata discovery without a construction factory.
Requires a file-backed assembly, matching portable PDB and untrimmed project declarations. Method, event and literal-field metadata is captured once during registration.
-
id: Stable script identity. -
sourcePath: Portable-PDB source path. -
properties: User-defined typed schema.
-
T:System.ArgumentException: The type is concrete or does not derive from Node/Resource.
RegisterAbstractWithRPC(System.String, System.String, System.ReadOnlySpan<Electron2D.RPCRegistration>, Electron2D.PropertyDescriptor[])
Kind: method
public static System.Void RegisterAbstractWithRPC<TNode>(System.String id, System.String sourcePath, System.ReadOnlySpan<Electron2D.RPCRegistration> rpcConfiguration, Electron2D.PropertyDescriptor[] properties)Registers an abstract compiled Node source with inherited class RPC declarations and typed metadata.
No factory is created. Descendant nodes use these declarations unless a more derived registration supplies the same ID. Later base registration is observed by subsequent queries and invocations.
-
id: Stable script identity. -
sourcePath: Source path proven by portable PDB. -
rpcConfiguration: Copied declarations with distinct IDs and compatible receiver roles. -
properties: Copied user-defined typed schema.
-
T:System.ArgumentException: The role is concrete, source/schema is invalid, or RPC declarations are incompatible. -
T:System.ArgumentNullException: A required argument is null. -
T:System.InvalidOperationException: The class identity/type/path is already registered. -
T:System.NotSupportedException: Matching compiled assembly and portable symbols are unavailable.
Kind: method
public static System.Void RegisterNode<TNode>(System.String id, System.String sourcePath, Func<TNode> factory, Electron2D.PropertyDescriptor[] properties)Registers one compiled C# node/source association and its exact scene factory and user property schema.
Requires a file-backed assembly, matching portable PDB and untrimmed project declarations. Method, event and literal-field metadata is captured once during registration.
-
id: Stable portable file type identity. -
sourcePath: Source path proven by the compiled portable PDB. -
factory: Static exact-type constructor. -
properties: User-defined typed properties; native inherited properties are discovered separately.
-
T:System.ArgumentException: Factory or schema is invalid. -
T:System.InvalidOperationException: Identity is already registered. -
T:System.NotSupportedException: Matching compiled assembly and portable source symbols are unavailable.
RegisterNodeWithRPC(System.String, System.String, Func<TNode>, System.ReadOnlySpan<Electron2D.RPCRegistration>, Electron2D.PropertyDescriptor[])
Kind: method
public static System.Void RegisterNodeWithRPC<TNode>(System.String id, System.String sourcePath, Func<TNode> factory, System.ReadOnlySpan<Electron2D.RPCRegistration> rpcConfiguration, Electron2D.PropertyDescriptor[] properties)Registers a compiled Node source with immutable class RPC declarations and its typed property schema.
Source/factory validation is identical to RegisterNode. Class declarations are inherited by actual Node instances and execute through their ordinary multiplayer interface without constructing metadata prototypes. Derived IDs override base declarations. Shared tokens and their captured state live with the compiled registration. Source text edits do not alter this compiled configuration. Existing registration overloads remain unchanged.
-
id: Stable portable class identity. -
sourcePath: Source path proven by the compiled portable PDB. -
factory: Static exact-type constructor. -
rpcConfiguration: Copied declarations with distinct IDs and compatible receiver roles. -
properties: Copied user-defined typed property descriptors.
-
T:System.ArgumentException: A factory, source, schema, declaration role, duplicate ID or method budget is invalid. -
T:System.ArgumentNullException: A required argument is null. -
T:System.InvalidOperationException: The class identity/type/path is already registered. -
T:System.NotSupportedException: Matching compiled assembly and portable symbols are unavailable.
Kind: method
public static System.Void RegisterResource<TResource>(System.String id, System.String sourcePath, Func<TResource> factory, Electron2D.PropertyDescriptor[] properties)Registers one compiled C# resource/source association and its exact archive factory and user schema.
Requires a file-backed assembly, matching portable PDB and untrimmed project declarations. Method, event and literal-field metadata is captured once during registration.
-
id: Stable portable file type identity. -
sourcePath: Source path proven by portable PDB. -
factory: Static exact-type constructor. -
properties: User-defined typed property schema.
-
T:System.ArgumentException: Factory or schema is invalid. -
T:System.InvalidOperationException: Identity is already registered. -
T:System.NotSupportedException: Matching assembly/source symbols are unavailable.
Kind: property
public System.Type CompiledType { get; }Gets the selected compiled CLR type without constructing an instance.
Null when unbound.
Kind: property
public System.String CompiledTypeID { get; }Gets the stable registered compiled class identity.
Empty when unbound.
Kind: property
public System.String SourceCode { get; set; }Gets or replaces source text without changing its compiled class implementation.
Empty initially; strict UTF-8 source is bounded to eight MiB.
-
T:System.ArgumentNullException: Text is null. -
T:System.ArgumentException: Text is invalid UTF-16 or exceeds the encoded budget.