Persist item enabled state in typed snapshots
This commit is contained in:
parent
ee60d1d5d3
commit
f785f8e350
10 changed files with 58 additions and 18 deletions
|
|
@ -636,18 +636,20 @@ namespace GameCult.Aetheria.State.Unity
|
|||
|
||||
public sealed class AetheriaRuntimeLoadoutItemSnapshot
|
||||
{
|
||||
public AetheriaRuntimeLoadoutItemSnapshot(string itemKey, double quality, double durability, int quantity)
|
||||
public AetheriaRuntimeLoadoutItemSnapshot(string itemKey, double quality, double durability, int quantity, bool enabled)
|
||||
{
|
||||
ItemKey = itemKey;
|
||||
Quality = quality;
|
||||
Durability = durability;
|
||||
Quantity = quantity;
|
||||
Enabled = enabled;
|
||||
}
|
||||
|
||||
public string ItemKey { get; }
|
||||
public double Quality { get; }
|
||||
public double Durability { get; }
|
||||
public int Quantity { get; }
|
||||
public bool Enabled { get; }
|
||||
}
|
||||
|
||||
public sealed class AetheriaRuntimeLoadoutItemSlotSnapshot
|
||||
|
|
@ -973,7 +975,7 @@ namespace GameCult.Aetheria.State.Unity
|
|||
|
||||
public sealed class AetheriaRuntimeEntityItemSlotSnapshot
|
||||
{
|
||||
public AetheriaRuntimeEntityItemSlotSnapshot(int x, int y, string itemKey, double quality, double durability, int quantity)
|
||||
public AetheriaRuntimeEntityItemSlotSnapshot(int x, int y, string itemKey, double quality, double durability, int quantity, bool enabled)
|
||||
{
|
||||
X = x;
|
||||
Y = y;
|
||||
|
|
@ -981,6 +983,7 @@ namespace GameCult.Aetheria.State.Unity
|
|||
Quality = quality;
|
||||
Durability = durability;
|
||||
Quantity = quantity;
|
||||
Enabled = enabled;
|
||||
}
|
||||
|
||||
public int X { get; }
|
||||
|
|
@ -989,6 +992,7 @@ namespace GameCult.Aetheria.State.Unity
|
|||
public double Quality { get; }
|
||||
public double Durability { get; }
|
||||
public int Quantity { get; }
|
||||
public bool Enabled { get; }
|
||||
}
|
||||
|
||||
public sealed class AetheriaRuntimeEntityStatGridSnapshot
|
||||
|
|
|
|||
|
|
@ -769,14 +769,16 @@ namespace GameCult.Aetheria.State.Unity
|
|||
var quality = ReadFieldDouble(ref reader, slotFields, 2, 1);
|
||||
var durability = ReadFieldDouble(ref reader, slotFields, 3, 1);
|
||||
var quantity = ReadFieldInt32(ref reader, slotFields, 4);
|
||||
SkipRemaining(ref reader, slotFields, 5);
|
||||
var enabled = ReadFieldBool(ref reader, slotFields, 5, true);
|
||||
SkipRemaining(ref reader, slotFields, 6);
|
||||
slots[slot] = new AetheriaRuntimeEntityItemSlotSnapshot(
|
||||
position.X,
|
||||
position.Y,
|
||||
itemKey,
|
||||
quality,
|
||||
durability,
|
||||
quantity <= 0 ? 1 : quantity);
|
||||
quantity <= 0 ? 1 : quantity,
|
||||
enabled);
|
||||
}
|
||||
|
||||
return slots;
|
||||
|
|
@ -1058,6 +1060,11 @@ namespace GameCult.Aetheria.State.Unity
|
|||
return index < fields && reader.ReadBoolean();
|
||||
}
|
||||
|
||||
private static bool ReadFieldBool(ref MessagePackReader reader, int fields, int index, bool fallback)
|
||||
{
|
||||
return index >= fields ? fallback : reader.ReadBoolean();
|
||||
}
|
||||
|
||||
private static long ReadFieldInt64(ref MessagePackReader reader, int fields, int index)
|
||||
{
|
||||
return index >= fields ? 0 : reader.ReadInt64();
|
||||
|
|
@ -1220,13 +1227,14 @@ namespace GameCult.Aetheria.State.Unity
|
|||
var quality = ReadFieldDouble(ref reader, itemFields, 1, 1);
|
||||
var durability = ReadFieldDouble(ref reader, itemFields, 2, 1);
|
||||
var quantity = ReadFieldInt32(ref reader, itemFields, 3);
|
||||
SkipRemaining(ref reader, itemFields, 4);
|
||||
return new AetheriaRuntimeLoadoutItemSnapshot(itemKey, quality, durability, quantity);
|
||||
var enabled = ReadFieldBool(ref reader, itemFields, 4, true);
|
||||
SkipRemaining(ref reader, itemFields, 5);
|
||||
return new AetheriaRuntimeLoadoutItemSnapshot(itemKey, quality, durability, quantity, enabled);
|
||||
}
|
||||
|
||||
private static AetheriaRuntimeLoadoutItemSnapshot EmptyLoadoutItem()
|
||||
{
|
||||
return new AetheriaRuntimeLoadoutItemSnapshot("", 1, 1, 1);
|
||||
return new AetheriaRuntimeLoadoutItemSnapshot("", 1, 1, 1, true);
|
||||
}
|
||||
|
||||
private static IReadOnlyList<AetheriaRuntimeLoadoutItemSlotSnapshot> ReadFieldLoadoutItemSlots(ref MessagePackReader reader, int fields, int index)
|
||||
|
|
|
|||
|
|
@ -184,6 +184,9 @@ namespace GameCult.Aetheria.State.Unity
|
|||
|
||||
[Key(3)]
|
||||
public int Quantity { get; set; } = 1;
|
||||
|
||||
[Key(4)]
|
||||
public bool Enabled { get; set; } = true;
|
||||
}
|
||||
|
||||
[MessagePackObject]
|
||||
|
|
|
|||
Loading…
Reference in a new issue