Created
April 10, 2020 14:30
-
-
Save gallexme/c1fa5b24aa9afea8d5676b3f4ee6b038 to your computer and use it in GitHub Desktop.
example
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
using System.Collections.Generic; | |
using TaleWorlds.CampaignSystem; | |
using TaleWorlds.SaveSystem; | |
namespace TestSPMod | |
{ | |
public class CustomSaveTickerTest : CampaignBehaviorBase | |
{ | |
public override void RegisterEvents() | |
{ | |
CampaignEvents.HourlyTickEvent.AddNonSerializedListener(this, onTick); | |
} | |
private void onTick() | |
{ | |
test.Add(Campaign.CurrentTime, new TestSaveAbleClass {myHero = Hero.MainHero,mystring = "TESTTTTTTT"}); | |
} | |
Dictionary<float, TestSaveAbleClass> test = new Dictionary<float, TestSaveAbleClass>(); | |
public class TestSaveAbleClass | |
{ | |
[SaveableField(1)] public Hero myHero; | |
[SaveableField(2)] | |
public string mystring = ""; | |
} | |
public class MySaveDefiner : SaveableTypeDefiner | |
{ | |
public MySaveDefiner() : base(10000001) | |
{ | |
} | |
protected override void DefineClassTypes() | |
{ | |
AddClassDefinition(typeof(TestSaveAbleClass), 1); | |
} | |
protected override void DefineContainerDefinitions() | |
{ | |
ConstructContainerDefinition(typeof (Dictionary<float, TestSaveAbleClass>)); | |
} | |
} | |
private void OnSessionLaunched() | |
{ | |
} | |
public override void SyncData(IDataStore dataStore) | |
{ | |
dataStore.SyncData("test", ref test); | |
} | |
} | |
} |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment