diff --git a/Dalamud/Game/Addon/Lifecycle/AddonArgTypes/AddonArgs.cs b/Dalamud/Game/Addon/Lifecycle/AddonArgTypes/AddonArgs.cs
index 077ca7c93..d82bf29a9 100644
--- a/Dalamud/Game/Addon/Lifecycle/AddonArgTypes/AddonArgs.cs
+++ b/Dalamud/Game/Addon/Lifecycle/AddonArgTypes/AddonArgs.cs
@@ -1,4 +1,5 @@
using Dalamud.Memory;
+
using FFXIVClientStructs.FFXIV.Component.GUI;
namespace Dalamud.Game.Addon.Lifecycle.AddonArgTypes;
@@ -12,7 +13,7 @@ public abstract unsafe class AddonArgs
/// Constant string representing the name of an addon that is invalid.
///
public const string InvalidAddon = "NullAddon";
-
+
private string? addonName;
private IntPtr addon;
@@ -26,8 +27,22 @@ public abstract unsafe class AddonArgs
///
public nint Addon
{
- get => this.addon;
- internal set
+ get => this.AddonInternal;
+ init => this.AddonInternal = value;
+ }
+
+ ///
+ /// Gets the type of these args.
+ ///
+ public abstract AddonArgsType Type { get; }
+
+ ///
+ /// Gets or sets the pointer to the addons AtkUnitBase.
+ ///
+ internal nint AddonInternal
+ {
+ get => this.Addon;
+ set
{
if (this.addon == value)
return;
@@ -37,11 +52,6 @@ public abstract unsafe class AddonArgs
}
}
- ///
- /// Gets the type of these args.
- ///
- public abstract AddonArgsType Type { get; }
-
///
/// Checks if addon name matches the given span of char.
///
@@ -55,7 +65,7 @@ public abstract unsafe class AddonArgs
var addonPointer = (AtkUnitBase*)this.Addon;
if (addonPointer->Name is null) return false;
-
+
return MemoryHelper.EqualsZeroTerminatedString(name, (nint)addonPointer->Name, null, 0x20);
}
diff --git a/Dalamud/Game/Addon/Lifecycle/AddonArgTypes/AddonDrawArgs.cs b/Dalamud/Game/Addon/Lifecycle/AddonArgTypes/AddonDrawArgs.cs
index 1e1013dd5..989e11912 100644
--- a/Dalamud/Game/Addon/Lifecycle/AddonArgTypes/AddonDrawArgs.cs
+++ b/Dalamud/Game/Addon/Lifecycle/AddonArgTypes/AddonDrawArgs.cs
@@ -5,12 +5,20 @@
///
public class AddonDrawArgs : AddonArgs, ICloneable
{
+ ///
+ /// Initializes a new instance of the class.
+ ///
+ [Obsolete("Not intended for public construction.", false)]
+ public AddonDrawArgs()
+ {
+ }
+
///
public override AddonArgsType Type => AddonArgsType.Draw;
///
public AddonDrawArgs Clone() => (AddonDrawArgs)this.MemberwiseClone();
-
+
///
object ICloneable.Clone() => this.Clone();
}
diff --git a/Dalamud/Game/Addon/Lifecycle/AddonArgTypes/AddonFinalizeArgs.cs b/Dalamud/Game/Addon/Lifecycle/AddonArgTypes/AddonFinalizeArgs.cs
index fc26a6c33..d9401b414 100644
--- a/Dalamud/Game/Addon/Lifecycle/AddonArgTypes/AddonFinalizeArgs.cs
+++ b/Dalamud/Game/Addon/Lifecycle/AddonArgTypes/AddonFinalizeArgs.cs
@@ -5,12 +5,20 @@ namespace Dalamud.Game.Addon.Lifecycle.AddonArgTypes;
///
public class AddonFinalizeArgs : AddonArgs, ICloneable
{
+ ///
+ /// Initializes a new instance of the class.
+ ///
+ [Obsolete("Not intended for public construction.", false)]
+ public AddonFinalizeArgs()
+ {
+ }
+
///
public override AddonArgsType Type => AddonArgsType.Finalize;
///
public AddonFinalizeArgs Clone() => (AddonFinalizeArgs)this.MemberwiseClone();
-
+
///
object ICloneable.Clone() => this.Clone();
}
diff --git a/Dalamud/Game/Addon/Lifecycle/AddonArgTypes/AddonReceiveEventArgs.cs b/Dalamud/Game/Addon/Lifecycle/AddonArgTypes/AddonReceiveEventArgs.cs
index 8f9003b4c..a557b0cb3 100644
--- a/Dalamud/Game/Addon/Lifecycle/AddonArgTypes/AddonReceiveEventArgs.cs
+++ b/Dalamud/Game/Addon/Lifecycle/AddonArgTypes/AddonReceiveEventArgs.cs
@@ -5,24 +5,32 @@ namespace Dalamud.Game.Addon.Lifecycle.AddonArgTypes;
///
public class AddonReceiveEventArgs : AddonArgs, ICloneable
{
+ ///
+ /// Initializes a new instance of the class.
+ ///
+ [Obsolete("Not intended for public construction.", false)]
+ public AddonReceiveEventArgs()
+ {
+ }
+
///
public override AddonArgsType Type => AddonArgsType.ReceiveEvent;
-
+
///
/// Gets or sets the AtkEventType for this event message.
///
public byte AtkEventType { get; set; }
-
+
///
/// Gets or sets the event id for this event message.
///
public int EventParam { get; set; }
-
+
///
/// Gets or sets the pointer to an AtkEvent for this event message.
///
public nint AtkEvent { get; set; }
-
+
///
/// Gets or sets the pointer to a block of data for this event message.
///
@@ -30,7 +38,7 @@ public class AddonReceiveEventArgs : AddonArgs, ICloneable
///
public AddonReceiveEventArgs Clone() => (AddonReceiveEventArgs)this.MemberwiseClone();
-
+
///
object ICloneable.Clone() => this.Clone();
}
diff --git a/Dalamud/Game/Addon/Lifecycle/AddonArgTypes/AddonRefreshArgs.cs b/Dalamud/Game/Addon/Lifecycle/AddonArgTypes/AddonRefreshArgs.cs
index bfcf02544..6e1b11ead 100644
--- a/Dalamud/Game/Addon/Lifecycle/AddonArgTypes/AddonRefreshArgs.cs
+++ b/Dalamud/Game/Addon/Lifecycle/AddonArgTypes/AddonRefreshArgs.cs
@@ -7,19 +7,27 @@ namespace Dalamud.Game.Addon.Lifecycle.AddonArgTypes;
///
public class AddonRefreshArgs : AddonArgs, ICloneable
{
+ ///
+ /// Initializes a new instance of the class.
+ ///
+ [Obsolete("Not intended for public construction.", false)]
+ public AddonRefreshArgs()
+ {
+ }
+
///
public override AddonArgsType Type => AddonArgsType.Refresh;
-
+
///
/// Gets or sets the number of AtkValues.
///
public uint AtkValueCount { get; set; }
-
+
///
/// Gets or sets the address of the AtkValue array.
///
public nint AtkValues { get; set; }
-
+
///
/// Gets the AtkValues in the form of a span.
///
@@ -27,7 +35,7 @@ public class AddonRefreshArgs : AddonArgs, ICloneable
///
public AddonRefreshArgs Clone() => (AddonRefreshArgs)this.MemberwiseClone();
-
+
///
object ICloneable.Clone() => this.Clone();
}
diff --git a/Dalamud/Game/Addon/Lifecycle/AddonArgTypes/AddonRequestedUpdateArgs.cs b/Dalamud/Game/Addon/Lifecycle/AddonArgTypes/AddonRequestedUpdateArgs.cs
index 219288ccf..26357abb0 100644
--- a/Dalamud/Game/Addon/Lifecycle/AddonArgTypes/AddonRequestedUpdateArgs.cs
+++ b/Dalamud/Game/Addon/Lifecycle/AddonArgTypes/AddonRequestedUpdateArgs.cs
@@ -5,14 +5,22 @@
///
public class AddonRequestedUpdateArgs : AddonArgs, ICloneable
{
+ ///
+ /// Initializes a new instance of the class.
+ ///
+ [Obsolete("Not intended for public construction.", false)]
+ public AddonRequestedUpdateArgs()
+ {
+ }
+
///
public override AddonArgsType Type => AddonArgsType.RequestedUpdate;
-
+
///
/// Gets or sets the NumberArrayData** for this event.
///
public nint NumberArrayData { get; set; }
-
+
///
/// Gets or sets the StringArrayData** for this event.
///
@@ -20,7 +28,7 @@ public class AddonRequestedUpdateArgs : AddonArgs, ICloneable
///
public AddonRequestedUpdateArgs Clone() => (AddonRequestedUpdateArgs)this.MemberwiseClone();
-
+
///
object ICloneable.Clone() => this.Clone();
}
diff --git a/Dalamud/Game/Addon/Lifecycle/AddonArgTypes/AddonSetupArgs.cs b/Dalamud/Game/Addon/Lifecycle/AddonArgTypes/AddonSetupArgs.cs
index bd60879b8..19c93ce25 100644
--- a/Dalamud/Game/Addon/Lifecycle/AddonArgTypes/AddonSetupArgs.cs
+++ b/Dalamud/Game/Addon/Lifecycle/AddonArgTypes/AddonSetupArgs.cs
@@ -7,19 +7,27 @@ namespace Dalamud.Game.Addon.Lifecycle.AddonArgTypes;
///
public class AddonSetupArgs : AddonArgs, ICloneable
{
+ ///
+ /// Initializes a new instance of the class.
+ ///
+ [Obsolete("Not intended for public construction.", false)]
+ public AddonSetupArgs()
+ {
+ }
+
///
public override AddonArgsType Type => AddonArgsType.Setup;
-
+
///
/// Gets or sets the number of AtkValues.
///
public uint AtkValueCount { get; set; }
-
+
///
/// Gets or sets the address of the AtkValue array.
///
public nint AtkValues { get; set; }
-
+
///
/// Gets the AtkValues in the form of a span.
///
@@ -27,7 +35,7 @@ public class AddonSetupArgs : AddonArgs, ICloneable
///
public AddonSetupArgs Clone() => (AddonSetupArgs)this.MemberwiseClone();
-
+
///
object ICloneable.Clone() => this.Clone();
}
diff --git a/Dalamud/Game/Addon/Lifecycle/AddonArgTypes/AddonUpdateArgs.cs b/Dalamud/Game/Addon/Lifecycle/AddonArgTypes/AddonUpdateArgs.cs
index b087ac15a..cc34a7531 100644
--- a/Dalamud/Game/Addon/Lifecycle/AddonArgTypes/AddonUpdateArgs.cs
+++ b/Dalamud/Game/Addon/Lifecycle/AddonArgTypes/AddonUpdateArgs.cs
@@ -5,17 +5,34 @@ namespace Dalamud.Game.Addon.Lifecycle.AddonArgTypes;
///
public class AddonUpdateArgs : AddonArgs, ICloneable
{
+ ///
+ /// Initializes a new instance of the class.
+ ///
+ [Obsolete("Not intended for public construction.", false)]
+ public AddonUpdateArgs()
+ {
+ }
+
///
public override AddonArgsType Type => AddonArgsType.Update;
-
+
///
/// Gets the time since the last update.
///
- public float TimeDelta { get; internal set; }
+ public float TimeDelta
+ {
+ get => this.TimeDeltaInternal;
+ init => this.TimeDeltaInternal = value;
+ }
+
+ ///
+ /// Gets or sets the time since the last update.
+ ///
+ internal float TimeDeltaInternal { get; set; }
///
public AddonUpdateArgs Clone() => (AddonUpdateArgs)this.MemberwiseClone();
-
+
///
object ICloneable.Clone() => this.Clone();
}
diff --git a/Dalamud/Game/Addon/Lifecycle/AddonLifecycle.cs b/Dalamud/Game/Addon/Lifecycle/AddonLifecycle.cs
index decb7a9f4..6288cd2cd 100644
--- a/Dalamud/Game/Addon/Lifecycle/AddonLifecycle.cs
+++ b/Dalamud/Game/Addon/Lifecycle/AddonLifecycle.cs
@@ -43,12 +43,15 @@ internal unsafe class AddonLifecycle : IDisposable, IServiceType
// Note: these can be sourced from ObjectPool of appropriate types instead, but since we don't import that NuGet
// package, and these events are always called from the main thread, this is fine.
+#pragma warning disable CS0618 // Type or member is obsolete
+ // TODO: turn constructors of these internal
private readonly AddonSetupArgs recyclingSetupArgs = new();
private readonly AddonFinalizeArgs recyclingFinalizeArgs = new();
private readonly AddonDrawArgs recyclingDrawArgs = new();
private readonly AddonUpdateArgs recyclingUpdateArgs = new();
private readonly AddonRefreshArgs recyclingRefreshArgs = new();
private readonly AddonRequestedUpdateArgs recyclingRequestedUpdateArgs = new();
+#pragma warning restore CS0618 // Type or member is obsolete
[ServiceManager.ServiceConstructor]
private AddonLifecycle(TargetSigScanner sigScanner)
@@ -275,7 +278,7 @@ internal unsafe class AddonLifecycle : IDisposable, IServiceType
Log.Error(e, "Exception in OnAddonSetup ReceiveEvent Registration.");
}
- this.recyclingSetupArgs.Addon = (nint)addon;
+ this.recyclingSetupArgs.AddonInternal = (nint)addon;
this.recyclingSetupArgs.AtkValueCount = valueCount;
this.recyclingSetupArgs.AtkValues = (nint)values;
this.InvokeListenersSafely(AddonEvent.PreSetup, this.recyclingSetupArgs);
@@ -306,7 +309,7 @@ internal unsafe class AddonLifecycle : IDisposable, IServiceType
Log.Error(e, "Exception in OnAddonFinalize ReceiveEvent Removal.");
}
- this.recyclingFinalizeArgs.Addon = (nint)atkUnitBase[0];
+ this.recyclingFinalizeArgs.AddonInternal = (nint)atkUnitBase[0];
this.InvokeListenersSafely(AddonEvent.PreFinalize, this.recyclingFinalizeArgs);
try
@@ -321,7 +324,7 @@ internal unsafe class AddonLifecycle : IDisposable, IServiceType
private void OnAddonDraw(AtkUnitBase* addon)
{
- this.recyclingDrawArgs.Addon = (nint)addon;
+ this.recyclingDrawArgs.AddonInternal = (nint)addon;
this.InvokeListenersSafely(AddonEvent.PreDraw, this.recyclingDrawArgs);
try
@@ -338,8 +341,8 @@ internal unsafe class AddonLifecycle : IDisposable, IServiceType
private void OnAddonUpdate(AtkUnitBase* addon, float delta)
{
- this.recyclingUpdateArgs.Addon = (nint)addon;
- this.recyclingUpdateArgs.TimeDelta = delta;
+ this.recyclingUpdateArgs.AddonInternal = (nint)addon;
+ this.recyclingUpdateArgs.TimeDeltaInternal = delta;
this.InvokeListenersSafely(AddonEvent.PreUpdate, this.recyclingUpdateArgs);
try
@@ -358,7 +361,7 @@ internal unsafe class AddonLifecycle : IDisposable, IServiceType
{
byte result = 0;
- this.recyclingRefreshArgs.Addon = (nint)addon;
+ this.recyclingRefreshArgs.AddonInternal = (nint)addon;
this.recyclingRefreshArgs.AtkValueCount = valueCount;
this.recyclingRefreshArgs.AtkValues = (nint)values;
this.InvokeListenersSafely(AddonEvent.PreRefresh, this.recyclingRefreshArgs);
@@ -380,7 +383,7 @@ internal unsafe class AddonLifecycle : IDisposable, IServiceType
private void OnRequestedUpdate(AtkUnitBase* addon, NumberArrayData** numberArrayData, StringArrayData** stringArrayData)
{
- this.recyclingRequestedUpdateArgs.Addon = (nint)addon;
+ this.recyclingRequestedUpdateArgs.AddonInternal = (nint)addon;
this.recyclingRequestedUpdateArgs.NumberArrayData = (nint)numberArrayData;
this.recyclingRequestedUpdateArgs.StringArrayData = (nint)stringArrayData;
this.InvokeListenersSafely(AddonEvent.PreRequestedUpdate, this.recyclingRequestedUpdateArgs);
diff --git a/Dalamud/Game/Addon/Lifecycle/AddonLifecycleReceiveEventListener.cs b/Dalamud/Game/Addon/Lifecycle/AddonLifecycleReceiveEventListener.cs
index 1c138e447..43aa71661 100644
--- a/Dalamud/Game/Addon/Lifecycle/AddonLifecycleReceiveEventListener.cs
+++ b/Dalamud/Game/Addon/Lifecycle/AddonLifecycleReceiveEventListener.cs
@@ -18,7 +18,10 @@ internal unsafe class AddonLifecycleReceiveEventListener : IDisposable
// Note: these can be sourced from ObjectPool of appropriate types instead, but since we don't import that NuGet
// package, and these events are always called from the main thread, this is fine.
+#pragma warning disable CS0618 // Type or member is obsolete
+ // TODO: turn constructors of these internal
private readonly AddonReceiveEventArgs recyclingReceiveEventArgs = new();
+#pragma warning restore CS0618 // Type or member is obsolete
///
/// Initializes a new instance of the class.
@@ -79,7 +82,7 @@ internal unsafe class AddonLifecycleReceiveEventListener : IDisposable
return;
}
- this.recyclingReceiveEventArgs.Addon = (nint)addon;
+ this.recyclingReceiveEventArgs.AddonInternal = (nint)addon;
this.recyclingReceiveEventArgs.AtkEventType = (byte)eventType;
this.recyclingReceiveEventArgs.EventParam = eventParam;
this.recyclingReceiveEventArgs.AtkEvent = (IntPtr)atkEvent;