Beispiel #1
0
        public void Load()
        {
            if (Ai.MyGrid.Storage == null)
            {
                return;
            }

            AiDataValues load = null;
            string       rawData;
            bool         validData = false;

            if (Ai.MyGrid.Storage.TryGetValue(Ai.Session.AiDataGuid, out rawData))
            {
                try
                {
                    var base64 = Convert.FromBase64String(rawData);
                    load      = MyAPIGateway.Utilities.SerializeFromBinary <AiDataValues>(base64);
                    validData = load != null;
                }
                catch (Exception e)
                {
                    //Log.Line("Invalid State Loaded, Re-init");
                }
            }

            if (validData && load.Version == VersionControl)
            {
                Repo = load;
            }
            else
            {
                Repo = new AiDataValues();
            }
        }
        public bool Sync(AiDataValues sync)
        {
            if (sync.Revision > Revision)
            {
                Revision       = sync.Revision;
                ActiveTerminal = sync.ActiveTerminal;
                ControllingPlayers.Clear();
                foreach (var s in sync.ControllingPlayers)
                {
                    ControllingPlayers[s.Key] = s.Value;
                }

                return(true);
            }

            return(false);
        }
Beispiel #3
0
 public override void CleanUp()
 {
     base.CleanUp();
     Data = null;
 }
Beispiel #4
0
 public void Clean()
 {
     Ai   = null;
     Repo = null;
 }