The goal is to save all relics into a List. Here is the list of classes :
Code: Select all
public interface IRelic
{
public string Name { get; }
public string Description { get; }
public RelicRarity Rarity { get; }
public Character Character => Character.Any;
}
Code: Select all
[Serializable]
public abstract class ARelic : IRelic
{
public abstract string Name { get; }
public abstract string Description { get; }
public abstract RelicRarity Rarity { get; }
}
Code: Select all
public class BloodVialRelic : IRelic, IEventHandler<OnPlayerTurnStartedEvent>
{
public string Name => "Blood Vial";
public string Description => "Heal 5 HP at the start of combat.";
public RelicRarity Rarity => RelicRarity.Common;
private readonly GlobalEventBusMono eventBus;
public BloodVialRelic()
{
// some code
}
public void Handle(OnPlayerTurnStartedEvent evt)
{
// some code
}
}
Code: Select all
ES3.Save<ARelic>("Relic", bloodVialRelic)
Code: Select all
"__type" : "ClubSandwich.Relics.BloodVialRelic,ClubSandwich.Relics"
Code: Select all
ES3.Load<ARelic>("Relic", bloodVialRelic)
I have noticed that if I add a public int field to the BloodVialRelic, it's properly loaded. Any relic that has no public fields does return null when loaded, while any relic with public supported field types by ES3 return the proper value.
What's up with that ? I don't need fields in all of them, and I don't see why loading a class that has no public fields would output null.