Skip to content

Commit

Permalink
add thaen fruit and blood moon data
Browse files Browse the repository at this point in the history
  • Loading branch information
AndrewSav committed Jan 13, 2025
1 parent 6d5e1ab commit fb37638
Show file tree
Hide file tree
Showing 7 changed files with 109 additions and 3 deletions.
2 changes: 2 additions & 0 deletions Analyzer.WorldSave.cs
Original file line number Diff line number Diff line change
@@ -1,5 +1,6 @@
using lib.remnant2.analyzer.Enums;
using lib.remnant2.analyzer.Model;
using lib.remnant2.analyzer.Model.Mechanics;
using lib.remnant2.saves.Model.Parts;
using lib.remnant2.saves.Model.Properties;
using lib.remnant2.saves.Model;
Expand Down Expand Up @@ -68,6 +69,7 @@ private static RolledWorld GetRolledWorld(Navigator navigator, string mode)
QuestInventory = questInventory,
Difficulty = Difficulties[difficulty],
Playtime = tp,
BloodMoon = BloodMoon.Read(navigator)
};
rolledWorld.Zones = worldIds.Select(x => GetZone(zoneActors, x, labyrinthId, events, rolledWorld, navigator)).ToList();

Expand Down
7 changes: 6 additions & 1 deletion Analyzer.cs
Original file line number Diff line number Diff line change
Expand Up @@ -11,6 +11,7 @@
using SerilogTimings;
using SerilogTimings.Extensions;
using lib.remnant2.analyzer.Enums;
using lib.remnant2.analyzer.Model.Mechanics;
using lib.remnant2.analyzer.SaveLocation;


Expand Down Expand Up @@ -331,6 +332,9 @@ public static Dataset Analyze(string? folderPath = null, Dataset? oldDataset = n
}
operation.Complete();

operation = performance.BeginOperation($"Character {result.Characters.Count + 1} (save_{charSlotInternal}) get thaen fruit data");
ThaenFruit? thaenFruit = ThaenFruit.Read(navigator);
operation.Complete();
operation = performance.BeginOperation($"Character {result.Characters.Count + 1} (save_{charSlotInternal}) campaign loot groups");
int slot = (int)navigator.GetProperty("LastActiveRootSlot")!.Value!;
WorldSlot mode = slot == 0 ? WorldSlot.Campaign : WorldSlot.Adventure;
Expand All @@ -343,7 +347,8 @@ public static Dataset Analyze(string? folderPath = null, Dataset? oldDataset = n
Adventure = adventure,
QuestCompletedLog = questCompletedLog,
Playtime = tp,
CassShop = cassLoot
CassShop = cassLoot,
ThaenFruit = thaenFruit
},
Profile = profile,
Index = charSlotInternal,
Expand Down
2 changes: 2 additions & 0 deletions CHANGELOG.md
Original file line number Diff line number Diff line change
@@ -1,5 +1,7 @@
# Changelog

## v0.0.37 (13 Jan 2025)
- Add Thaen fruit and Blood moon data

## v0.0.36 (13 Jan 2025)
- Fix Override Pin name and location
Expand Down
46 changes: 46 additions & 0 deletions Model/Mechanics/BloodMoon.cs
Original file line number Diff line number Diff line change
@@ -0,0 +1,46 @@
using lib.remnant2.saves.Model;
using lib.remnant2.saves.Model.Properties;
using lib.remnant2.saves.Navigation;

namespace lib.remnant2.analyzer.Model.Mechanics;

public class BloodMoon
{
public double CurrentChance { get; set; }
public DateTime LastTriggeredTime { get; set; }
public DateTime LastCheckTime { get; set; }
public int ZoneLoadCount { get; set; }
public Dictionary<string, string> StringifiedRawData = [];

public static BloodMoon? Read(Navigator n)
{
List<UObject> oo = n.FindObjects("Quest_Event_Bloodmoon_C");
if (oo.Count == 0) return null;
Component? c =oo[0].Components?.FirstOrDefault(x => x.ComponentKey == "BloodMoon");
if (c == null) return null;
PropertyBag? pb = c.Properties;
if (pb == null) return null;
BloodMoon result = new()
{
StringifiedRawData = pb.Properties.ToDictionary(x => x.Key, x => x.Value.ToString())
};
if (result.StringifiedRawData.Count == 0) return null;
if (pb.Contains("CurrentChance"))
{
result.CurrentChance = pb["CurrentChance"].Get<double>();
}
if (pb.Contains("LastTriggeredTime"))
{
result.LastTriggeredTime = (DateTime)pb["LastTriggeredTime"].Get<StructProperty>().Value!;
}
if (pb.Contains("LastCheckTime"))
{
result.LastCheckTime = (DateTime)pb["LastCheckTime"].Get<StructProperty>().Value!;
}
if (pb.Contains("ZoneLoadCount"))
{
result.ZoneLoadCount = pb["ZoneLoadCount"].Get<int>();
}
return result;
}
}
45 changes: 45 additions & 0 deletions Model/Mechanics/ThaenFruit.cs
Original file line number Diff line number Diff line change
@@ -0,0 +1,45 @@
using lib.remnant2.saves.Model;
using lib.remnant2.saves.Model.Properties;
using lib.remnant2.saves.Navigation;

namespace lib.remnant2.analyzer.Model.Mechanics;
public class ThaenFruit
{
public int GrowthStage { get; set; }
public DateTime Timestamp { get; set; }
public bool HasFruit { get; set; }
public int PickedCount { get; set; }
public Dictionary<string,string> StringifiedRawData = [];

public static ThaenFruit? Read(Navigator n)
{
UObject? o = n.GetObject("pc:/Game/Zone_1_Template.Ward13_Town:PersistentLevel");
if (o == null || o.Properties == null) return null;
if (o.Properties.Properties[1].Value.Value is not StructProperty sp) return null;
if (sp.Value is not PersistenceContainer pc) return null;
PropertyBag? pb = pc.Actors.SingleOrDefault(x=> x.Key == 55).Value.GetFirstObjectProperties();
if (pb == null) return null;
ThaenFruit result = new()
{
StringifiedRawData = pb.Properties.ToDictionary(x => x.Key, x => x.Value.ToString())
};
if (result.StringifiedRawData.Count == 0) return null;
if (pb.Contains("GrowthStage"))
{
result.GrowthStage = pb["GrowthStage"].Get<int>();
}
if (pb.Contains("Timestamp"))
{
result.Timestamp = (DateTime)pb["Timestamp"].Get<StructProperty>().Value!;
}
if (pb.Contains("HasFruit"))
{
result.HasFruit = pb["HasFruit"].Get<byte>() != 0;
}
if (pb.Contains("PickedCount"))
{
result.PickedCount = pb["PickedCount"].Get<int>();
}
return result;
}
}
5 changes: 4 additions & 1 deletion Model/RolledWorld.cs
Original file line number Diff line number Diff line change
@@ -1,4 +1,6 @@
namespace lib.remnant2.analyzer.Model;
using lib.remnant2.analyzer.Model.Mechanics;

namespace lib.remnant2.analyzer.Model;

// Represents part of the data from a single save_N.sav: either adventure data or campaign data
public class RolledWorld
Expand Down Expand Up @@ -42,4 +44,5 @@ public bool CanGetChallenge(string challenge)
}

public bool IsCampaign => Zones.Exists(x => x.Name == "Labyrinth");
public BloodMoon? BloodMoon;
}
5 changes: 4 additions & 1 deletion Model/SaveSlot.cs
Original file line number Diff line number Diff line change
@@ -1,4 +1,6 @@
namespace lib.remnant2.analyzer.Model;
using lib.remnant2.analyzer.Model.Mechanics;

namespace lib.remnant2.analyzer.Model;

// Represents data in a single save_N.sav
public class SaveSlot
Expand All @@ -8,4 +10,5 @@ public class SaveSlot
public required List<string> QuestCompletedLog;
public required List<LootItem> CassShop;
public TimeSpan? Playtime;
public ThaenFruit? ThaenFruit;
}

0 comments on commit fb37638

Please sign in to comment.