{"TotalCount":74,"Files":[{"Ident":"igor.reactivity","Path":"Editor/Debugger/DebuggerWidget.cs","FileName":"DebuggerWidget.cs","PackageType":"library","CodeKind":"Editor","AssetVersionId":302096,"IsPrivate":false,"Code":"#if DEBUG\n\nusing Sandbox.Reactivity.Internals;\nusing Sandbox.UI;\n\nnamespace Sandbox.Reactivity.Editor.Debugger;\n\n// ReSharper disable once ClassNeverInstantiated.Global\n[Dock(\u0022Editor\u0022, \u0022Reactivity Debugger\u0022, \u0022local_fire_department\u0022)]\ninternal sealed partial class DebuggerWidget : Widget\n{\n\tprivate readonly TreeView _tree;\n\n\tpublic DebuggerWidget(Widget? parent)\n\t\t: base(parent)\n\t{\n\t\tLayout = new Column\n\t\t{\n\t\t\tSpacing = 2,\n\t\t\tChildren =\n\t\t\t[\n\t\t\t\tnew Widget\n\t\t\t\t{\n\t\t\t\t\tLayout = new Row\n\t\t\t\t\t{\n\t\t\t\t\t\tSpacing = 2,\n\t\t\t\t\t\tChildren =\n\t\t\t\t\t\t[\n\t\t\t\t\t\t\t// TODO: search bar\n\t\t\t\t\t\t\tnew Widget\n\t\t\t\t\t\t\t{\n\t\t\t\t\t\t\t\tHorizontalSizeMode = SizeMode.Flexible,\n\t\t\t\t\t\t\t},\n\t\t\t\t\t\t\tnew Widget\n\t\t\t\t\t\t\t{\n\t\t\t\t\t\t\t\tBackgroundColor = Theme.ControlBackground,\n\t\t\t\t\t\t\t\tBorderRadius = Theme.ControlRadius,\n\t\t\t\t\t\t\t\tLayout = new Row\n\t\t\t\t\t\t\t\t{\n\t\t\t\t\t\t\t\t\tChildren =\n\t\t\t\t\t\t\t\t\t[\n\t\t\t\t\t\t\t\t\t\tnew ToolButton(\u0022Settings\u0022, \u0022more_vert\u0022, this)\n\t\t\t\t\t\t\t\t\t\t{\n\t\t\t\t\t\t\t\t\t\t\tMouseLeftPress = () =\u003E Settings\u003CDebuggerWidget\u003E.OpenContextMenu(this),\n\t\t\t\t\t\t\t\t\t\t},\n\t\t\t\t\t\t\t\t\t],\n\t\t\t\t\t\t\t\t},\n\t\t\t\t\t\t\t},\n\t\t\t\t\t\t],\n\t\t\t\t\t},\n\t\t\t\t},\n\t\t\t\tnew Widget\n\t\t\t\t{\n\t\t\t\t\tBackgroundColor = Theme.ControlBackground,\n\t\t\t\t\tBorderRadius = Theme.ControlRadius,\n\t\t\t\t\tLayout = new Column\n\t\t\t\t\t{\n\t\t\t\t\t\tChildren =\n\t\t\t\t\t\t[\n\t\t\t\t\t\t\t_tree = new TreeView\n\t\t\t\t\t\t\t{\n\t\t\t\t\t\t\t\tMargin = new Margin(8, 0),\n\t\t\t\t\t\t\t\tSelectionOverride = () =\u003E EditorUtility.InspectorObject,\n\t\t\t\t\t\t\t},\n\t\t\t\t\t\t],\n\t\t\t\t\t},\n\t\t\t\t},\n\t\t\t],\n\t\t};\n\n\t\tEffect.OnEffectRootCreated \u002B= OnEffectRootCreated;\n\t}\n\n\tpublic override void OnDestroyed()\n\t{\n\t\tforeach (var item in _tree.Items) // .Items makes a copy\n\t\t{\n\t\t\tif (item is EffectTreeNode node)\n\t\t\t{\n\t\t\t\tnode.Dispose();\n\t\t\t}\n\t\t}\n\n\t\t_tree.Clear();\n\n\t\tEffect.OnEffectRootCreated -= OnEffectRootCreated;\n\t}\n\n\tprivate void OnEffectRootCreated(Effect root)\n\t{\n\t\tif (root.IsDisposed)\n\t\t{\n\t\t\t// just in case - effects from other scenes (e.g. prefab editors) might cause this to happen\n\t\t\treturn;\n\t\t}\n\n\t\tif (!ShowUiEffects \u0026\u0026 root.Parent is IReactivePanel)\n\t\t{\n\t\t\treturn;\n\t\t}\n\n\t\tif (!ShowGameplayEffects \u0026\u0026 root.Parent is (Component or GameObject) and not IReactivePanel)\n\t\t{\n\t\t\treturn;\n\t\t}\n\n\t\tvar node = new EffectTreeNode(root);\n\t\t_tree.AddItem(node);\n\n\t\tif (AutoExpand)\n\t\t{\n\t\t\t_tree.Open(node, true);\n\t\t}\n\t}\n}\n\n#endif\n"},{"Ident":"igor.reactivity","Path":"Editor/Inspector/SerializedReactiveObjectProperty.cs","FileName":"SerializedReactiveObjectProperty.cs","PackageType":"library","CodeKind":"Editor","AssetVersionId":302096,"IsPrivate":false,"Code":"#if DEBUG\n\nusing Sandbox.Reactivity.Internals;\n\nnamespace Sandbox.Reactivity.Editor.Inspector;\n\ninternal class SerializedReactiveObjectProperty(IReactiveObject reactive) : SerializedProperty\n{\n\tprotected readonly IReactiveObject ReactiveObject = reactive;\n\n\tpublic override string Name { get; } = reactive.Name ?? \u0022Reactive Object\u0022;\n\n\tpublic override string DisplayName =\u003E Name;\n\n\tpublic override Type PropertyType =\u003E ReactiveObject.GetType();\n\n\tpublic override bool IsEditable =\u003E false;\n\n\tpublic override bool IsValid =\u003E ReactiveObject is not Effect { IsDisposed: true } \u0026\u0026 base.IsValid;\n\n\tpublic override void SetValue\u003CT\u003E(T value)\n\t{\n\t}\n\n\tpublic override T GetValue\u003CT\u003E(T defaultValue = default!)\n\t{\n\t\treturn ValueToType(ReactiveObject, defaultValue);\n\t}\n}\n\n#endif\n"},{"Ident":"igor.reactivity","Path":".obj/__compiler_extra.cs","FileName":"__compiler_extra.cs","PackageType":"library","CodeKind":"Game","AssetVersionId":302096,"IsPrivate":false,"Code":"global using static Sandbox.Internal.GlobalGameNamespace;\r\nglobal using Microsoft.AspNetCore.Components;\r\nglobal using Microsoft.AspNetCore.Components.Rendering;\r\n[assembly: global::System.Reflection.AssemblyMetadata( \u0022AddonTitle\u0022, \u0022Reactivity\u0022 )]\r\n[assembly: global::System.Reflection.AssemblyMetadata( \u0022AddonIdent\u0022, \u0022reactivity\u0022 )]\r\n[assembly: global::System.Reflection.AssemblyMetadata( \u0022OrgIdent\u0022, \u0022igor\u0022 )]\r\n[assembly: global::System.Reflection.AssemblyMetadata( \u0022Ident\u0022, \u0022igor.reactivity\u0022 )]\r\n[assembly: global::System.Reflection.AssemblyMetadata( \u0022EngineVersion\u0022, \u002226\u0022 )]\r\n[assembly: global::System.Reflection.AssemblyMetadata( \u0022EngineMinorVersion\u0022, \u00221\u0022 )]\r\n\r\n[assembly: System.Runtime.Versioning.TargetFramework( \u0022.NETCoreApp,Version=v9.0\u0022, FrameworkDisplayName = \u0022.NET 9.0\u0022 )]\r\n[assembly: global::System.Reflection.AssemblyMetadata( \u0022CompileTime\u0022, \u00222026-06-27T21:09:21.7423840Z\u0022 )]\r\n[assembly: global::System.Reflection.AssemblyVersion(\u00220.0.111.0\u0022)]\r\n[assembly: global::System.Reflection.AssemblyFileVersion(\u00220.0.111.0\u0022)]"},{"Ident":"igor.reactivity","Path":"Code/Internals/Runtimes/Runtime.cs","FileName":"Runtime.cs","PackageType":"library","CodeKind":"Game","AssetVersionId":302096,"IsPrivate":false,"Code":"using System.Runtime.CompilerServices;\n\nnamespace Sandbox.Reactivity.Internals.Runtimes;\n\ninternal sealed class Runtime : IDisposable\n{\n\t/// \u003Csummary\u003E\n\t/// Effects that are waiting to run due to reactivity changes.\n\t/// \u003C/summary\u003E\n\tprivate readonly Queue\u003CEffect\u003E _pendingEffects = new(16);\n\n\t/// \u003Csummary\u003E\n\t/// How many effects have run during a flush operation.\n\t/// \u003C/summary\u003E\n\tprivate uint _flushDepth;\n\n\t/// \u003Csummary\u003E\n\t/// Whether pending effects are currently being run.\n\t/// \u003C/summary\u003E\n\tprivate bool _isFlushing;\n\n\t/// \u003Csummary\u003E\n\t/// The currently executing effect.\n\t/// \u003C/summary\u003E\n\tpublic Effect? CurrentEffect { get; set; }\n\n\t/// \u003Csummary\u003E\n\t/// The currently executing reaction.\n\t/// \u003C/summary\u003E\n\tpublic IReaction? CurrentReaction { get; set; }\n\n\t/// \u003Csummary\u003E\n\t/// A monotonically increasing counter that\u0027s incremented when an \u003Csee cref=\u0022IProducer\u0022 /\u003E updates its current\n\t/// value.\n\t/// \u003C/summary\u003E\n\tpublic uint Version { get; set; } = 1;\n\n\t/// \u003Csummary\u003E\n\t/// Whether dependency tracking is currently disabled.\n\t/// \u003C/summary\u003E\n\tpublic bool IsUntracking { get; set; }\n\n\t/// \u003Csummary\u003E\n\t/// Whether a flush was scheduled to run at the end of the frame.\n\t/// \u003C/summary\u003E\n\tpublic bool IsFlushScheduled { get; private set; }\n\n\t/// \u003Csummary\u003E\n\t/// Whether an effect is currently executing its teardown function. This is used by producers to skip any\n\t/// recomputation when accessed to ensure the previous value is returned.\n\t/// \u003C/summary\u003E\n\tpublic bool IsRunningTeardown { get; set; }\n\n\tpublic void Dispose()\n\t{\n\t\t_pendingEffects.Clear();\n\t\tCurrentEffect = null;\n\t\tCurrentReaction = null;\n\t\tVersion = uint.MaxValue;\n\t\tIsUntracking = true;\n\t\tIsFlushScheduled = false;\n\t\t_isFlushing = false;\n\t}\n\n\t/// \u003Csummary\u003E\n\t/// Returns the currently executing effect.\n\t/// \u003C/summary\u003E\n\t/// \u003Cexception cref=\u0022InvalidOperationException\u0022\u003E\n\t/// Thrown if there is no effect that is currently executing.\n\t/// \u003C/exception\u003E\n\tpublic Effect EnsureCurrentEffect([CallerMemberName] string name = \u0022Effect\u0022)\n\t{\n\t\treturn CurrentEffect ?? throw new InvalidOperationException(name \u002B \u0022 must be created in an effect root\u0022);\n\t}\n\n\tpublic void ScheduleEffect(Effect effect)\n\t{\n\t\t_pendingEffects.Enqueue(effect);\n\n\t\tif (!IsFlushScheduled \u0026\u0026 !_isFlushing)\n\t\t{\n\t\t\tIsFlushScheduled = true;\n\t\t}\n\t}\n\n\t/// \u003Csummary\u003E\n\t/// Empties the queue of effects that are scheduled to run due to one of their dependencies changing. This should\n\t/// only be run when you want an effect to re-run immediately after changing a reactive value.\n\t/// \u003C/summary\u003E\n\tpublic void Flush()\n\t{\n\t\tif (_isFlushing)\n\t\t{\n\t\t\treturn;\n\t\t}\n\n\t\t_isFlushing = true;\n\t\tIsFlushScheduled = false;\n\n\t\ttry\n\t\t{\n\t\t\twhile (_pendingEffects.TryDequeue(out var effect))\n\t\t\t{\n\t\t\t\tif (_flushDepth\u002B\u002B \u003E 1000)\n\t\t\t\t{\n\t\t\t\t\t_pendingEffects.Clear();\n\t\t\t\t\t_pendingEffects.TrimExcess(16);\n\n#if DEBUG\n\t\t\t\t\tvar exception = new InfiniteLoopException(_effectExecutions);\n\t\t\t\t\tOnFlushInfiniteLoop?.Invoke(exception);\n\n\t\t\t\t\tthrow exception;\n#else\n\t\t\t\t\tthrow new InfiniteLoopException();\n#endif\n\t\t\t\t}\n\n\t\t\t\tif (effect.ShouldRun)\n\t\t\t\t{\n\t\t\t\t\teffect.Run();\n#if DEBUG\n\t\t\t\t\t_effectExecutions[effect] = _effectExecutions.GetValueOrDefault(effect) \u002B 1;\n#endif\n\t\t\t\t}\n\t\t\t}\n\t\t}\n\t\tfinally\n\t\t{\n\t\t\t_flushDepth = 0;\n\t\t\t_isFlushing = false;\n#if DEBUG\n\t\t\t_effectExecutions.Clear();\n#endif\n\t\t}\n\t}\n\n#if DEBUG\n\t/// \u003Csummary\u003E\n\t/// Which effects have executing during the current flush, and how many times they\u0027ve executed.\n\t/// \u003C/summary\u003E\n\tprivate readonly Dictionary\u003CEffect, int\u003E _effectExecutions = [];\n\n\t/// \u003Csummary\u003E\n\t/// Called when an infinite loop occurred during a flush.\n\t/// \u003C/summary\u003E\n\tpublic static event Action\u003CInfiniteLoopException\u003E? OnFlushInfiniteLoop;\n#endif\n}\n"},{"Ident":"igor.reactivity","Path":"Code/ReactivePanel.cs","FileName":"ReactivePanel.cs","PackageType":"library","CodeKind":"Game","AssetVersionId":302096,"IsPrivate":false,"Code":"#if SANDBOX\nusing System.Diagnostics;\nusing Sandbox.Reactivity.Internals;\nusing Sandbox.UI;\nusing static Sandbox.Reactivity.Reactive;\n#if JETBRAINS_ANNOTATIONS\nusing JetBrains.Annotations;\n#endif\n\nnamespace Sandbox.Reactivity;\n\n/// \u003Csummary\u003E\n/// The reactive counterpart to \u003Csee cref=\u0022Panel\u0022 /\u003E that allows usage of reactive properties.\n/// \u003C/summary\u003E\n/// \u003Cremarks\u003E\n/// Make sure you set up an effect root using \u003Csee cref=\u0022PanelRoot\u0022 /\u003E at the top of your razor markup:\n/// \u003Ccode\u003E\n/// @{ using var _ = PanelRoot(); }\n/// \u003C/code\u003E\n/// Engine limitations prevent this from being done automatically.\n/// \u003C/remarks\u003E\n#if JETBRAINS_ANNOTATIONS\n[PublicAPI]\n#endif\npublic class ReactivePanel : Panel, IReactivePropertyContainer, IReactivePanel\n{\n\tprivate Effect? _effectRoot;\n\n\tprivate Effect? _renderEffectRoot;\n\n\tprivate int _version;\n\n\tpublic ReactivePanel()\n\t{\n\t\tvar parent = Runtime.CurrentEffect;\n\n\t\t_effectRoot = new Effect([StackTraceHidden] [DebuggerStepThrough]() =\u003E\n\t\t\t{\n\t\t\t\tOnActivate();\n\t\t\t\treturn null;\n\t\t\t},\n\t\t\tparent,\n\t\t\tfalse);\n\n\t\t_effectRoot.SetDebugInfo(DisplayInfo.For(this).Name,\n\t\t\tDisplayInfo.For(this).Icon,\n\t\t\tnew CallLocation(GetType(), nameof(OnActivate)),\n\t\t\tparent ?? (object?)this);\n\n\t\t_effectRoot.Run();\n\t}\n\n\tEffect? IReactivePanel.RenderEffectRoot\n\t{\n\t\tget =\u003E _renderEffectRoot;\n\t\tset =\u003E _renderEffectRoot = value;\n\t}\n\n\tint IReactivePanel.Version\n\t{\n\t\tget =\u003E _version;\n\t\tset =\u003E _version = value;\n\t}\n\n\tDictionary\u003Cint, IProducer\u003E IReactivePropertyContainer.Producers { get; } = [];\n\n\tprotected ReactivePanelScope PanelRoot()\n\t{\n\t\treturn new ReactivePanelScope(this);\n\t}\n\n\tpublic sealed override void Delete(bool immediate = false)\n\t{\n\t\t_renderEffectRoot?.Dispose();\n\t\t_renderEffectRoot = null;\n\n\t\t_effectRoot?.Dispose();\n\t\t_effectRoot = null;\n\n\t\tbase.Delete(immediate);\n\t}\n\n\tprotected sealed override int BuildHash()\n\t{\n\t\treturn _version;\n\t}\n\n\t/// \u003Csummary\u003E\n\t/// Called inside an effect root when this panel is instantiated, allowing for effects to be created. When this\n\t/// panel is deleted, the effect root (and all of its descendants) are disposed.\n\t/// \u003C/summary\u003E\n\tprotected virtual void OnActivate()\n\t{\n\t}\n}\n#endif\n"},{"Ident":"igor.reactivity","Path":"Code/ReactivePanelScope.cs","FileName":"ReactivePanelScope.cs","PackageType":"library","CodeKind":"Game","AssetVersionId":302096,"IsPrivate":false,"Code":"#if SANDBOX\nusing Sandbox.Reactivity.Internals;\n#if JETBRAINS_ANNOTATIONS\nusing JetBrains.Annotations;\n#endif\n\n// we can\u0027t wrap the BuildRenderTree method for razor components, so we need something that can set up the proper\n// scope inside the markup itself\n\nnamespace Sandbox.Reactivity;\n\n/// \u003Csummary\u003E\n/// A disposable that\u0027s used to enable reactivity for a \u003Csee cref=\u0022ReactivePanelComponent\u0022 /\u003E or\n/// \u003Csee cref=\u0022ReactivePanel\u0022 /\u003E during rendering.\n/// \u003C/summary\u003E\n#if JETBRAINS_ANNOTATIONS\n[PublicAPI]\n#endif\npublic readonly ref struct ReactivePanelScope : IDisposable\n{\n\tprivate readonly Effect.ExecutionScope _executionScope;\n\n\tinternal ReactivePanelScope(IReactivePanel panel)\n\t{\n\t\tif (panel.RenderEffectRoot is { } previousRoot)\n\t\t{\n\t\t\t// don\u0027t teardown previous root since we\u0027re already building the render tree by this point\n\t\t\tpreviousRoot.Dispose(false);\n\t\t}\n\n\t\t// nested panels don\u0027t render immediately when a containing panel\u0027s tree is rendering, so the parent is\n\t\t// always null anyway\n\t\tvar effectRoot = new Effect(null, null, true, () =\u003E panel.Version\u002B\u002B);\n\t\teffectRoot.SetDebugInfo(panel.GetType().ToSimpleString(false) \u002B \u0022 (Render)\u0022,\n\t\t\tpanel is ReactivePanel ? \u0022view_quilt\u0022 : \u0022monitor\u0022,\n\t\t\tnew CallLocation(2),\n\t\t\tpanel is ReactivePanel reactive ? reactive.GameObject?.GetComponent\u003CIReactivePanel\u003E() : panel);\n\n\t\tpanel.RenderEffectRoot = effectRoot;\n\t\t_executionScope = new Effect.ExecutionScope(effectRoot);\n\t}\n\n\tpublic void Dispose()\n\t{\n\t\t_executionScope.Dispose();\n\t}\n}\n#endif\n"},{"Ident":"igor.reactivity","Path":"Internals/TypeHierarchy.cs","FileName":"TypeHierarchy.cs","PackageType":"library","CodeKind":"Game","AssetVersionId":302096,"IsPrivate":false,"Code":"#if SANDBOX\nnamespace Sandbox.Reactivity.Internals;\n\n/// \u003Csummary\u003E\n/// Maintains a list of types that are assignable to the given type.\n/// \u003C/summary\u003E\ninternal static class TypeHierarchy\u003CT\u003E\n{\n\t/// \u003Csummary\u003E\n\t/// All types that are assignable to \u003Ctypeparamref name=\u0022T\u0022/\u003E.\n\t/// \u003C/summary\u003E\n\t[SkipHotload]\n\t// ReSharper disable once StaticMemberInGenericType\n\tpublic static readonly IEnumerable\u003CType\u003E Types;\n\n\tstatic TypeHierarchy()\n\t{\n\t\t// since this is most likely going to be used for simple event types, we\u0027re going to assume that the hierarchy\n\t\t// won\u0027t be very large and that checking a list would be faster than hashing for a set\n\t\tvar next = typeof(T);\n\t\tvar hierarchy = new List\u003CType\u003E();\n\n\t\twhile (next != null)\n\t\t{\n\t\t\thierarchy.Add(next);\n\n\t\t\tforeach (var type in next.GetInterfaces())\n\t\t\t{\n\t\t\t\tif (!hierarchy.Contains(type))\n\t\t\t\t{\n\t\t\t\t\thierarchy.Add(type);\n\t\t\t\t}\n\t\t\t}\n\n\t\t\tnext = next.BaseType;\n\n\t\t\tif (next == typeof(object))\n\t\t\t{\n\t\t\t\tbreak;\n\t\t\t}\n\t\t}\n\n\t\tTypes = hierarchy;\n\t}\n}\n#endif\n"},{"Ident":"igor.reactivity","Path":"IState.cs","FileName":"IState.cs","PackageType":"library","CodeKind":"Game","AssetVersionId":302096,"IsPrivate":false,"Code":"#if JETBRAINS_ANNOTATIONS\n#endif\n\nnamespace Sandbox.Reactivity;\n\n/// \u003Csummary\u003E\n/// An object that contains a reactive value. Reading the value inside an effect will cause it to re-run when it\n/// changes.\n/// \u003C/summary\u003E\n/// \u003Ctypeparam name=\u0022T\u0022\u003EThe type of value this object contains.\u003C/typeparam\u003E\n/// \u003Cremarks\u003E\n/// This can be used to abstract over a \u003Csee cref=\u0022State{T}\u0022 /\u003E or \u003Csee cref=\u0022Derived{T}\u0022 /\u003E as needed.\n/// \u003C/remarks\u003E\n#if JETBRAINS_ANNOTATIONS\n#endif\npublic interface IState\u003CT\u003E\n{\n\t/// \u003Csummary\u003E\n\t/// The current value.\n\t/// \u003C/summary\u003E\n\tT Value { get; set; }\n}\n\n/// \u003Cinheritdoc cref=\u0022IState{T}\u0022 /\u003E\n#if JETBRAINS_ANNOTATIONS\n#endif\npublic interface IReadOnlyState\u003Cout T\u003E\n{\n\t/// \u003Cinheritdoc cref=\u0022IState{T}.Value\u0022 /\u003E\n\tT Value { get; }\n}\n"},{"Ident":"igor.reactivity","Path":"Editor/Inspector/SerializedReactionDependencyProperty.cs","FileName":"SerializedReactionDependencyProperty.cs","PackageType":"library","CodeKind":"Editor","AssetVersionId":302096,"IsPrivate":false,"Code":"#if DEBUG\n\nusing System.Reflection;\nusing System.Text;\nusing Sandbox.Internal;\nusing Sandbox.Reactivity.Internals;\n\nnamespace Sandbox.Reactivity.Editor.Inspector;\n\n/// \u003Csummary\u003E\n/// A property that corresponds to an \u003Csee cref=\u0022IProducer\u0022 /\u003E that an \u003Csee cref=\u0022IReaction\u0022 /\u003E depends on. It uses the\n/// name/location of the property the producer was accessed from (where possible).\n/// \u003C/summary\u003E\ninternal class SerializedReactionDependencyProperty : SerializedProperty\n{\n\tprivate readonly IReaction _reaction;\n\n\tprivate readonly string? _sourceFile;\n\n\tprivate readonly int _sourceLine;\n\n\tprivate readonly PropertyInfo _valueProperty;\n\n\tpublic SerializedReactionDependencyProperty(IProducer producer, IReaction reaction)\n\t{\n\t\tif (producer.GetType() is not { GenericTypeArguments: [var valueType] } producerType)\n\t\t{\n\t\t\tthrow new InvalidOperationException(\u0022Could not determine producer type\u0022);\n\t\t}\n\n\t\tif (producerType.GetProperty(\u0022Value\u0022, valueType) is not { } valueProperty)\n\t\t{\n\t\t\tthrow new InvalidOperationException(\u0022Could not find producer value property\u0022);\n\t\t}\n\n\t\t_reaction = reaction;\n\t\t_valueProperty = valueProperty;\n\t\tProducer = producer;\n\t\tPropertyType = valueType;\n\n\t\tif (reaction is Effect effect)\n\t\t{\n\t\t\tvoid OnEffectDispose()\n\t\t\t{\n\t\t\t\tNoteChanged();\n\n\t\t\t\teffect.OnDisposed -= OnEffectDispose;\n\t\t\t}\n\n\t\t\teffect.OnDisposed \u002B= OnEffectDispose;\n\t\t}\n\n\t\tif (producer.Container is { SourceFile: { } propertyFile, SourceLine: var propertyLine })\n\t\t{\n\t\t\t_sourceFile = propertyFile;\n\t\t\t_sourceLine = propertyLine;\n\t\t}\n\t\telse if (producer.Location is { } location)\n\t\t{\n\t\t\tvar separatorIndex = location.LastIndexOf(\u0027:\u0027);\n\n\t\t\tif (separatorIndex != -1)\n\t\t\t{\n\t\t\t\t_sourceFile = location[..separatorIndex];\n\t\t\t\t_sourceLine = int.TryParse(location[(separatorIndex \u002B 1)..], out var line) ? line : 0;\n\t\t\t}\n\t\t\telse\n\t\t\t{\n\t\t\t\t_sourceFile = location;\n\t\t\t}\n\t\t}\n\t}\n\n\t// needed since we can\u0027t get a concrete generic type definition from a type library to call SetValue on that will\n\t// do this internally. conversion is required for things like enums because the control widget passes around an\n\t// int64 instead of the actual underlying type\n\tprivate static MethodInfo TryConvertMethod =\u003E\n\t\tfield ??= typeof(GlobalSystemNamespace).Assembly.GetType(\u0022Sandbox.Translation\u0022)\n\t\t\t\t?.GetMethod(\u0022TryConvert\u0022,\n\t\t\t\t\tBindingFlags.Static | BindingFlags.NonPublic,\n\t\t\t\t\t[typeof(object), typeof(Type), typeof(object).MakeByRefType()]) ??\n\t\t\tthrow new MemberAccessException(\u0022Could not find Sandbox.Translation.TryConvert\u0022);\n\n\tpublic IProducer Producer { get; }\n\n\tpublic override Type PropertyType { get; }\n\n\tpublic override bool IsProperty =\u003E true;\n\n\tpublic override bool IsEditable =\u003E _reaction is not Effect { IsDisposed: true };\n\n\tpublic override bool IsValid =\u003E _reaction is not Effect { IsDisposed: true } \u0026\u0026 base.IsValid;\n\n\tpublic override string Name =\u003E Producer.Name ?? \u0022Reactive Object\u0022;\n\n\tpublic override string DisplayName =\u003E Producer.Container?.Title ?? Producer.Name ?? \u0022Reactive Object\u0022;\n\n\tpublic override string Description\n\t{\n\t\tget\n\t\t{\n\t\t\tvar description = \u0022\u0022;\n\t\t\tvar containerProperty = \u0022\u0022;\n\t\t\tvar fileLocation = \u0022\u0022;\n\n\t\t\tif (Producer.Container is { } property)\n\t\t\t{\n\t\t\t\tdescription = property.Description;\n\t\t\t\tcontainerProperty =\n\t\t\t\t\t$\u0022 {property.TypeDescription.TargetType.ToRichText()}.\u003Cspan style=\u0027color: #9CDCFE; font-weight: 600;\u0027\u003E{property.Name}\u003C/span\u003E\u0022;\n\t\t\t}\n\n\t\t\tif (_sourceFile != null)\n\t\t\t{\n\t\t\t\tvar line = _sourceLine != 0 ? $\u0022:{_sourceLine}\u0022 : \u0022\u0022;\n\t\t\t\tfileLocation =\n\t\t\t\t\t$\u0022\u003Cbr/\u003E\u003Cspan style=\u0027color: {Theme.Primary.Desaturate(0.3f).Hex};\u0027\u003E{_sourceFile}{line}\u003C/span\u003E\u0022;\n\t\t\t}\n\n\t\t\tStringBuilder result = new();\n\n\t\t\tif (!string.IsNullOrWhiteSpace(containerProperty) || !string.IsNullOrWhiteSpace(_sourceFile))\n\t\t\t{\n\t\t\t\tresult.Append(\u0022Declared in:\u0022);\n\t\t\t}\n\n\t\t\tresult.Append(containerProperty);\n\t\t\tresult.Append(fileLocation);\n\n\t\t\tif (!string.IsNullOrWhiteSpace(description))\n\t\t\t{\n\t\t\t\tresult.Append(\u0022\u003Cbr/\u003E\u003Cbr/\u003E\u0022);\n\t\t\t\tresult.Append(description);\n\t\t\t}\n\n\t\t\treturn result.ToString();\n\t\t}\n\t}\n\n\tpublic override string SourceFile =\u003E _sourceFile!;\n\n\tpublic override int SourceLine =\u003E _sourceLine;\n\n\tpublic override void SetValue\u003CT\u003E(T value)\n\t{\n\t\tobject?[] parameters = [value, _valueProperty.PropertyType, null];\n\n\t\tif (TryConvertMethod.Invoke(null, parameters) is false)\n\t\t{\n\t\t\treturn;\n\t\t}\n\n\t\tNotePreChange();\n\t\t_valueProperty.SetValue(Producer, parameters[2]);\n\t\tNoteChanged();\n\t}\n\n\tpublic override T GetValue\u003CT\u003E(T defaultValue = default!)\n\t{\n\t\treturn ValueToType(Producer.NonReactiveValue, defaultValue);\n\t}\n}\n\n#endif\n"},{"Ident":"igor.reactivity","Path":"Code/ReactiveComponent.cs","FileName":"ReactiveComponent.cs","PackageType":"library","CodeKind":"Game","AssetVersionId":302096,"IsPrivate":false,"Code":"#if SANDBOX\nusing System.Diagnostics;\nusing Sandbox.Reactivity.Internals;\nusing static Sandbox.Reactivity.Reactive;\n#if JETBRAINS_ANNOTATIONS\nusing JetBrains.Annotations;\n#endif\n\nnamespace Sandbox.Reactivity;\n\n/// \u003Csummary\u003E\n/// The base component used to opt into the reactivity system. This allows usage of the reactive property attributes,\n/// and automatically creates an effect root in \u003Csee cref=\u0022OnActivate\u0022 /\u003E.\n/// \u003C/summary\u003E\n/// \u003Cseealso cref=\u0022ReactiveAttribute\u0022 /\u003E\n/// \u003Cseealso cref=\u0022DerivedAttribute\u0022 /\u003E\n#if JETBRAINS_ANNOTATIONS\n[PublicAPI]\n#endif\npublic abstract class ReactiveComponent(ReactiveComponent.ActivationStage activationStage) : Component,\n\tIReactivePropertyContainer\n{\n\t/// \u003Csummary\u003E\n\t/// Describes at what point during its lifecycle a \u003Csee cref=\u0022ReactiveComponent\u0022 /\u003E will run its activation method.\n\t/// \u003C/summary\u003E\n\tpublic enum ActivationStage\n\t{\n\t\t/// \u003Csummary\u003E\n\t\t/// Calls \u003Csee cref=\u0022ReactiveComponent.OnActivate\u0022 /\u003E during \u003Csee cref=\u0022Component.OnEnabled\u0022 /\u003E. This is the\n\t\t/// default.\n\t\t/// \u003C/summary\u003E\n\t\tOnEnabled,\n\n\t\t/// \u003Csummary\u003E\n\t\t/// Calls \u003Csee cref=\u0022ReactiveComponent.OnActivate\u0022 /\u003E during \u003Csee cref=\u0022Component.OnStart\u0022 /\u003E. Useful for when\n\t\t/// you want to access data on other components on the same game object that is only available \u003Ci\u003Eafter\u003C/i\u003E\n\t\t/// they\u0027re enabled.\n\t\t/// \u003C/summary\u003E\n\t\t/// \u003Cremarks\u003E\n\t\t/// If the component is disabled and re-enabled, the activation will subsequently run during\n\t\t/// \u003Csee cref=\u0022Component.OnEnabled\u0022 /\u003E since \u003Csee cref=\u0022Component.OnStart\u0022 /\u003E is only called once ever.\n\t\t/// \u003C/remarks\u003E\n\t\tOnStart,\n\t}\n\n\t/// \u003Csummary\u003E\n\t/// When to run this component\u0027s activation method.\n\t/// \u003C/summary\u003E\n\tprivate readonly ActivationStage _activationStage = activationStage;\n\n\t/// \u003Csummary\u003E\n\t/// The disposable for this component\u0027s effect root that exists while it\u0027s enabled.\n\t/// \u003C/summary\u003E\n\tprivate Effect? _effectRoot;\n\n\t/// \u003Csummary\u003E\n\t/// Whether this component has ever called \u003Csee cref=\u0022Component.OnStart\u0022 /\u003E.\n\t/// \u003C/summary\u003E\n\tprivate bool _hasStarted;\n\n\tprotected ReactiveComponent()\n\t\t: this(ActivationStage.OnEnabled)\n\t{\n\t}\n\n\tDictionary\u003Cint, IProducer\u003E IReactivePropertyContainer.Producers { get; } = [];\n\n\t/// \u003Cinheritdoc cref=\u0022GameObjectExtensions.SendDirect\u0022 /\u003E\n\tpublic void SendDirect\u003CT\u003E(T eventData)\n\t{\n\t\tGameObject?.SendDirect(eventData);\n\t}\n\n\t/// \u003Cinheritdoc cref=\u0022GameObjectExtensions.SendUp\u0022 /\u003E\n\tpublic void SendUp\u003CT\u003E(T eventData)\n\t{\n\t\tGameObject?.SendUp(eventData);\n\t}\n\n\t/// \u003Cinheritdoc cref=\u0022GameObjectExtensions.SendDown\u0022 /\u003E\n\tpublic void SendDown\u003CT\u003E(T eventData)\n\t{\n\t\tGameObject?.SendDown(eventData);\n\t}\n\n\t/// \u003Csummary\u003E\n\t/// Runs a function when this component\u0027s game object receives an event.\n\t/// \u003C/summary\u003E\n\t/// \u003Cparam name=\u0022callback\u0022\u003E\n\t/// The function to run when the event is received. If the function returns \u003Cc\u003Etrue\u003C/c\u003E, the event will prevent\n\t/// further propagation to ancestor/descendant game objects.\n\t/// \u003C/param\u003E\n\t/// \u003Ctypeparam name=\u0022T\u0022\u003E\n\t/// The type of event to listen to. Any received game objects that are assignable to this type will run the\n\t/// function.\n\t/// \u003C/typeparam\u003E\n\tpublic void OnEvent\u003CT\u003E(Func\u003CT, bool\u003E callback)\n\t{\n\t\tif (GameObject is not { } go)\n\t\t{\n\t\t\treturn;\n\t\t}\n\n\t\tvar manager = GameObjectEventManager.GetOrCreate(go);\n\t\tvar parent = Runtime.EnsureCurrentEffect();\n\n\t\tvar effect = new Effect([StackTraceHidden] [DebuggerStepThrough]() =\u003E\n\t\t\t{\n\t\t\t\tmanager.Add(callback);\n\n\t\t\t\treturn () =\u003E manager.Remove(callback);\n\t\t\t},\n\t\t\tparent,\n\t\t\tfalse);\n\n\t\teffect.SetDebugInfo($\u0022OnEvent\u003C{typeof(T).ToSimpleString(false)}\u003E\u0022,\n\t\t\t\u0022electric_bolt\u0022,\n\t\t\tnew CallLocation(1),\n\t\t\tparent);\n\n\t\teffect.Run();\n\t}\n\n\t[StackTraceHidden]\n\tprivate void CreateRootEffect()\n\t{\n\t\t_effectRoot?.Dispose();\n\n\t\t// component lifetimes are managed by their owning game objects, it doesn\u0027t make sense to bind it to the\n\t\t// lifetime of the currently executing effect\n\t\t_effectRoot = new Effect([StackTraceHidden] [DebuggerStepThrough]() =\u003E\n\t\t\t{\n\t\t\t\tOnActivate();\n\t\t\t\treturn null;\n\t\t\t},\n\t\t\tnull,\n\t\t\tfalse);\n\n\t\t_effectRoot.SetDebugInfo(DisplayInfo.For(this).Name,\n\t\t\tDisplayInfo.For(this).Icon,\n\t\t\tnew CallLocation(GetType(), nameof(OnActivate)),\n\t\t\tthis);\n\n\t\t_effectRoot.Run();\n\t}\n\n\tprotected sealed override void OnEnabled()\n\t{\n\t\tif (_activationStage != ActivationStage.OnStart || _hasStarted)\n\t\t{\n\t\t\tCreateRootEffect();\n\t\t}\n\t}\n\n\tprotected sealed override void OnStart()\n\t{\n\t\tif (_activationStage == ActivationStage.OnStart)\n\t\t{\n\t\t\t_hasStarted = true;\n\n\t\t\tCreateRootEffect();\n\t\t}\n\t}\n\n\tprotected sealed override void OnDisabled()\n\t{\n\t\t_effectRoot?.Dispose();\n\t\t_effectRoot = null;\n\t}\n\n\t/// \u003Csummary\u003E\n\t/// Called inside an effect root when this component is enabled, allowing for effects to be created. When this\n\t/// component is disabled, the effect root (and all of its descendants) are disposed.\n\t/// \u003C/summary\u003E\n\tprotected virtual void OnActivate()\n\t{\n\t}\n}\n#endif\n"},{"Ident":"igor.reactivity","Path":"Code/State.cs","FileName":"State.cs","PackageType":"library","CodeKind":"Game","AssetVersionId":302096,"IsPrivate":false,"Code":"using Sandbox.Reactivity.Internals;\n#if JETBRAINS_ANNOTATIONS\nusing JetBrains.Annotations;\n#endif\n\nnamespace Sandbox.Reactivity;\n\n/// \u003Csummary\u003E\n/// A reactive object that contains a value that can be changed at any time.\n/// \u003C/summary\u003E\n/// \u003Ctypeparam name=\u0022T\u0022\u003EThe type of value this state contains.\u003C/typeparam\u003E\n/// \u003Cseealso cref=\u0022Reactive.State\u0022 /\u003E\n#if JETBRAINS_ANNOTATIONS\n[PublicAPI]\n#endif\npublic sealed class State\u003CT\u003E : IProducer\u003CT\u003E, IWritableProducer\u003CT\u003E, IState\u003CT\u003E, IReadOnlyState\u003CT\u003E\n{\n\tprivate readonly List\u003CIReaction\u003E _reactions = [];\n\n\t/// \u003Csummary\u003E\n\t/// The stored value of this state.\n\t/// \u003C/summary\u003E\n\tprivate T _value;\n\n\tprivate uint _writeVersion;\n\n\tinternal State(T initialValue)\n\t{\n\t\t_value = initialValue;\n\t}\n\n\tList\u003CIReaction\u003E IProducer.Reactions =\u003E _reactions;\n\n\t/// \u003Csummary\u003E\n\t/// The version at which this state\u0027s value last changed.\n\t/// \u003C/summary\u003E\n\tuint IProducer.WriteVersion =\u003E _writeVersion;\n\n\tobject? IProducer.NonReactiveValue\n\t{\n\t\tget =\u003E _value;\n\t\tset =\u003E _value = (T)value!;\n\t}\n\n\t/// \u003Csummary\u003E\n\t/// The current value of this state. Reading this inside of an effect will cause it to add this state as a\n\t/// dependency.\n\t/// \u003C/summary\u003E\n\t/// \u003Cseealso cref=\u0022Reactive.Untrack()\u0022 /\u003E\n\t/// \u003Cseealso cref=\u0022Reactive.Untrack(Action)\u0022 /\u003E\n\tpublic T Value\n\t{\n\t\tget\n\t\t{\n\t\t\tthis.TrackRead();\n\t\t\treturn _value;\n\t\t}\n\t\tset\n\t\t{\n\t\t\tif (EqualityComparer\u003CT\u003E.Default.Equals(_value, value))\n\t\t\t{\n\t\t\t\treturn;\n\t\t\t}\n\n\t\t\t_value = value;\n\t\t\t_writeVersion = \u002B\u002BReactive.Runtime.Version;\n\n\t\t\tthis.PropagateReactivity();\n\t\t}\n\t}\n\n\tvoid IProducer.AddReaction(IReaction reaction)\n\t{\n\t\tif (!reaction.IsConnectedToEffect)\n\t\t{\n\t\t\treturn;\n\t\t}\n\n\t\tif (!_reactions.Contains(reaction))\n\t\t{\n\t\t\t_reactions.Add(reaction);\n\t\t}\n\t}\n\n\tvoid IProducer.RemoveReaction(IReaction reaction)\n\t{\n\t\t_reactions.Remove(reaction);\n\t}\n\n\tpublic static implicit operator T(State\u003CT\u003E state)\n\t{\n\t\treturn state.Value;\n\t}\n\n#if DEBUG \u0026\u0026 SANDBOX\n\tstring? IReactiveObject.Name { get; set; } = \u0022State\u0022;\n\n\tstring? IReactiveObject.Icon { get; set; } = \u0022center_focus_strong\u0022;\n\n\tstring? IReactiveObject.Location { get; set; }\n\n\tobject? IReactiveObject.Parent { get; set; }\n\n\tPropertyDescription? IReactiveObject.Container { get; set; }\n#endif\n}\n"},{"Ident":"igor.reactivity","Path":"Internals/GameObjectEventManager.cs","FileName":"GameObjectEventManager.cs","PackageType":"library","CodeKind":"Game","AssetVersionId":302096,"IsPrivate":false,"Code":"#if SANDBOX\nusing System.Collections;\n\nnamespace Sandbox.Reactivity.Internals;\n\nfile sealed class EventList\u003CT\u003E : List\u003CFunc\u003CT, bool\u003E\u003E;\n\n/// \u003Csummary\u003E\n/// Maintains the list of registered event callbacks on a game object.\n/// \u003C/summary\u003E\ninternal sealed class GameObjectEventManager(GameObject go)\n{\n\t/// \u003Csummary\u003E\n\t/// The map of game objects to their event managers.\n\t/// \u003C/summary\u003E\n\tprivate static readonly Dictionary\u003CGameObject, GameObjectEventManager\u003E RegisteredObjects = [];\n\n\t/// \u003Csummary\u003E\n\t/// The map of types to the list of callbacks to run when used as an event.\n\t/// \u003C/summary\u003E\n\tprivate readonly Dictionary\u003CType, IList\u003E _handledEvents = [];\n\n\t/// \u003Csummary\u003E\n\t/// The game object this event manager belongs to.\n\t/// \u003C/summary\u003E\n\tprivate readonly GameObject _owningObject = go;\n\n\t/// \u003Csummary\u003E\n\t/// Returns the event manager for the given game object.\n\t/// \u003C/summary\u003E\n\t/// \u003Cparam name=\u0022go\u0022\u003EThe game object to get the event handler for.\u003C/param\u003E\n\t/// \u003Creturns\u003EThe event manager that corresponds to the given game object, or \u003Cc\u003Enull\u003C/c\u003E if not found.\u003C/returns\u003E\n\tpublic static GameObjectEventManager? Get(GameObject go)\n\t{\n\t\treturn RegisteredObjects.GetValueOrDefault(go);\n\t}\n\n\t/// \u003Csummary\u003E\n\t/// Returns an event manager for the given game object. If it doesn\u0027t already have one, it will be created.\n\t/// \u003C/summary\u003E\n\t/// \u003Cparam name=\u0022go\u0022\u003EThe game object to get an event handler for.\u003C/param\u003E\n\t/// \u003Creturns\u003EAn event handler that corresponds to the given game object.\u003C/returns\u003E\n\tpublic static GameObjectEventManager GetOrCreate(GameObject go)\n\t{\n\t\tif (!RegisteredObjects.TryGetValue(go, out var handler))\n\t\t{\n\t\t\thandler = new GameObjectEventManager(go);\n\t\t\tRegisteredObjects[go] = handler;\n\t\t}\n\n\t\treturn handler;\n\t}\n\n\t/// \u003Csummary\u003E\n\t/// Adds a function to run when an event is received.\n\t/// \u003C/summary\u003E\n\t/// \u003Cparam name=\u0022callback\u0022\u003EThe function to run.\u003C/param\u003E\n\t/// \u003Ctypeparam name=\u0022T\u0022\u003E\n\t/// The event type the function accepts. The function will also run for any events that are assignable to this type.\n\t/// \u003C/typeparam\u003E\n\tpublic void Add\u003CT\u003E(Func\u003CT, bool\u003E callback)\n\t{\n\t\tforeach (var type in TypeHierarchy\u003CT\u003E.Types)\n\t\t{\n\t\t\tif (!_handledEvents.TryGetValue(type, out var eventList))\n\t\t\t{\n\t\t\t\teventList = new EventList\u003CT\u003E();\n\t\t\t\t_handledEvents[type] = eventList;\n\t\t\t}\n\n\t\t\t((EventList\u003CT\u003E)eventList).Add(callback);\n\t\t}\n\t}\n\n\t/// \u003Csummary\u003E\n\t/// Removes a function from running when an event is received.\n\t/// \u003C/summary\u003E\n\t/// \u003Cparam name=\u0022callback\u0022\u003EThe function to remove.\u003C/param\u003E\n\t/// \u003Ctypeparam name=\u0022T\u0022\u003EThe event type the function accepts.\u003C/typeparam\u003E\n\tpublic void Remove\u003CT\u003E(Func\u003CT, bool\u003E callback)\n\t{\n\t\tforeach (var type in TypeHierarchy\u003CT\u003E.Types)\n\t\t{\n\t\t\tif (!_handledEvents.TryGetValue(type, out var eventList))\n\t\t\t{\n\t\t\t\tcontinue;\n\t\t\t}\n\n\t\t\tvar callbacks = (EventList\u003CT\u003E)eventList;\n\n\t\t\tif (callbacks.Remove(callback) \u0026\u0026 callbacks.Count == 0)\n\t\t\t{\n\t\t\t\t_handledEvents.Remove(type);\n\t\t\t}\n\t\t}\n\n\t\tif (_handledEvents.Count == 0)\n\t\t{\n\t\t\tRegisteredObjects.Remove(_owningObject);\n\t\t}\n\t}\n\n\t/// \u003Csummary\u003E\n\t/// Runs any functions on this handler with the given event.\n\t/// \u003C/summary\u003E\n\t/// \u003Cparam name=\u0022eventData\u0022\u003EThe event object to use when running a function.\u003C/param\u003E\n\t/// \u003Ctypeparam name=\u0022T\u0022\u003E\n\t/// The event type to pass to this event handler\u0027s functions. This will call any functions that accept a type that\n\t/// is assignable to this one.\n\t/// \u003C/typeparam\u003E\n\t/// \u003Creturns\u003EWhether a function has requested to stop propagation to other game objects.\u003C/returns\u003E\n\tpublic bool Dispatch\u003CT\u003E(T eventData)\n\t{\n\t\tif (!_handledEvents.TryGetValue(typeof(T), out var eventList))\n\t\t{\n\t\t\treturn false;\n\t\t}\n\n\t\tvar stopPropagation = false;\n\n\t\tusing (new UntrackScope())\n\t\t{\n\t\t\tforeach (var callback in (EventList\u003CT\u003E)eventList)\n\t\t\t{\n\t\t\t\tstopPropagation = callback(eventData) || stopPropagation;\n\t\t\t}\n\t\t}\n\n\t\treturn stopPropagation;\n\t}\n}\n#endif\n"},{"Ident":"igor.reactivity","Path":"State.cs","FileName":"State.cs","PackageType":"library","CodeKind":"Game","AssetVersionId":302096,"IsPrivate":false,"Code":"using Sandbox.Reactivity.Internals;\n#if JETBRAINS_ANNOTATIONS\n#endif\n\nnamespace Sandbox.Reactivity;\n\n/// \u003Csummary\u003E\n/// A reactive object that contains a value that can be changed at any time.\n/// \u003C/summary\u003E\n/// \u003Ctypeparam name=\u0022T\u0022\u003EThe type of value this state contains.\u003C/typeparam\u003E\n/// \u003Cseealso cref=\u0022Reactive.State\u0022 /\u003E\n#if JETBRAINS_ANNOTATIONS\n#endif\npublic sealed class State\u003CT\u003E : IProducer\u003CT\u003E, IWritableProducer\u003CT\u003E, IState\u003CT\u003E, IReadOnlyState\u003CT\u003E\n{\n\tprivate readonly List\u003CIReaction\u003E _reactions = [];\n\n\t/// \u003Csummary\u003E\n\t/// The stored value of this state.\n\t/// \u003C/summary\u003E\n\tprivate T _value;\n\n\tprivate uint _writeVersion;\n\n\tinternal State(T initialValue)\n\t{\n\t\t_value = initialValue;\n\t}\n\n\tList\u003CIReaction\u003E IProducer.Reactions =\u003E _reactions;\n\n\t/// \u003Csummary\u003E\n\t/// The version at which this state\u0027s value last changed.\n\t/// \u003C/summary\u003E\n\tuint IProducer.WriteVersion =\u003E _writeVersion;\n\n\tobject? IProducer.NonReactiveValue\n\t{\n\t\tget =\u003E _value;\n\t\tset =\u003E _value = (T)value!;\n\t}\n\n\t/// \u003Csummary\u003E\n\t/// The current value of this state. Reading this inside of an effect will cause it to add this state as a\n\t/// dependency.\n\t/// \u003C/summary\u003E\n\t/// \u003Cseealso cref=\u0022Reactive.Untrack()\u0022 /\u003E\n\t/// \u003Cseealso cref=\u0022Reactive.Untrack(Action)\u0022 /\u003E\n\tpublic T Value\n\t{\n\t\tget\n\t\t{\n\t\t\tthis.TrackRead();\n\t\t\treturn _value;\n\t\t}\n\t\tset\n\t\t{\n\t\t\tif (EqualityComparer\u003CT\u003E.Default.Equals(_value, value))\n\t\t\t{\n\t\t\t\treturn;\n\t\t\t}\n\n\t\t\t_value = value;\n\t\t\t_writeVersion = \u002B\u002BReactive.Runtime.Version;\n\n\t\t\tthis.PropagateReactivity();\n\t\t}\n\t}\n\n\tvoid IProducer.AddReaction(IReaction reaction)\n\t{\n\t\tif (!reaction.IsConnectedToEffect)\n\t\t{\n\t\t\treturn;\n\t\t}\n\n\t\tif (!_reactions.Contains(reaction))\n\t\t{\n\t\t\t_reactions.Add(reaction);\n\t\t}\n\t}\n\n\tvoid IProducer.RemoveReaction(IReaction reaction)\n\t{\n\t\t_reactions.Remove(reaction);\n\t}\n\n\tpublic static implicit operator T(State\u003CT\u003E state)\n\t{\n\t\treturn state.Value;\n\t}\n\n#if DEBUG \u0026\u0026 SANDBOX\n#endif\n}\n"},{"Ident":"igor.reactivity","Path":"Code/Internals/ReactivePropertyContainer.cs","FileName":"ReactivePropertyContainer.cs","PackageType":"library","CodeKind":"Game","AssetVersionId":302096,"IsPrivate":false,"Code":"#if SANDBOX\n#if JETBRAINS_ANNOTATIONS\nusing JetBrains.Annotations;\n#endif\n\nnamespace Sandbox.Reactivity.Internals;\n\n/// \u003Csummary\u003E\n/// Implemented by classes that support annotating properties with \u003Csee cref=\u0022ReactiveAttribute\u0022 /\u003E.\n/// \u003C/summary\u003E\ninternal interface IReactivePropertyContainer\n{\n\t/// \u003Csummary\u003E\n\t/// The dictionary of this container\u0027s reactive property member IDs to their backing producers.\n\t/// \u003C/summary\u003E\n\tDictionary\u003Cint, IProducer\u003E Producers { get; }\n}\n\n// required to be public due to codegen\npublic static class ReactivePropertyContainer\n{\n\t/// \u003Csummary\u003E\n\t/// The dictionary of static reactive property member IDs to their backing producers.\n\t/// \u003C/summary\u003E\n\tprivate static readonly Dictionary\u003Cint, IProducer\u003E StaticsContainer = new();\n\n\t/// \u003Csummary\u003E\n\t/// Returns an \u003Csee cref=\u0022IProducer\u0022 /\u003E for the given member and target, or creates one if it doesn\u0027t exist. What\n\t/// kind of producer depends on the attributes that are on the member.\n\t/// \u003C/summary\u003E\n\t/// \u003Cparam name=\u0022memberIdent\u0022\u003EThe unique ID of the member.\u003C/param\u003E\n\t/// \u003Cparam name=\u0022target\u0022\u003EThe object to store the producer object on. This can be null for static members.\u003C/param\u003E\n\t/// \u003Cparam name=\u0022defaultValue\u0022\u003EThe default value to use when creating a producer.\u003C/param\u003E\n\t/// \u003Ctypeparam name=\u0022T\u0022\u003EThe return type of the member.\u003C/typeparam\u003E\n\t/// \u003Ctypeparam name=\u0022TProducer\u0022\u003EThe type to cast the producer to.\u003C/typeparam\u003E\n\t/// \u003Creturns\u003E\n\t/// An \u003Csee cref=\u0022IProducer\u0022 /\u003E that can be used as a backing reactive object for the given member and target.\n\t/// \u003C/returns\u003E\n\t/// \u003Cexception cref=\u0022InvalidOperationException\u0022\u003E\n\t/// Thrown if \u003Cparamref name=\u0022target\u0022 /\u003E is an object that doesn\u0027t implement\n\t/// \u003Csee cref=\u0022IReactivePropertyContainer\u0022 /\u003E.\n\t/// \u003C/exception\u003E\n\tprivate static TProducer GetOrCreateProducer\u003CT, TProducer\u003E(int memberIdent, object? target, T defaultValue)\n\t\twhere TProducer : IProducer\n\t{\n\t\t// find existing producer if possible\n\t\tvar states = target switch\n\t\t{\n\t\t\t// static property\n\t\t\tnull =\u003E StaticsContainer,\n\t\t\t// instance property\n\t\t\tIReactivePropertyContainer container =\u003E container.Producers,\n\t\t\t// instance property that doesnt implement IReactivePropertyContainer; nowhere to put the producer objects\n\t\t\t_ =\u003E throw new InvalidOperationException(\n\t\t\t\t$\u0022Reactive property defined on unsupported type {target.GetType()}\u0022),\n\t\t};\n\n\t\tif (states.TryGetValue(memberIdent, out var state))\n\t\t{\n\t\t\treturn (TProducer)state;\n\t\t}\n\n\t\t// none exists, time to make one\n\t\tif (TypeLibrary.GetMemberByIdent(memberIdent) is not PropertyDescription property)\n\t\t{\n\t\t\tthrow new InvalidOperationException($\u0022Could not find member with identity {memberIdent}\u0022);\n\t\t}\n\n\t\tvar containingType = property.TypeDescription;\n\n\t\tif (property.IsStatic \u0026\u0026 containingType.IsGenericType)\n\t\t{\n\t\t\tthrow new InvalidOperationException(\n\t\t\t\t$\u0022Static reactive properties on generic type {containingType.FullName} are not supported\u0022);\n\t\t}\n\n\t\tIProducer producer;\n\n\t\t// check if we need to create a derived state and wire up the computation method\n\t\tif (property.GetCustomAttribute\u003CDerivedAttribute\u003E() is { ComputeMethod: { } computeMethodName })\n\t\t{\n\t\t\tvar method = target switch\n\t\t\t{\n\t\t\t\tnull =\u003E containingType.GetStaticMethod(computeMethodName),\n\t\t\t\t_ =\u003E containingType.GetMethod(computeMethodName),\n\t\t\t};\n\n\t\t\tif (method == null)\n\t\t\t{\n\t\t\t\tthrow new InvalidOperationException(\n\t\t\t\t\t$\u0022Could not find derived compute method {computeMethodName} on {containingType.Name}.{property.Name}\u0022);\n\t\t\t}\n\n\t\t\tproducer = new Derived\u003CT\u003E(method.CreateDelegate\u003CFunc\u003CT\u003E\u003E(target));\n\t\t\tproducer.SetDebugInfo(location: $\u0022{method.SourceFile}:{method.SourceLine}\u0022);\n\t\t}\n\t\telse\n\t\t{\n\t\t\tproducer = new State\u003CT\u003E(defaultValue);\n\t\t\tproducer.SetDebugInfo(location: $\u0022{property.SourceFile}:{property.SourceLine}\u0022);\n\t\t}\n\n\t\tproducer.SetDebugInfo(property.Name,\n\t\t\tparent: target ?? property.TypeDescription.TargetType,\n\t\t\tcontainer: property);\n\n\t\tstates.Add(memberIdent, producer);\n\t\treturn (TProducer)producer;\n\t}\n\n\t/// \u003Csummary\u003E\n\t/// Returns a value from an object\u0027s backing producer, enabling reactivity.\n\t/// \u003C/summary\u003E\n\t/// \u003Cparam name=\u0022wrapped\u0022\u003EThe original property being accessed.\u003C/param\u003E\n\t/// \u003Ctypeparam name=\u0022T\u0022\u003EThe type of property being accessed.\u003C/typeparam\u003E\n\t/// \u003Creturns\u003EThe value of the backing producer.\u003C/returns\u003E\n\t/// \u003Cexception cref=\u0022InvalidOperationException\u0022\u003E\n\t/// Thrown if the object does not implement \u003Csee cref=\u0022IReactivePropertyContainer\u0022 /\u003E.\n\t/// \u003C/exception\u003E\n#if JETBRAINS_ANNOTATIONS\n\t[UsedImplicitly]\n#endif\n\tpublic static T GetReactiveValue\u003CT\u003E(in WrappedPropertyGet\u003CT\u003E wrapped)\n\t{\n\t\tvar producer = GetOrCreateProducer\u003CT, IProducer\u003CT\u003E\u003E(wrapped.MemberIdent, wrapped.Object, wrapped.Value);\n\t\treturn producer.Value;\n\t}\n\n\t/// \u003Csummary\u003E\n\t/// Sets the value for an object\u0027s backing producer.\n\t/// \u003C/summary\u003E\n\t/// \u003Cparam name=\u0022wrapped\u0022\u003EThe original property being accessed.\u003C/param\u003E\n\t/// \u003Ctypeparam name=\u0022T\u0022\u003EThe type of property being accessed.\u003C/typeparam\u003E\n\t/// \u003Cexception cref=\u0022InvalidOperationException\u0022\u003E\n\t/// Thrown if the object does not implement\n\t/// \u003Csee cref=\u0022IReactivePropertyContainer\u0022 /\u003E\n\t/// \u003C/exception\u003E\n#if JETBRAINS_ANNOTATIONS\n\t[UsedImplicitly]\n#endif\n\tpublic static void SetReactiveValue\u003CT\u003E(in WrappedPropertySet\u003CT\u003E wrapped)\n\t{\n\t\tvar producer = GetOrCreateProducer\u003CT, IWritableProducer\u003CT\u003E\u003E(wrapped.MemberIdent, wrapped.Object, wrapped.Value);\n\t\tproducer.Value = wrapped.Value;\n\t}\n}\n#endif\n"},{"Ident":"igor.reactivity","Path":"Code/Internals/Runtimes/SandboxRuntimeExecutor.cs","FileName":"SandboxRuntimeExecutor.cs","PackageType":"library","CodeKind":"Game","AssetVersionId":302096,"IsPrivate":false,"Code":"#if SANDBOX\n#if JETBRAINS_ANNOTATIONS\nusing JetBrains.Annotations;\n#endif\n\nnamespace Sandbox.Reactivity.Internals.Runtimes;\n\n#if JETBRAINS_ANNOTATIONS\n[UsedImplicitly(ImplicitUseKindFlags.InstantiatedNoFixedConstructorSignature)]\n#endif\ninternal sealed class SandboxRuntimeExecutor : GameObjectSystem\u003CSandboxRuntimeExecutor\u003E\n{\n\t/// \u003Csee cref=\u0022TickStage.Physics\u0022 /\u003E\n\tprivate static readonly List\u003CAction\u003E PhysicsTickFunctions = new(16);\n\n\t/// \u003Csee cref=\u0022TickStage.Start\u0022 /\u003E\n\tprivate static readonly List\u003CAction\u003E StartTickFunctions = new(16);\n\n\t/// \u003Csee cref=\u0022TickStage.End\u0022 /\u003E\n\tprivate static readonly List\u003CAction\u003E EndTickFunctions = new(16);\n\n\t/// \u003Csee cref=\u0022FrameStage.Interpolation\u0022 /\u003E\n\tprivate static readonly List\u003CAction\u003E InterpolationFrameFunctions = new(1);\n\n\t/// \u003Csee cref=\u0022FrameStage.Start\u0022 /\u003E\n\tprivate static readonly List\u003CAction\u003E StartFrameFunctions = new(16);\n\n\t/// \u003Csee cref=\u0022FrameStage.UpdateBones\u0022 /\u003E\n\tprivate static readonly List\u003CAction\u003E UpdateBonesFrameFunctions = new(16);\n\n\t/// \u003Csee cref=\u0022FrameStage.End\u0022 /\u003E\n\tprivate static readonly List\u003CAction\u003E EndFrameFunctions = new(16);\n\n\tpublic SandboxRuntimeExecutor(Scene scene)\n\t\t: base(scene)\n\t{\n\t\tListen(Stage.StartUpdate, 10, StartUpdate, \u0022Reactivity.StartUpdate\u0022);\n\t\tListen(Stage.UpdateBones, 10, UpdateBones, \u0022Reactivity.UpdateBones\u0022);\n\t\tListen(Stage.PhysicsStep, 10, PhysicsStep, \u0022Reactivity.PhysicsStep\u0022);\n\t\tListen(Stage.Interpolation, 10, Interpolate, \u0022Reactivity.Interpolation\u0022);\n\t\tListen(Stage.FinishUpdate, 10, FinishUpdate, \u0022Reactivity.FinishUpdate\u0022);\n\t\tListen(Stage.StartFixedUpdate, 10, StartFixedUpdate, \u0022Reactivity.StartFixedUpdate\u0022);\n\t\tListen(Stage.FinishFixedUpdate, 10, FinishFixedUpdate, \u0022Reactivity.FinishFixedUpdate\u0022);\n\t}\n\n\tprivate static List\u003CAction\u003E GetCallbacks(TickStage tickStage)\n\t{\n\t\treturn tickStage switch\n\t\t{\n\t\t\tTickStage.Physics =\u003E PhysicsTickFunctions,\n\t\t\tTickStage.Start =\u003E StartTickFunctions,\n\t\t\tTickStage.End =\u003E EndTickFunctions,\n\t\t\t_ =\u003E throw new ArgumentOutOfRangeException(),\n\t\t};\n\t}\n\n\tprivate static List\u003CAction\u003E GetCallbacks(FrameStage frameStage)\n\t{\n\t\treturn frameStage switch\n\t\t{\n\t\t\tFrameStage.Interpolation =\u003E InterpolationFrameFunctions,\n\t\t\tFrameStage.Start =\u003E StartFrameFunctions,\n\t\t\tFrameStage.UpdateBones =\u003E UpdateBonesFrameFunctions,\n\t\t\tFrameStage.End =\u003E EndFrameFunctions,\n\t\t\t_ =\u003E throw new ArgumentOutOfRangeException(),\n\t\t};\n\t}\n\n\tpublic static void AddTickFunction(TickStage stage, Action callback)\n\t{\n\t\tvar callbacks = GetCallbacks(stage);\n\n\t\tif (!callbacks.Contains(callback))\n\t\t{\n\t\t\tcallbacks.Add(callback);\n\t\t}\n\t}\n\n\tpublic static void RemoveTickFunction(TickStage stage, Action callback)\n\t{\n\t\tvar callbacks = GetCallbacks(stage);\n\t\tcallbacks.Remove(callback);\n\t}\n\n\tpublic static void AddFrameFunction(FrameStage stage, Action callback)\n\t{\n\t\tvar callbacks = GetCallbacks(stage);\n\n\t\tif (!callbacks.Contains(callback))\n\t\t{\n\t\t\tcallbacks.Add(callback);\n\t\t}\n\t}\n\n\tpublic static void RemoveFrameFunction(FrameStage stage, Action callback)\n\t{\n\t\tvar callbacks = GetCallbacks(stage);\n\t\tcallbacks.Remove(callback);\n\t}\n\n\tprivate static void StartUpdate()\n\t{\n\t\tif (StartFrameFunctions.Count == 0)\n\t\t{\n\t\t\treturn;\n\t\t}\n\n\t\tforeach (var callback in StartFrameFunctions)\n\t\t{\n\t\t\tcallback();\n\t\t}\n\t}\n\n\tprivate static void UpdateBones()\n\t{\n\t\tif (UpdateBonesFrameFunctions.Count == 0)\n\t\t{\n\t\t\treturn;\n\t\t}\n\n\t\tforeach (var callback in UpdateBonesFrameFunctions)\n\t\t{\n\t\t\tcallback();\n\t\t}\n\t}\n\n\tprivate static void PhysicsStep()\n\t{\n\t\tif (PhysicsTickFunctions.Count == 0)\n\t\t{\n\t\t\treturn;\n\t\t}\n\n\t\tforeach (var callback in PhysicsTickFunctions)\n\t\t{\n\t\t\tcallback();\n\t\t}\n\t}\n\n\tprivate static void Interpolate()\n\t{\n\t\tif (InterpolationFrameFunctions.Count == 0)\n\t\t{\n\t\t\treturn;\n\t\t}\n\n\t\tforeach (var callback in InterpolationFrameFunctions)\n\t\t{\n\t\t\tcallback();\n\t\t}\n\t}\n\n\tprivate static void FinishUpdate()\n\t{\n\t\tif (EndFrameFunctions.Count \u003E 0)\n\t\t{\n\t\t\tforeach (var callback in EndFrameFunctions)\n\t\t\t{\n\t\t\t\tcallback();\n\t\t\t}\n\t\t}\n\n\t\tif (Reactive.Runtime.IsFlushScheduled)\n\t\t{\n\t\t\tReactive.Runtime.Flush();\n\t\t}\n\t}\n\n\tprivate static void StartFixedUpdate()\n\t{\n\t\tif (StartTickFunctions.Count == 0)\n\t\t{\n\t\t\treturn;\n\t\t}\n\n\t\tforeach (var callback in StartTickFunctions)\n\t\t{\n\t\t\tcallback();\n\t\t}\n\t}\n\n\tprivate static void FinishFixedUpdate()\n\t{\n\t\tif (EndTickFunctions.Count == 0)\n\t\t{\n\t\t\treturn;\n\t\t}\n\n\t\tforeach (var callback in EndTickFunctions)\n\t\t{\n\t\t\tcallback();\n\t\t}\n\t}\n}\n#endif\n"},{"Ident":"igor.reactivity","Path":"FrameStage.cs","FileName":"FrameStage.cs","PackageType":"library","CodeKind":"Game","AssetVersionId":302096,"IsPrivate":false,"Code":"namespace Sandbox.Reactivity;\n\n/// \u003Csummary\u003E\n/// Describes at what point during a frame a function should run.\n/// \u003C/summary\u003E\npublic enum FrameStage\n{\n\t/// \u003Csummary\u003E\n\t/// While transforms are being interpolated.\n\t/// \u003C/summary\u003E\n\tInterpolation,\n\n\t/// \u003Csummary\u003E\n\t/// At the start of the frame, after interpolation.\n\t/// \u003C/summary\u003E\n\tStart,\n\n\t/// \u003Csummary\u003E\n\t/// While bones are being updated.\n\t/// \u003C/summary\u003E\n\tUpdateBones,\n\n\t/// \u003Csummary\u003E\n\t/// At the end of the frame.\n\t/// \u003C/summary\u003E\n\tEnd,\n}\n"},{"Ident":"igor.reactivity","Path":"Internals/IReactiveObject.cs","FileName":"IReactiveObject.cs","PackageType":"library","CodeKind":"Game","AssetVersionId":302096,"IsPrivate":false,"Code":"using System.Diagnostics;\n\nnamespace Sandbox.Reactivity.Internals;\n\ninternal interface IReactiveObject\n{\n#if DEBUG \u0026\u0026 SANDBOX\n#endif\n}\n\ninternal static class ReactiveObjectExtensions\n{\n\textension(IReactiveObject reactive)\n\t{\n\t\t[Conditional(\u0022DEBUG\u0022)]\n\t\tpublic void SetDebugInfo(\n\t\t\tstring? name = null,\n\t\t\tstring? icon = null,\n\t\t\tstring? location = null,\n\t\t\tobject? parent = null,\n#if SANDBOX\n\t\t\tPropertyDescription? container = null\n#else\n#endif\n\t\t)\n\t\t{\n#if DEBUG \u0026\u0026 SANDBOX\n#endif\n\t\t}\n\t}\n}\n"},{"Ident":"igor.reactivity","Path":"Internals/IReactivePanel.cs","FileName":"IReactivePanel.cs","PackageType":"library","CodeKind":"Game","AssetVersionId":302096,"IsPrivate":false,"Code":"#if SANDBOX\nnamespace Sandbox.Reactivity.Internals;\n\n/// \u003Csummary\u003E\n/// A panel that creates an effect root every time it builds its render tree.\n/// \u003C/summary\u003E\ninternal interface IReactivePanel\n{\n\t/// \u003Csummary\u003E\n\t/// The current effect root created during rendering.\n\t/// \u003C/summary\u003E\n\tEffect? RenderEffectRoot { get; set; }\n\n\t/// \u003Csummary\u003E\n\t/// A monotonically increasing counter that\u0027s incremented when a panel\u0027s dependencies have changed and needs to\n\t/// rebuild its render tree.\n\t/// \u003C/summary\u003E\n\tint Version { get; set; }\n}\n#endif\n"},{"Ident":"igor.reactivity","Path":"Internals/ReactionState.cs","FileName":"ReactionState.cs","PackageType":"library","CodeKind":"Game","AssetVersionId":302096,"IsPrivate":false,"Code":"namespace Sandbox.Reactivity.Internals;\n\ninternal enum ReactionState\n{\n\t/// \u003Csummary\u003E\n\t/// This reaction was manually scheduled to run, or a direct dependency of this reaction has changed its value\n\t/// and needs to re-run.\n\t/// \u003C/summary\u003E\n\tStale,\n\n\t/// \u003Csummary\u003E\n\t/// This reaction can\u0027t definitively determine whether it\u0027s stale. Either this reaction is not monitoring changes to\n\t/// dependencies for optimization, or because an ancestor dependency has propagated a change and the direct\n\t/// dependencies need to be checked to see if they\u0027ve actually changed.\n\t/// \u003C/summary\u003E\n\tPossiblyStale,\n\n\t/// \u003Csummary\u003E\n\t/// All dependencies for this reaction have not changed since the last time it ran.\n\t/// \u003C/summary\u003E\n\tUpToDate,\n}\n"},{"Ident":"igor.reactivity","Path":"Internals/Runtimes/InfiniteLoopException.cs","FileName":"InfiniteLoopException.cs","PackageType":"library","CodeKind":"Game","AssetVersionId":302096,"IsPrivate":false,"Code":"namespace Sandbox.Reactivity.Internals.Runtimes;\n\ninternal class InfiniteLoopException(Dictionary\u003CEffect, int\u003E? effectExecutions = null) : Exception(Message)\n{\n\tprivate new const string Message = \u0022An infinite loop occurred while flushing effects\u0022;\n\n#if DEBUG\n#endif\n}\n"}]}