public void Load() { try { string Storage = ""; //if (Tool.Storage.ContainsKey(SessionCore.StorageGuid)) if (MyAPIGateway.Utilities.GetVariable($"settings_{Tool.EntityId}", out Storage)) { byte[] Raw = Convert.FromBase64String(Storage); try { Persistent persistent = MyAPIGateway.Utilities.SerializeFromBinary <Persistent>(Raw); SyncBeamLength.Set(persistent.BeamLength); SyncDistanceMode.Set(persistent.DistanceBased); SessionCore.DebugWrite($"{Tool.CustomName}.Load()", $"Loaded from storage. beamlength={persistent.BeamLength}"); } catch (Exception Scrap) { SessionCore.LogError($"{Tool.CustomName}.Load()", Scrap); } } else { SessionCore.DebugWrite($"{Tool.CustomName}.Load()", "Storage access failed."); } } catch (Exception Scrap) { SessionCore.LogError($"{Tool.CustomName}.Load().AccessStorage", Scrap); } }
public void Load() { try { if (MyAPIGateway.Multiplayer.MultiplayerActive && !MyAPIGateway.Multiplayer.IsServer) { SyncHarvestEfficiency.Ask(); return; } string Storage = ""; //if (Tool.Storage.ContainsKey(SessionCore.StorageGuid)) if (Drill.Storage?.TryGetValue(SessionCore.StorageGuid, out Storage) == true || MyAPIGateway.Utilities.GetVariable($"settings_{Drill.EntityId}", out Storage)) { try { Persistent persistent = MyAPIGateway.Utilities.SerializeFromBinary <Persistent>(Convert.FromBase64String(Storage)); SyncHarvestEfficiency.Set(persistent.HarvestMultiplier); } catch (Exception Scrap) { SessionCore.LogError($"{Drill.CustomName}.Load()", Scrap); } } else { SessionCore.DebugWrite($"{Drill.CustomName}.Load()", "Storage access failed."); } } catch (Exception Scrap) { SessionCore.LogError($"{Drill.CustomName}.Load().AccessStorage", Scrap); } }
public void Load() { try { if (MyAPIGateway.Multiplayer.MultiplayerActive && !MyAPIGateway.Multiplayer.IsServer) { SyncBeamLength.Ask(); SyncDistanceMode.Ask(); SyncSpeedMultiplier.Ask(); return; } string Storage = ""; //if (Tool.Storage.ContainsKey(SessionCore.StorageGuid)) if (Tool.Storage?.TryGetValue(SessionCore.StorageGuid, out Storage) == true || MyAPIGateway.Utilities.GetVariable($"settings_{Tool.EntityId}", out Storage)) { try { Persistent persistent = MyAPIGateway.Utilities.SerializeFromBinary <Persistent>(Convert.FromBase64String(Storage)); SyncBeamLength.Set(persistent.BeamLength); SyncDistanceMode.Set(persistent.DistanceBased); SyncSpeedMultiplier.Set(persistent.SpeedMultiplier); SessionCore.DebugWrite($"{Tool.CustomName}.Load()", $"Loaded from storage. Persistent Beamlength: {persistent.BeamLength}; Sync Beamlength: {SyncBeamLength.Get()}"); } catch (Exception Scrap) { SessionCore.LogError($"{Tool.CustomName}.Load()", Scrap); } } else { SessionCore.DebugWrite($"{Tool.CustomName}.Load()", "Storage access failed."); } } catch (Exception Scrap) { SessionCore.LogError($"{Tool.CustomName}.Load().AccessStorage", Scrap); } }
public virtual void Load() { try { string Storage = null; if (MyAPIGateway.Utilities.GetVariable($"settings_{Entity.EntityId}", out Storage)) { byte[] Raw = Convert.FromBase64String(Storage); try { AntennaPersistent persistent = MyAPIGateway.Utilities.SerializeFromBinary <AntennaPersistent>(Raw); if (persistent.Datagrams != null) { Datagrams = new Queue <MyAntennaDatagram>(persistent.Datagrams); } if (persistent.Protocols != null) { Protocols = persistent.Protocols; } SyncAllowReceive.Set(persistent.Receive); } catch (Exception Scrap) { RadarCore.LogError($"{Block.CustomName}.Load()", Scrap); } } else { RadarCore.DebugWrite($"{Block.CustomName}.Load()", "Storage access failed.", IsExcessive: true); } } catch (Exception Scrap) { RadarCore.LogError($"{Block.CustomName}.Load().AccessStorage", Scrap); } }