public override void OnCreate() { foreach (var statInstDef in Stats) { if (statInstDef.Def is AccumulatedStatInstanceDef) { var stat = SyncObject.New <AccumulatedStat>(); stat.StatDef = statInstDef.Def.Stat.Def; stat.Modifiers.Add(new AccStatModifier() { AddMod = statInstDef.Def.InitialValue, ModKey = new EffectId() { SpellId = new SpellId() { Id = 0 } } }); stat.FinishInit(); StatsSync.Add(stat); } else { var stat = SyncObject.New <LinearStat>(); stat.StatDef = statInstDef.Def.Stat.Def; stat.Set(statInstDef.Def.InitialValue); stat.FinishInit(); StatsSync.Add(stat); } } }
static (DeltaList <TestSyncObject>, DeltaList <TestSyncObject>) SimpleInitTest() { DeltaList <TestSyncObject> list = SyncObject.New <DeltaList <TestSyncObject> >(); list.Add(SyncObject.New <TestSyncObject>()); list[0].Value = 1923; var listGhost = ((IGhost)list); NetDataWriter wStream = null; Assert.True(listGhost.Serialize(ref wStream, true)); DeltaList <TestSyncObject> syncedList = SyncObject.New <DeltaList <TestSyncObject> >(); var syncGhost = ((IGhost)syncedList); syncGhost.Deserialize(new NetDataReader(wStream.Data)); Assert.AreEqual(list[0].Value, syncedList[0].Value); return(list, syncedList); }