added items
This commit is contained in:
parent
c3de5fdb63
commit
5f90bc137b
158 changed files with 2316 additions and 512 deletions
76
src/Automata.Memory/TerrainOffsets.cs
Normal file
76
src/Automata.Memory/TerrainOffsets.cs
Normal file
|
|
@ -0,0 +1,76 @@
|
|||
using System.Text.Json;
|
||||
using System.Text.Json.Serialization;
|
||||
using Serilog;
|
||||
|
||||
namespace Automata.Memory;
|
||||
|
||||
public sealed class TerrainOffsets
|
||||
{
|
||||
private static readonly JsonSerializerOptions JsonOptions = new()
|
||||
{
|
||||
WriteIndented = true,
|
||||
DefaultIgnoreCondition = JsonIgnoreCondition.Never
|
||||
};
|
||||
|
||||
public string ProcessName { get; set; } = "PathOfExileSteam";
|
||||
|
||||
/// <summary>Pattern to find GameState base pointer. Empty = unknown for POE2.</summary>
|
||||
public string GameStatePattern { get; set; } = "";
|
||||
|
||||
// Pointer chain: GameState → InGameState → IngameData → TerrainData
|
||||
public int InGameStateOffset { get; set; }
|
||||
public int IngameDataOffset { get; set; }
|
||||
public int TerrainDataOffset { get; set; }
|
||||
|
||||
// Within TerrainData struct
|
||||
public int NumColsOffset { get; set; }
|
||||
public int NumRowsOffset { get; set; }
|
||||
public int LayerMeleeOffset { get; set; }
|
||||
public int BytesPerRowOffset { get; set; }
|
||||
|
||||
/// <summary>Number of sub-tiles per terrain cell (typically 23 for POE).</summary>
|
||||
public int SubTilesPerCell { get; set; } = 23;
|
||||
|
||||
public static TerrainOffsets Load(string path)
|
||||
{
|
||||
if (!File.Exists(path))
|
||||
{
|
||||
Log.Information("Offsets file not found at '{Path}', using defaults", path);
|
||||
var defaults = new TerrainOffsets();
|
||||
defaults.Save(path);
|
||||
return defaults;
|
||||
}
|
||||
|
||||
try
|
||||
{
|
||||
var json = File.ReadAllText(path);
|
||||
var offsets = JsonSerializer.Deserialize<TerrainOffsets>(json, JsonOptions);
|
||||
if (offsets is null)
|
||||
{
|
||||
Log.Warning("Failed to deserialize '{Path}', using defaults", path);
|
||||
return new TerrainOffsets();
|
||||
}
|
||||
Log.Information("Loaded offsets from '{Path}'", path);
|
||||
return offsets;
|
||||
}
|
||||
catch (Exception ex)
|
||||
{
|
||||
Log.Error(ex, "Error loading offsets from '{Path}'", path);
|
||||
return new TerrainOffsets();
|
||||
}
|
||||
}
|
||||
|
||||
public void Save(string path)
|
||||
{
|
||||
try
|
||||
{
|
||||
var json = JsonSerializer.Serialize(this, JsonOptions);
|
||||
File.WriteAllText(path, json);
|
||||
Log.Debug("Saved offsets to '{Path}'", path);
|
||||
}
|
||||
catch (Exception ex)
|
||||
{
|
||||
Log.Error(ex, "Error saving offsets to '{Path}'", path);
|
||||
}
|
||||
}
|
||||
}
|
||||
Loading…
Add table
Add a link
Reference in a new issue