Пример #1
0
        /// <summary>
        ///     Set option sync message.
        /// </summary>
        /// <param name="sender">The sender who send the option message.</param>
        /// <param name="message">The option message received.</param>
        private void OnSetOptionSyncMessage(ulong sender, SetOptionSyncMessage message)
        {
            switch (message.Option)
            {
            case Option.AlwaysAutoHelmet:
            case Option.AdditionalFuelWarning:
                Mod.Static.SetOption(message.Option, MyAPIGateway.Utilities.SerializeFromBinary <bool>(message.Value));
                break;

            case Option.FuelThreshold:
            case Option.HaltedSpeedTolerance:
                Mod.Static.SetOption(message.Option, MyAPIGateway.Utilities.SerializeFromBinary <float>(message.Value));
                break;

            case Option.DelayAfterManualHelmet:
                Mod.Static.SetOption(message.Option, MyAPIGateway.Utilities.SerializeFromBinary <int>(message.Value));
                break;

            case Option.DisableAutoDampener:
                Mod.Static.SetOption(message.Option, MyAPIGateway.Utilities.SerializeFromBinary <DisableAutoDampenerOption>(message.Value));
                break;

            default:
                using (Log.BeginMethod(nameof(OnSetOptionSyncMessage))) {
                    Log.Error($"Unknown option '{nameof(message.Option)}'");
                }

                return;
            }
        }
Пример #2
0
        public override void SyncOption <TValue>(Option option, TValue value)
        {
            Mod.Static.SetOption(option, value);
            var message = new SetOptionSyncMessage {
                Option = option, Value = MyAPIGateway.Utilities.SerializeToBinary(value)
            };

            Network.Sync(message);
        }