Implement service locator

This commit is contained in:
Raymond 2021-08-20 11:59:35 -04:00
parent 06b1163a52
commit ff1d7f2829
101 changed files with 1614 additions and 1436 deletions

View file

@ -27,9 +27,9 @@ namespace Dalamud.Game.Text.SeStringHandling
private byte[] encodedData;
/// <summary>
/// Gets or sets the Lumina instance to use for any necessary data lookups.
/// Gets the Lumina instance to use for any necessary data lookups.
/// </summary>
public DataManager DataResolver { get; set; }
public DataManager DataResolver => Service<DataManager>.Get();
/// <summary>
/// Gets the type of this payload.
@ -45,9 +45,8 @@ namespace Dalamud.Game.Text.SeStringHandling
/// Decodes a binary representation of a payload into its corresponding nice object payload.
/// </summary>
/// <param name="reader">A reader positioned at the start of the payload, and containing at least one entire payload.</param>
/// <param name="data">The DataManager instance.</param>
/// <returns>The constructed Payload-derived object that was decoded from the binary data.</returns>
public static Payload Decode(BinaryReader reader, DataManager data)
public static Payload Decode(BinaryReader reader)
{
var payloadStartPos = reader.BaseStream.Position;
@ -64,8 +63,6 @@ namespace Dalamud.Game.Text.SeStringHandling
payload = DecodeChunk(reader);
}
payload.DataResolver = data;
// for now, cache off the actual binary data for this payload, so we don't have to
// regenerate it if the payload isn't modified
// TODO: probably better ways to handle this