Esempio n. 1
0
 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);
     }
 }
Esempio n. 2
0
 public override void UpdateOnceBeforeFrame()
 {
     try
     {
         if (Tool.CubeGrid.Physics == null)
         {
             NeedsUpdate |= MyEntityUpdateEnum.BEFORE_NEXT_FRAME;
             return;
         }
         Term      = Grid.GetTerminalSystem();
         ToolCargo = Tool.GetInventory();
         CheckInitControls();
         SyncBeamLength   = new AutoSet <float>(Tool, "BeamLength", Checker: val => val >= MinBeamLengthBlocks && val <= MaxBeamLengthBlocks);
         SyncDistanceMode = new AutoSet <bool>(Tool, "DistanceBasedMode");
         SyncBeamLength.Ask();
         SyncDistanceMode.Ask();
         BeamLength = 1;
         Tool.AppendingCustomInfo += Tool_AppendingCustomInfo;
         Load();
         NeedsUpdate |= MyEntityUpdateEnum.EACH_FRAME | MyEntityUpdateEnum.EACH_100TH_FRAME;
         DebugNote    = MyAPIGateway.Utilities.CreateNotification($"{Tool.CustomName}", int.MaxValue, (IsWelder ? "Blue" : "Red"));
         if (SessionCore.Debug)
         {
             DebugNote.Show();
         }
     }
     catch { }
 }
Esempio n. 3
0
 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);
     }
 }