Пример #1
0
        private void HandleServerEventMultiplayerOptionsImmediate(MultiplayerOptionsImmediate message)
        {
            for (MultiplayerOptions.OptionType optionType = MultiplayerOptions.OptionType.ServerName; optionType < MultiplayerOptions.OptionType.NumOfSlots; ++optionType)
            {
                MultiplayerOptionsProperty optionProperty = optionType.GetOptionProperty();
                if (optionProperty.Replication == MultiplayerOptionsProperty.ReplicationOccurrence.Immediately)
                {
                    switch (optionProperty.OptionValueType)
                    {
                    case MultiplayerOptions.OptionValueType.Bool:
                        bool flag;
                        message.GetOption(optionType).GetValue(out flag);
                        optionType.SetValue(flag);
                        continue;

                    case MultiplayerOptions.OptionValueType.Integer:
                    case MultiplayerOptions.OptionValueType.Enum:
                        int num;
                        message.GetOption(optionType).GetValue(out num);
                        optionType.SetValue(num);
                        continue;

                    case MultiplayerOptions.OptionValueType.String:
                        string str;
                        message.GetOption(optionType).GetValue(out str);
                        optionType.SetValue(str);
                        continue;

                    default:
                        throw new ArgumentOutOfRangeException();
                    }
                }
            }
        }
Пример #2
0
        protected override void OnWrite()
        {
            foreach (MultiplayerOptions.MultiplayerOption option in this._optionList)
            {
                MultiplayerOptions.OptionType optionType     = option.OptionType;
                MultiplayerOptionsProperty    optionProperty = optionType.GetOptionProperty();
                switch (optionProperty.OptionValueType)
                {
                case MultiplayerOptions.OptionValueType.Bool:
                    GameNetworkMessage.WriteBoolToPacket(optionType.GetBoolValue());
                    continue;

                case MultiplayerOptions.OptionValueType.Integer:
                case MultiplayerOptions.OptionValueType.Enum:
                    GameNetworkMessage.WriteIntToPacket(optionType.GetIntValue(), new CompressionInfo.Integer(optionProperty.BoundsMin, optionProperty.BoundsMax, true));
                    continue;

                case MultiplayerOptions.OptionValueType.String:
                    GameNetworkMessage.WriteStringToPacket(optionType.GetStrValue());
                    continue;

                default:
                    continue;
                }
            }
        }
Пример #3
0
        protected override bool OnRead()
        {
            bool bufferReadValid = true;

            this._optionList = new List <MultiplayerOptions.MultiplayerOption>();
            for (MultiplayerOptions.OptionType optionType = MultiplayerOptions.OptionType.ServerName; optionType < MultiplayerOptions.OptionType.NumOfSlots; ++optionType)
            {
                MultiplayerOptionsProperty optionProperty = optionType.GetOptionProperty();
                if (optionProperty.Replication == MultiplayerOptionsProperty.ReplicationOccurrence.AtMapLoad)
                {
                    MultiplayerOptions.MultiplayerOption multiplayerOption = MultiplayerOptions.MultiplayerOption.CreateMultiplayerOption(optionType);
                    switch (optionProperty.OptionValueType)
                    {
                    case MultiplayerOptions.OptionValueType.Bool:
                        multiplayerOption.UpdateValue(GameNetworkMessage.ReadBoolFromPacket(ref bufferReadValid));
                        break;

                    case MultiplayerOptions.OptionValueType.Integer:
                    case MultiplayerOptions.OptionValueType.Enum:
                        multiplayerOption.UpdateValue(GameNetworkMessage.ReadIntFromPacket(new CompressionInfo.Integer(optionProperty.BoundsMin, optionProperty.BoundsMax, true), ref bufferReadValid));
                        break;

                    case MultiplayerOptions.OptionValueType.String:
                        multiplayerOption.UpdateValue(GameNetworkMessage.ReadStringFromPacket(ref bufferReadValid));
                        break;
                    }
                    this._optionList.Add(multiplayerOption);
                }
            }
            return(bufferReadValid);
        }
Пример #4
0
 public MultiplayerOptionsInitial()
 {
     this._optionList = new List <MultiplayerOptions.MultiplayerOption>();
     for (MultiplayerOptions.OptionType optionType = MultiplayerOptions.OptionType.ServerName; optionType < MultiplayerOptions.OptionType.NumOfSlots; ++optionType)
     {
         if (optionType.GetOptionProperty().Replication == MultiplayerOptionsProperty.ReplicationOccurrence.AtMapLoad)
         {
             this._optionList.Add(MultiplayerOptions.Instance.GetOptionFromOptionType(optionType));
         }
     }
 }
 private MultiplayerOption(MultiplayerOptions.OptionType optionType)
 {
     this.OptionType = optionType;
     if (optionType.GetOptionProperty().OptionValueType == MultiplayerOptions.OptionValueType.String)
     {
         this._intValue    = MultiplayerOptions.MultiplayerOption.IntegerValue.Invalid;
         this._stringValue = MultiplayerOptions.MultiplayerOption.StringValue.Create();
     }
     else
     {
         this._intValue    = MultiplayerOptions.MultiplayerOption.IntegerValue.Create();
         this._stringValue = MultiplayerOptions.MultiplayerOption.StringValue.Invalid;
     }
 }
Пример #6
0
        private void HandleServerEventMultiplayerOptionsInitial(MultiplayerOptionsInitial message)
        {
            for (MultiplayerOptions.OptionType optionType = MultiplayerOptions.OptionType.ServerName; optionType < MultiplayerOptions.OptionType.NumOfSlots; ++optionType)
            {
                MultiplayerOptionsProperty optionProperty = optionType.GetOptionProperty();
                if (optionProperty.Replication == MultiplayerOptionsProperty.ReplicationOccurrence.AtMapLoad)
                {
                    switch (optionProperty.OptionValueType)
                    {
                    case MultiplayerOptions.OptionValueType.Bool:
                        bool flag;
                        message.GetOption(optionType).GetValue(out flag);
                        optionType.SetValue(flag);
                        continue;

                    case MultiplayerOptions.OptionValueType.Integer:
                    case MultiplayerOptions.OptionValueType.Enum:
                        int num;
                        message.GetOption(optionType).GetValue(out num);
                        optionType.SetValue(num);
                        continue;

                    case MultiplayerOptions.OptionValueType.String:
                        string str;
                        message.GetOption(optionType).GetValue(out str);
                        optionType.SetValue(str);
                        continue;

                    default:
                        throw new ArgumentOutOfRangeException();
                    }
                }
            }
            string strValue = MultiplayerOptions.OptionType.WelcomeMessage.GetStrValue();

            if (string.IsNullOrEmpty(strValue))
            {
                return;
            }
            BaseNetworkComponent.WelcomeMessageReceivedDelegate welcomeMessageReceived = this.WelcomeMessageReceived;
            if (welcomeMessageReceived == null)
            {
                return;
            }
            welcomeMessageReceived(strValue);
        }
        public string GetValueTextForOptionWithMultipleSelection(
            MultiplayerOptions.OptionType optionType)
        {
            MultiplayerOptionsProperty optionProperty = optionType.GetOptionProperty();

            switch (optionProperty.OptionValueType)
            {
            case MultiplayerOptions.OptionValueType.Enum:
                return(Enum.ToObject(optionProperty.EnumType, optionType.GetIntValue()).ToString());

            case MultiplayerOptions.OptionValueType.String:
                return(optionType.GetStrValue());

            default:
                return((string)null);
            }
        }
Пример #8
0
        public static string GetValueText(
            this MultiplayerOptions.OptionType optionType,
            MultiplayerOptions.MultiplayerOptionsAccessMode mode = MultiplayerOptions.MultiplayerOptionsAccessMode.CurrentMapOptions)
        {
            switch (optionType.GetOptionProperty().OptionValueType)
            {
            case MultiplayerOptions.OptionValueType.Bool:
                return(optionType.GetBoolValue(mode).ToString());

            case MultiplayerOptions.OptionValueType.Integer:
            case MultiplayerOptions.OptionValueType.Enum:
                return(optionType.GetIntValue(mode).ToString());

            case MultiplayerOptions.OptionValueType.String:
                return(optionType.GetStrValue(mode));

            default:
                return((string)null);
            }
        }
        public void SetValueForOptionWithMultipleSelectionFromText(
            MultiplayerOptions.OptionType optionType,
            string value)
        {
            MultiplayerOptionsProperty optionProperty = optionType.GetOptionProperty();

            switch (optionProperty.OptionValueType)
            {
            case MultiplayerOptions.OptionValueType.Enum:
                optionType.SetValue((int)Enum.Parse(optionProperty.EnumType, value));
                break;

            case MultiplayerOptions.OptionValueType.String:
                optionType.SetValue(value);
                break;
            }
            if (optionType != MultiplayerOptions.OptionType.GameType && optionType != MultiplayerOptions.OptionType.ClanMatchType)
            {
                return;
            }
            this.OnGameTypeChanged();
        }
Пример #10
0
 public static int GetMaximumValue(this MultiplayerOptions.OptionType optionType) => optionType.GetOptionProperty().BoundsMax;