mono/il2cpp config

This commit is contained in:
Gurge44 committed 2026-09-24 20:26:16 +02:00
1 parent e16d9119d1
commit 65281aeebc
59 files changed
+773 -146

No files matched your search

+20 -19
View File
@@ -14,21 +14,25 @@ namespace EHR.Modules;
/// <typeparam name="T">The type of the parent class that owns the state machine.</typeparam>
public class StateMachineWrapper<T> : CompilerGeneratedObjectWrapper
{
#if IL2CPP
// normally it is fields, but IL2CPP turns them into properties
private readonly PropertyInfo _thisProperty;
private readonly PropertyInfo _stateProperty;
#else
private readonly FieldInfo _stateField;
private readonly FieldInfo _thisField;
private readonly bool _mono;
#endif
private T? _parentInstance;
/// <summary>
/// Gets the instance of the parent class that owns the state machine.
/// </summary>
public T Instance => _parentInstance ??= (T) (_mono ? _thisField.GetValue(GeneratedObject)! : _thisProperty.GetValue(GeneratedObject)!);
#if IL2CPP
public T Instance => _parentInstance ??= (T) (_thisProperty.GetValue(GeneratedObject)!);
#else
public T Instance => _parentInstance ??= (T) (_thisField.GetValue(GeneratedObject)!);
#endif
/// <summary>
/// Gets or sets the current state of the state machine.
@@ -36,14 +40,13 @@ public class StateMachineWrapper<T> : CompilerGeneratedObjectWrapper
/// <returns>The current state as an integer.</returns>
public int State
{
get => _mono ? (int) _stateField.GetValue(GeneratedObject)! : (int) _stateProperty.GetValue(GeneratedObject)!;
set
{
if (_mono)
_stateField.SetValue(GeneratedObject, value);
else
_stateProperty.SetValue(GeneratedObject, value);
}
#if IL2CPP
get => (int) _stateProperty.GetValue(GeneratedObject)!;
set => _stateProperty.SetValue(GeneratedObject, value);
#else
get => (int) _stateField.GetValue(GeneratedObject)!;
set => _stateField.SetValue(GeneratedObject, value);
#endif
}
/// <summary>
@@ -52,15 +55,13 @@ public class StateMachineWrapper<T> : CompilerGeneratedObjectWrapper
/// <param name="stateMachine">The state machine instance to wrap.</param>
public StateMachineWrapper(object stateMachine) : base(stateMachine)
{
#if IL2CPP
_thisProperty = AccessTools.Property(GeneratedType, "__4__this");
_stateProperty = AccessTools.Property(GeneratedType, "__1__state");
if (_thisProperty == null || _stateProperty == null)
{
_mono = true;
_thisField = AccessTools.Field(GeneratedType, "<>4__this");
_stateField = AccessTools.Field(GeneratedType, "<>1__state");
}
#else
_thisField = AccessTools.Field(GeneratedType, "<>4__this");
_stateField = AccessTools.Field(GeneratedType, "<>1__state");
#endif
}
/// <summary>