fix a million warnings

This commit is contained in:
goat 2024-06-30 00:58:04 +02:00
parent b752d958f7
commit b425bb3e49
26 changed files with 1027 additions and 1019 deletions

View file

@ -7,135 +7,6 @@ using Dalamud.Memory;
namespace Dalamud.Game.ClientState.Fates;
/// <summary>
/// This class represents an FFXIV Fate.
/// </summary>
internal unsafe partial class Fate
{
/// <summary>
/// Initializes a new instance of the <see cref="Fate"/> class.
/// </summary>
/// <param name="address">The address of this fate in memory.</param>
internal Fate(IntPtr address)
{
this.Address = address;
}
/// <inheritdoc />
public IntPtr Address { get; }
private FFXIVClientStructs.FFXIV.Client.Game.Fate.FateContext* Struct => (FFXIVClientStructs.FFXIV.Client.Game.Fate.FateContext*)this.Address;
public static bool operator ==(Fate fate1, Fate fate2)
{
if (fate1 is null || fate2 is null)
return Equals(fate1, fate2);
return fate1.Equals(fate2);
}
public static bool operator !=(Fate fate1, Fate fate2) => !(fate1 == fate2);
/// <summary>
/// Gets a value indicating whether this Fate is still valid in memory.
/// </summary>
/// <param name="fate">The fate to check.</param>
/// <returns>True or false.</returns>
public static bool IsValid(Fate fate)
{
var clientState = Service<ClientState>.GetNullable();
if (fate == null || clientState == null)
return false;
if (clientState.LocalContentId == 0)
return false;
return true;
}
/// <summary>
/// Gets a value indicating whether this actor is still valid in memory.
/// </summary>
/// <returns>True or false.</returns>
public bool IsValid() => IsValid(this);
/// <inheritdoc/>
bool IEquatable<IFate>.Equals(IFate other) => this.FateId == other?.FateId;
/// <inheritdoc/>
public override bool Equals(object obj) => ((IEquatable<IFate>)this).Equals(obj as IFate);
/// <inheritdoc/>
public override int GetHashCode() => this.FateId.GetHashCode();
}
/// <summary>
/// This class represents an FFXIV Fate.
/// </summary>
internal unsafe partial class Fate : IFate
{
/// <inheritdoc/>
public ushort FateId => this.Struct->FateId;
/// <inheritdoc/>
public Lumina.Excel.GeneratedSheets.Fate GameData => Service<DataManager>.Get().GetExcelSheet<Lumina.Excel.GeneratedSheets.Fate>().GetRow(this.FateId);
/// <inheritdoc/>
public int StartTimeEpoch => this.Struct->StartTimeEpoch;
/// <inheritdoc/>
public short Duration => this.Struct->Duration;
/// <inheritdoc/>
public long TimeRemaining => this.StartTimeEpoch + this.Duration - DateTimeOffset.Now.ToUnixTimeSeconds();
/// <inheritdoc/>
public SeString Name => MemoryHelper.ReadSeString(&this.Struct->Name);
/// <inheritdoc/>
public SeString Description => MemoryHelper.ReadSeString(&this.Struct->Description);
/// <inheritdoc/>
public SeString Objective => MemoryHelper.ReadSeString(&this.Struct->Objective);
/// <inheritdoc/>
public FateState State => (FateState)this.Struct->State;
/// <inheritdoc/>
public byte HandInCount => this.Struct->HandInCount;
/// <inheritdoc/>
public byte Progress => this.Struct->Progress;
/// <inheritdoc/>
public bool HasExpBonus => this.Struct->IsExpBonus;
/// <inheritdoc/>
public uint IconId => this.Struct->IconId;
/// <inheritdoc/>
public byte Level => this.Struct->Level;
/// <inheritdoc/>
public byte MaxLevel => this.Struct->MaxLevel;
/// <inheritdoc/>
public Vector3 Position => this.Struct->Location;
/// <inheritdoc/>
public float Radius => this.Struct->Radius;
/// <inheritdoc/>
public uint MapIconId => this.Struct->MapIconId;
/// <summary>
/// Gets the territory this <see cref="Fate"/> is located in.
/// </summary>
public ExcelResolver<Lumina.Excel.GeneratedSheets.TerritoryType> TerritoryType => new(this.Struct->TerritoryId);
}
/// <summary>
/// Interface representing an fate entry that can be seen in the current area.
/// </summary>
@ -241,3 +112,131 @@ public interface IFate : IEquatable<IFate>
/// </summary>
IntPtr Address { get; }
}
/// <summary>
/// This class represents an FFXIV Fate.
/// </summary>
internal unsafe partial class Fate
{
/// <summary>
/// Initializes a new instance of the <see cref="Fate"/> class.
/// </summary>
/// <param name="address">The address of this fate in memory.</param>
internal Fate(IntPtr address)
{
this.Address = address;
}
/// <inheritdoc />
public IntPtr Address { get; }
private FFXIVClientStructs.FFXIV.Client.Game.Fate.FateContext* Struct => (FFXIVClientStructs.FFXIV.Client.Game.Fate.FateContext*)this.Address;
public static bool operator ==(Fate fate1, Fate fate2)
{
if (fate1 is null || fate2 is null)
return Equals(fate1, fate2);
return fate1.Equals(fate2);
}
public static bool operator !=(Fate fate1, Fate fate2) => !(fate1 == fate2);
/// <summary>
/// Gets a value indicating whether this Fate is still valid in memory.
/// </summary>
/// <param name="fate">The fate to check.</param>
/// <returns>True or false.</returns>
public static bool IsValid(Fate fate)
{
var clientState = Service<ClientState>.GetNullable();
if (fate == null || clientState == null)
return false;
if (clientState.LocalContentId == 0)
return false;
return true;
}
/// <summary>
/// Gets a value indicating whether this actor is still valid in memory.
/// </summary>
/// <returns>True or false.</returns>
public bool IsValid() => IsValid(this);
/// <inheritdoc/>
bool IEquatable<IFate>.Equals(IFate other) => this.FateId == other?.FateId;
/// <inheritdoc/>
public override bool Equals(object obj) => ((IEquatable<IFate>)this).Equals(obj as IFate);
/// <inheritdoc/>
public override int GetHashCode() => this.FateId.GetHashCode();
}
/// <summary>
/// This class represents an FFXIV Fate.
/// </summary>
internal unsafe partial class Fate : IFate
{
/// <inheritdoc/>
public ushort FateId => this.Struct->FateId;
/// <inheritdoc/>
public Lumina.Excel.GeneratedSheets.Fate GameData => Service<DataManager>.Get().GetExcelSheet<Lumina.Excel.GeneratedSheets.Fate>().GetRow(this.FateId);
/// <inheritdoc/>
public int StartTimeEpoch => this.Struct->StartTimeEpoch;
/// <inheritdoc/>
public short Duration => this.Struct->Duration;
/// <inheritdoc/>
public long TimeRemaining => this.StartTimeEpoch + this.Duration - DateTimeOffset.Now.ToUnixTimeSeconds();
/// <inheritdoc/>
public SeString Name => MemoryHelper.ReadSeString(&this.Struct->Name);
/// <inheritdoc/>
public SeString Description => MemoryHelper.ReadSeString(&this.Struct->Description);
/// <inheritdoc/>
public SeString Objective => MemoryHelper.ReadSeString(&this.Struct->Objective);
/// <inheritdoc/>
public FateState State => (FateState)this.Struct->State;
/// <inheritdoc/>
public byte HandInCount => this.Struct->HandInCount;
/// <inheritdoc/>
public byte Progress => this.Struct->Progress;
/// <inheritdoc/>
public bool HasExpBonus => this.Struct->IsExpBonus;
/// <inheritdoc/>
public uint IconId => this.Struct->IconId;
/// <inheritdoc/>
public byte Level => this.Struct->Level;
/// <inheritdoc/>
public byte MaxLevel => this.Struct->MaxLevel;
/// <inheritdoc/>
public Vector3 Position => this.Struct->Location;
/// <inheritdoc/>
public float Radius => this.Struct->Radius;
/// <inheritdoc/>
public uint MapIconId => this.Struct->MapIconId;
/// <summary>
/// Gets the territory this <see cref="Fate"/> is located in.
/// </summary>
public ExcelResolver<Lumina.Excel.GeneratedSheets.TerritoryType> TerritoryType => new(this.Struct->TerritoryId);
}