Ejemplo n.º 1
0
        internal void PacketizeO2GeneratorSettings(IMyCubeBlock block, ProtoO2GeneratorSettings settings)
        {
            var data  = new DataO2GeneratorSettings(MyAPIGateway.Multiplayer.MyId, block.EntityId, settings);
            var bytes = MyAPIGateway.Utilities.SerializeToBinary(data);

            O2GeneratorSettingsToClients(block.CubeGrid.GetPosition(), bytes, data.Sender);
        }
Ejemplo n.º 2
0
        }                                    // empty ctor is required for deserialization

        public DataO2GeneratorSettings(ulong sender, long entityId, ProtoO2GeneratorSettings settings)
        {
            Type     = PacketType.O2Generatorsettings;
            Sender   = sender;
            EntityId = entityId;
            Settings = settings;
        }
Ejemplo n.º 3
0
 public DataO2GeneratorSettings(ulong sender, long entityId, PacketType action)
 {
     Type     = action;
     Sender   = sender;
     EntityId = entityId;
     Settings = null;
 }
Ejemplo n.º 4
0
        public bool LoadSettings()
        {
            if (O2Generator.Storage == null)
            {
                return(false);
            }

            string rawData;
            bool   loadedSomething = false;

            if (O2Generator.Storage.TryGetValue(Session.Instance.O2GeneratorSettingsGuid, out rawData))
            {
                ProtoO2GeneratorSettings loadedSettings = null;

                try
                {
                    loadedSettings = MyAPIGateway.Utilities.SerializeFromXML <ProtoO2GeneratorSettings>(rawData);
                }
                catch (Exception e)
                {
                    loadedSettings = null;
                    Log.Line($"O2GeneratorId:{O2Generator.EntityId.ToString()} - Error loading settings!\n{e}");
                }

                if (loadedSettings != null)
                {
                    Settings        = loadedSettings;
                    loadedSomething = true;
                }
            }

            return(loadedSomething);
        }
Ejemplo n.º 5
0
 internal void UpdateSettings(ProtoO2GeneratorSettings newSettings)
 {
     if (Session.Enforced.Debug == 3)
     {
         Log.Line($"UpdateSettings for O2Generator - Fix:{newSettings.FixRoomPressure} - O2GenId [{O2Generator.EntityId}]");
     }
     SettingsUpdated = true;
     O2Set.Settings  = newSettings;
 }