Base Class:
Code: Select all
using System.Collections;
using System.Collections.Generic;
using UnityEngine;
[System.Serializable]
public class TavernTable : MonoBehaviour
{
[Header("Basic Info")]
public int slot;
public string faction;
public List<TavernSeat> tavernSeats = new List<TavernSeat>();
//[Header("Graphics")]
public TavernTable()
{
}
public TavernTable(int slot, string faction, List<TavernSeat> tavernSeats)
{
this.slot = slot;
this.faction = faction;
this.tavernSeats = tavernSeats;
}
}
Code: Select all
using System.Collections;
using System.Collections.Generic;
using UnityEngine;
[System.Serializable]
public class TavernSeat : MonoBehaviour
{
[Header("Basic Info")]
public string faction;
public string npcString;
public string dish;
public bool occupied;
public string facing;
[Header("Graphics")]
public Sprite dishSprite;
public Animator dishAnimation;
public TavernSeat()
{
}
public TavernSeat(string faction, string npcString, string dish, bool occupied, string facing)
{
this.faction = faction;
this.npcString = npcString;
this.dish = dish;
this.occupied = occupied;
this.facing = facing;
}
}
Code: Select all
[SerializeField] private List<TavernTable> tavernTables = new List<TavernTable>();
private void Awake()
{
SaveSystem.saveDataApplied += OnSaveDataApplied;
EventHandler.ScenePortalTriggered += SaveBeforeChangingScenes;
if (Instance != null && Instance != this)
{
Destroy(this.gameObject);
}
else
{
Instance = this;
}
}
public void OnSaveDataApplied()
{
if (!ManualSave.manuallyLoadingGame)
{
if (ES3.KeyExists("tavernTables"))
{
tavernTables = ES3.Load<List<TavernTable>>("tavernTables");
}
}
}
void SaveBeforeChangingScenes()
{
ES3.Save("tavernTables", tavernTables);
}
public void OnApplicationQuit()
{
ES3.Save("tavernTables", tavernTables);
}
private void OnDestroy()
{
SaveSystem.saveDataApplied -= OnSaveDataApplied;
EventHandler.ScenePortalTriggered -= SaveBeforeChangingScenes;
}
Code: Select all
"tavernTables" : {
"__type" : "System.Collections.Generic.List`1[[TavernTable, Assembly-CSharp, Version=0.0.0.0, Culture=neutral, PublicKeyToken=null]],mscorlib",
"value" : [
{
"_ES3Ref" : "5414689953241649868",
"goID" : "6033350127038508259",
"slot" : 0,
"faction" : "Merchant Guild",
"tavernSeats" : [
{
"_ES3Ref" : "3685158514958316190"
},{
"_ES3Ref" : "1220786584282548631"
},{
"_ES3Ref" : "6747607265961300836"
},{
"_ES3Ref" : "5799960329459964387"
}
]
},{
"_ES3Ref" : "2155466466197841777",
"goID" : "8606208887014283366",
"slot" : 1,
"faction" : "",
"tavernSeats" : [
{
"_ES3Ref" : "2757473104712015625"
},{
"_ES3Ref" : "5896122006412478740"
},{
"_ES3Ref" : "8155609654366732165"
},{
"_ES3Ref" : "3081668857995932087"
}
]
},{
"_ES3Ref" : "5205220558443895360",
"goID" : "516784855196241593",
"slot" : 2,
"faction" : "",
"tavernSeats" : [
{
"_ES3Ref" : "5347194596021911488"
},{
"_ES3Ref" : "5970068844136196543"
},{
"_ES3Ref" : "5838737796283121499"
},{
"_ES3Ref" : "2137992083672095157"
}
]
},{
"_ES3Ref" : "5703271183222130916",
"goID" : "8973886442000047297",
"slot" : 3,
"faction" : "",
"tavernSeats" : [
{
"_ES3Ref" : "4921097766851121174"
},{
"_ES3Ref" : "7460144537797856366"
},{
"_ES3Ref" : "7107839831936185012"
},{
"_ES3Ref" : "1475154388851829189"
}
]
}
]
},