ActionVariable

Abstract wrapper that pairs an internal Variable storage backend with optional reference semantics. When an ActionVariable references another, GetValue() transparently delegates to the referenced variable, enabling data flow between actions without direct coupling.

The generic subclass ActionVariable<TVariable> adds a typed Value property for convenient Inspector display via Odin.

Definition

Namespace: Paragon.Core.ActionSystem Assembly: Paragon.dll

[Serializable]
public abstract class ActionVariable
[Serializable]
public class ActionVariable<TVariable> : ActionVariable

Quick Lookup

Goal
How

Get the variable's value

actionVariable.GetValue()

Get typed value (generic)

actionVariable.Value (on ActionVariable<T>)

Set the variable's value

actionVariable.SetValue(obj)

Set typed value (generic)

actionVariable.Value = val (on ActionVariable<T>)

Link to another variable

actionVariable.SetReference(other) then IsReference = true

Check if backed by a field

actionVariable.IsFieldVariable

Get the variable name

actionVariable.Name

Get the variable type

actionVariable.Type

Properties

Name

The name of the underlying variable. For field variables this is the field name; for dynamic variables it is the name passed at creation.

Type

The System.Type of the variable's value.

IsReference

When true, GetValue() delegates to the referenced ActionVariable instead of reading the local variable.

IsFieldVariable

Returns true if the underlying storage is a FieldVariable (reflection-backed).

Value (generic subclass only)

Typed accessor available on ActionVariable<TVariable>. Internally calls GetValue() / SetValue().

Constructors

Both constructors are internal — instances are created by ActionVariables, not by user code.

ActionVariable(Action, FieldInfo)

Creates a field-backed variable. The underlying storage is a FieldVariable.

Parameter
Type
Description

action

Action

The owning action instance

fieldInfo

FieldInfo

Reflection info for the field to bind

ActionVariable(Action, Type, string, object)

Creates a dynamic variable. The underlying storage is a DynamicVariable.

Parameter
Type
Description

action

Action

The owning action instance

type

Type

The value type

name

string

The variable name

value

object

Optional initial value

Methods

GetValue

Returns the current value. If IsReference is true and a reference is set, returns the referenced variable's value instead.

Returns: The variable's value as object, or null if the reference is null in reference mode.

SetValue

Sets the value on the underlying Variable storage (field or dynamic). This always writes to the local variable, regardless of IsReference.

Parameter
Type
Description

value

object

The value to assign

UpdateValue

Reads the current value (respecting reference mode) and writes it back to the local variable. Used by ActionVariables.ApplyFieldVariables() to sync referenced values into fields before execution.

SetReference

Sets or clears the reference to another ActionVariable. When setting a non-null reference, the local value is cleared to default.

Parameter
Type
Description

reference

ActionVariable

The variable to reference, or null to clear

circle-exclamation

GetReference

Returns the currently referenced ActionVariable, or null if none is set.

Returns: The referenced ActionVariable or null.

Common Pitfalls

circle-exclamation
circle-exclamation
circle-exclamation

See Also

Last updated