Skip to content
eduardgushchin edited this page Oct 22, 2026 · 1 revision

Home | API by Category | Complete API Index | API Status

Field Value
Full name Electron2D.Script
Namespace Electron2D
Kind class
Category API Resources

Overview

Describes a registered compiled C# Node or Resource and its source, typed schema and construction factory.

Syntax

public sealed class Electron2D.Script

Remarks

Project 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

Detailed engine reference

Members

Member Kind Summary
public Script() constructor Creates an unbound source asset; registration/loading supplies its compiled class association.
public System.Boolean CanInstantiate() method Reports whether a concrete exact construction factory is available.
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) method
protected override Electron2D.Resource CreateDuplicateInstance() method
protected override System.Void Dispose(System.Boolean disposing) method
public Electron2D.Script GetBaseScript() method Loads the directly inherited registered script asset, when the project base class has one.
public System.String GetGlobalName() method Returns the declared global class name.
public System.Type GetInstanceBaseType() method Returns the first native engine class inherited by the compiled project class.
public TValue GetPropertyDefaultValue<TOwner, TValue>(PropertyDescriptor<TOwner, TValue> property, TOwner owner) method Reads a typed declared default in an existing compatible owner context.
protected override System.Collections.Generic.IEnumerable<Electron2D.PropertyDescriptor> GetPropertyDescriptors() method
public Electron2D.RPCRegistration[] GetRPCConfig() method Returns the compiled class's effective typed RPC declarations without constructing an instance.
public Dictionary<System.String, TValue> GetScriptConstantMap<TValue>() method Copies constants of one exact caller-selected value type.
public System.Reflection.MethodInfo[] GetScriptMethodList() method Returns declared project methods and inherited project methods without invoking them.
public Electron2D.PropertyDescriptor[] GetScriptPropertyList() method Returns copied typed project property metadata, including registered script bases.
public System.Reflection.EventInfo[] GetScriptSignalList() method Returns copied registration-time CLR event metadata for project-defined signals.
public System.Boolean HasScriptMethod(System.String methodName) method Reports a project method name across the compiled script inheritance chain.
public System.Boolean HasScriptSignal(System.String signalName) method Reports a project event name across script inheritance.
public System.Boolean HasSourceCode() method Reports whether source text is nonempty.
public System.Boolean IsAbstract() method Reports whether the associated compiled class is abstract.
public System.Boolean IsTool() method Reports the compiled class's editor tool declaration.
public T New<T>() method Creates a caller-owned instance through the registered exact factory.
public T New<T>(Func<T> constructor) method Creates a typed instance using a direct C# constructor expression, including constructor arguments.
public static System.Void RegisterAbstract<T>(System.String id, System.String sourcePath, Electron2D.PropertyDescriptor[] properties) method Registers an abstract project type for inherited source/metadata discovery without a construction factory.
public static System.Void RegisterAbstractWithRPC<TNode>(System.String id, System.String sourcePath, System.ReadOnlySpan<Electron2D.RPCRegistration> rpcConfiguration, Electron2D.PropertyDescriptor[] properties) method Registers an abstract compiled Node source with inherited class RPC declarations and typed metadata.
public static System.Void RegisterNode<TNode>(System.String id, System.String sourcePath, Func<TNode> factory, Electron2D.PropertyDescriptor[] properties) method Registers one compiled C# node/source association and its exact scene factory and user property schema.
public static System.Void RegisterNodeWithRPC<TNode>(System.String id, System.String sourcePath, Func<TNode> factory, System.ReadOnlySpan<Electron2D.RPCRegistration> rpcConfiguration, Electron2D.PropertyDescriptor[] properties) method Registers a compiled Node source with immutable class RPC declarations and its typed property schema.
public static System.Void RegisterResource<TResource>(System.String id, System.String sourcePath, Func<TResource> factory, Electron2D.PropertyDescriptor[] properties) method Registers one compiled C# resource/source association and its exact archive factory and user schema.
public System.Type CompiledType { get; } property Gets the selected compiled CLR type without constructing an instance.
public System.String CompiledTypeID { get; } property Gets the stable registered compiled class identity.
public System.String SourceCode { get; set; } property Gets or replaces source text without changing its compiled class implementation.

Member Details

Script()

Kind: constructor

public Script()

Summary

Creates an unbound source asset; registration/loading supplies its compiled class association.

CanInstantiate()

Kind: method

public System.Boolean CanInstantiate()

Summary

Reports whether a concrete exact construction factory is available.

Returns

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)

CreateDuplicateInstance()

Kind: method

protected override Electron2D.Resource CreateDuplicateInstance()

Dispose(System.Boolean)

Kind: method

protected override System.Void Dispose(System.Boolean disposing)

GetBaseScript()

Kind: method

public Electron2D.Script GetBaseScript()

Summary

Loads the directly inherited registered script asset, when the project base class has one.

Returns

Borrowed cached base Script, or null for a native/unregistered base.

GetGlobalName()

Kind: method

public System.String GetGlobalName()

Summary

Returns the declared global class name.

Returns

The CLR class name with GlobalClassAttribute, or empty.

GetInstanceBaseType()

Kind: method

public System.Type GetInstanceBaseType()

Summary

Returns the first native engine class inherited by the compiled project class.

Returns

Native CLR base type, or null when unbound.

GetPropertyDefaultValue(PropertyDescriptor<TOwner, TValue>, TOwner)

Kind: method

public TValue GetPropertyDefaultValue<TOwner, TValue>(PropertyDescriptor<TOwner, TValue> property, TOwner owner)

Summary

Reads a typed declared default in an existing compatible owner context.

Returns

The declared revert/default value.

Parameters

  • property: Registered typed descriptor.
  • owner: Live owner whose lifetime retains borrowed defaults.

Exceptions

  • T:System.ArgumentException: Owner or descriptor is unrelated.
  • T:System.InvalidOperationException: No declared default exists.

GetPropertyDescriptors()

Kind: method

protected override System.Collections.Generic.IEnumerable<Electron2D.PropertyDescriptor> GetPropertyDescriptors()

GetRPCConfig()

Kind: method

public Electron2D.RPCRegistration[] GetRPCConfig()

Summary

Returns the compiled class's effective typed RPC declarations without constructing an instance.

Remarks

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.

Returns

A caller-owned snapshot of shared immutable method tokens and copied policies; empty for unbound or Resource roles.

Exceptions

  • T:System.ObjectDisposedException: This script resource is disposed.

GetScriptConstantMap()

Kind: method

public Dictionary<System.String, TValue> GetScriptConstantMap<TValue>()

Summary

Copies constants of one exact caller-selected value type.

Returns

Names and typed values, including project bases.

GetScriptMethodList()

Kind: method

public System.Reflection.MethodInfo[] GetScriptMethodList()

Summary

Returns declared project methods and inherited project methods without invoking them.

Returns

Copied registration-time CLR method metadata, ordered by name/signature.

GetScriptPropertyList()

Kind: method

public Electron2D.PropertyDescriptor[] GetScriptPropertyList()

Summary

Returns copied typed project property metadata, including registered script bases.

Returns

Descriptors with no untyped access channel.

GetScriptSignalList()

Kind: method

public System.Reflection.EventInfo[] GetScriptSignalList()

Summary

Returns copied registration-time CLR event metadata for project-defined signals.

Returns

Project event declarations including project bases.

HasScriptMethod(System.String)

Kind: method

public System.Boolean HasScriptMethod(System.String methodName)

Summary

Reports a project method name across the compiled script inheritance chain.

Returns

Whether such a method is declared.

Parameters

  • methodName: Nonnull metadata name.

HasScriptSignal(System.String)

Kind: method

public System.Boolean HasScriptSignal(System.String signalName)

Summary

Reports a project event name across script inheritance.

Returns

Whether the signal is declared.

Parameters

  • signalName: Nonnull event name.

HasSourceCode()

Kind: method

public System.Boolean HasSourceCode()

Summary

Reports whether source text is nonempty.

Returns

Whether SourceCode contains text.

IsAbstract()

Kind: method

public System.Boolean IsAbstract()

Summary

Reports whether the associated compiled class is abstract.

Returns

False when unbound.

IsTool()

Kind: method

public System.Boolean IsTool()

Summary

Reports the compiled class's editor tool declaration.

Returns

Whether the class carries ToolAttribute.

New()

Kind: method

public T New<T>()

Summary

Creates a caller-owned instance through the registered exact factory.

Remarks

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.

Returns

The actual project class instance.

Exceptions

  • 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.

New(Func<T>)

Kind: method

public T New<T>(Func<T> constructor)

Summary

Creates a typed instance using a direct C# constructor expression, including constructor arguments.

Remarks

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.

Returns

Caller-owned exact compiled instance.

Parameters

  • constructor: Typed constructor, or null for the registered factory.

Exceptions

  • 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.

RegisterAbstract(System.String, System.String, Electron2D.PropertyDescriptor[])

Kind: method

public static System.Void RegisterAbstract<T>(System.String id, System.String sourcePath, Electron2D.PropertyDescriptor[] properties)

Summary

Registers an abstract project type for inherited source/metadata discovery without a construction factory.

Remarks

Requires a file-backed assembly, matching portable PDB and untrimmed project declarations. Method, event and literal-field metadata is captured once during registration.

Parameters

  • id: Stable script identity.
  • sourcePath: Portable-PDB source path.
  • properties: User-defined typed schema.

Exceptions

  • 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)

Summary

Registers an abstract compiled Node source with inherited class RPC declarations and typed metadata.

Remarks

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.

Parameters

  • 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.

Exceptions

  • 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.

RegisterNode(System.String, System.String, Func<TNode>, Electron2D.PropertyDescriptor[])

Kind: method

public static System.Void RegisterNode<TNode>(System.String id, System.String sourcePath, Func<TNode> factory, Electron2D.PropertyDescriptor[] properties)

Summary

Registers one compiled C# node/source association and its exact scene factory and user property schema.

Remarks

Requires a file-backed assembly, matching portable PDB and untrimmed project declarations. Method, event and literal-field metadata is captured once during registration.

Parameters

  • 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.

Exceptions

  • 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)

Summary

Registers a compiled Node source with immutable class RPC declarations and its typed property schema.

Remarks

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.

Parameters

  • 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.

Exceptions

  • 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.

RegisterResource(System.String, System.String, Func<TResource>, Electron2D.PropertyDescriptor[])

Kind: method

public static System.Void RegisterResource<TResource>(System.String id, System.String sourcePath, Func<TResource> factory, Electron2D.PropertyDescriptor[] properties)

Summary

Registers one compiled C# resource/source association and its exact archive factory and user schema.

Remarks

Requires a file-backed assembly, matching portable PDB and untrimmed project declarations. Method, event and literal-field metadata is captured once during registration.

Parameters

  • id: Stable portable file type identity.
  • sourcePath: Source path proven by portable PDB.
  • factory: Static exact-type constructor.
  • properties: User-defined typed property schema.

Exceptions

  • T:System.ArgumentException: Factory or schema is invalid.
  • T:System.InvalidOperationException: Identity is already registered.
  • T:System.NotSupportedException: Matching assembly/source symbols are unavailable.

CompiledType

Kind: property

public System.Type CompiledType { get;  }

Summary

Gets the selected compiled CLR type without constructing an instance.

Value

Null when unbound.

CompiledTypeID

Kind: property

public System.String CompiledTypeID { get;  }

Summary

Gets the stable registered compiled class identity.

Value

Empty when unbound.

SourceCode

Kind: property

public System.String SourceCode { get; set; }

Summary

Gets or replaces source text without changing its compiled class implementation.

Value

Empty initially; strict UTF-8 source is bounded to eight MiB.

Exceptions

  • T:System.ArgumentNullException: Text is null.
  • T:System.ArgumentException: Text is invalid UTF-16 or exceeds the encoded budget.

Clone this wiki locally