Beispiel #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();
                    }
                }
            }
        }
        public List <string> GetMultiplayerOptionsList(MultiplayerOptions.OptionType optionType)
        {
            List <string> stringList1 = new List <string>();

            switch (optionType)
            {
            case MultiplayerOptions.OptionType.ClanMatchType:
                stringList1 = Module.CurrentModule.GetMultiplayerGameTypes().Select <MultiplayerGameTypeInfo, string>((Func <MultiplayerGameTypeInfo, string>)(q => q.GameType)).ToList <string>();
                stringList1.Remove("FreeForAll");
                stringList1.Remove("TeamDeathmatch");
                stringList1.Remove("Duel");
                stringList1.Remove("Siege");
                break;

            case MultiplayerOptions.OptionType.GameType:
                stringList1 = Module.CurrentModule.GetMultiplayerGameTypes().Select <MultiplayerGameTypeInfo, string>((Func <MultiplayerGameTypeInfo, string>)(q => q.GameType)).ToList <string>();
                break;

            case MultiplayerOptions.OptionType.Map:
                if (this.CurrentOptionsCategory == MultiplayerOptions.OptionsCategory.Default)
                {
                    stringList1 = MultiplayerGameTypes.GetGameTypeInfo(MultiplayerOptions.OptionType.GameType.GetStrValue()).Scenes.ToList <string>();
                    break;
                }
                if (this.CurrentOptionsCategory == MultiplayerOptions.OptionsCategory.ClanMatch)
                {
                    MultiplayerOptions.OptionType.ClanMatchType.GetStrValue();
                    stringList1 = this.GetAvailableClanMatchScenes();
                    break;
                }
                break;

            case MultiplayerOptions.OptionType.CultureTeam1:
            case MultiplayerOptions.OptionType.CultureTeam2:
                stringList1 = MBObjectManager.Instance.GetObjectTypeList <BasicCultureObject>().Where <BasicCultureObject>((Func <BasicCultureObject, bool>)(c => c.IsMainCulture)).Select <BasicCultureObject, string>((Func <BasicCultureObject, string>)(x => x.StringId)).ToList <string>();
                break;

            case MultiplayerOptions.OptionType.SpectatorCamera:
                List <string> stringList2 = new List <string>();
                stringList2.Add(SpectatorCameraTypes.LockToAnyAgent.ToString());
                SpectatorCameraTypes spectatorCameraTypes = SpectatorCameraTypes.LockToAnyPlayer;
                stringList2.Add(spectatorCameraTypes.ToString());
                spectatorCameraTypes = SpectatorCameraTypes.LockToTeamMembers;
                stringList2.Add(spectatorCameraTypes.ToString());
                spectatorCameraTypes = SpectatorCameraTypes.LockToTeamMembersView;
                stringList2.Add(spectatorCameraTypes.ToString());
                stringList1 = stringList2;
                break;

            case MultiplayerOptions.OptionType.AutoTeamBalanceThreshold:
                List <string> stringList3 = new List <string>();
                for (int index = 0; index < 6; ++index)
                {
                    stringList3.Add(((AutoTeamBalanceLimits)index).ToString());
                }
                stringList1 = stringList3;
                break;
            }
            return(stringList1);
        }
        public MultiplayerOptions()
        {
            this._current = new MultiplayerOptions.MultiplayerOptionsContainer();
            this._next    = new MultiplayerOptions.MultiplayerOptionsContainer();
            this._ui      = new MultiplayerOptions.MultiplayerOptionsContainer();
            MultiplayerOptions.MultiplayerOptionsContainer container = this.GetContainer();
            for (MultiplayerOptions.OptionType optionType = MultiplayerOptions.OptionType.ServerName; optionType < MultiplayerOptions.OptionType.NumOfSlots; ++optionType)
            {
                container.CreateOption(optionType);
            }
            List <MultiplayerGameTypeInfo> multiplayerGameTypes = Module.CurrentModule.GetMultiplayerGameTypes();

            if (multiplayerGameTypes.Count > 0)
            {
                MultiplayerGameTypeInfo multiplayerGameTypeInfo = multiplayerGameTypes[0];
                container.UpdateOptionValue(MultiplayerOptions.OptionType.GameType, multiplayerGameTypeInfo.GameType);
                container.UpdateOptionValue(MultiplayerOptions.OptionType.ClanMatchType, multiplayerGameTypes.First <MultiplayerGameTypeInfo>((Func <MultiplayerGameTypeInfo, bool>)(info => info.GameType == "Skirmish")).GameType);
                container.UpdateOptionValue(MultiplayerOptions.OptionType.Map, multiplayerGameTypeInfo.Scenes.First <string>());
            }
            container.UpdateOptionValue(MultiplayerOptions.OptionType.CultureTeam1, MBObjectManager.Instance.GetObjectTypeList <BasicCultureObject>()[0].StringId);
            container.UpdateOptionValue(MultiplayerOptions.OptionType.CultureTeam2, MBObjectManager.Instance.GetObjectTypeList <BasicCultureObject>()[2].StringId);
            container.UpdateOptionValue(MultiplayerOptions.OptionType.MaxNumberOfPlayers, 120);
            container.UpdateOptionValue(MultiplayerOptions.OptionType.MinNumberOfPlayersForMatchStart, 1);
            container.UpdateOptionValue(MultiplayerOptions.OptionType.WarmupTimeLimit, 5);
            container.UpdateOptionValue(MultiplayerOptions.OptionType.MapTimeLimit, 30);
            container.UpdateOptionValue(MultiplayerOptions.OptionType.RoundTimeLimit, 120);
            container.UpdateOptionValue(MultiplayerOptions.OptionType.RoundPreparationTimeLimit, 10);
            container.UpdateOptionValue(MultiplayerOptions.OptionType.RoundTotal, 20);
            container.UpdateOptionValue(MultiplayerOptions.OptionType.RespawnPeriodTeam1, 3);
            container.UpdateOptionValue(MultiplayerOptions.OptionType.RespawnPeriodTeam2, 3);
            container.UpdateOptionValue(MultiplayerOptions.OptionType.MinScoreToWinMatch, 120000);
            container.UpdateOptionValue(MultiplayerOptions.OptionType.AutoTeamBalanceThreshold, 0);
            this._current.CopyAllValuesTo(this._next);
            this._current.CopyAllValuesTo(this._ui);
        }
Beispiel #4
0
 public static void SetValue(
     this MultiplayerOptions.OptionType optionType,
     string value,
     MultiplayerOptions.MultiplayerOptionsAccessMode mode = MultiplayerOptions.MultiplayerOptionsAccessMode.CurrentMapOptions)
 {
     MultiplayerOptions.Instance.GetOptionFromOptionType(optionType, mode).UpdateValue(value);
 }
Beispiel #5
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);
        }
Beispiel #6
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;
                }
            }
        }
Beispiel #7
0
        public static string GetStrValue(
            this MultiplayerOptions.OptionType optionType,
            MultiplayerOptions.MultiplayerOptionsAccessMode mode = MultiplayerOptions.MultiplayerOptionsAccessMode.CurrentMapOptions)
        {
            string str;

            MultiplayerOptions.Instance.GetOptionFromOptionType(optionType, mode).GetValue(out str);
            return(str);
        }
Beispiel #8
0
        public static int GetIntValue(
            this MultiplayerOptions.OptionType optionType,
            MultiplayerOptions.MultiplayerOptionsAccessMode mode = MultiplayerOptions.MultiplayerOptionsAccessMode.CurrentMapOptions)
        {
            int num;

            MultiplayerOptions.Instance.GetOptionFromOptionType(optionType, mode).GetValue(out num);
            return(num);
        }
Beispiel #9
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;
     }
 }
Beispiel #11
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);
            }
        }
Beispiel #13
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();
        }
 public static MultiplayerOptions.MultiplayerOption CreateMultiplayerOption(
     MultiplayerOptions.OptionType optionType)
 {
     return(new MultiplayerOptions.MultiplayerOption(optionType));
 }
 private void CopyOptionFromOther(
     MultiplayerOptions.OptionType optionType,
     MultiplayerOptions.MultiplayerOption option)
 {
     this._multiplayerOptions[(int)optionType] = option;
 }
 public MultiplayerOptions.MultiplayerOption GetOptionFromOptionType(
     MultiplayerOptions.OptionType optionType)
 {
     return(this._multiplayerOptions[(int)optionType]);
 }
 public void CreateOption(MultiplayerOptions.OptionType optionType) => this._multiplayerOptions[(int)optionType] = MultiplayerOptions.MultiplayerOption.CreateMultiplayerOption(optionType);
Beispiel #19
0
 public MultiplayerOptions.MultiplayerOption GetOption(
     MultiplayerOptions.OptionType optionType)
 {
     return(this._optionList.First <MultiplayerOptions.MultiplayerOption>((Func <MultiplayerOptions.MultiplayerOption, bool>)(x => x.OptionType == optionType)));
 }
Beispiel #20
0
 public static MultiplayerOptionsProperty GetOptionProperty(
     this MultiplayerOptions.OptionType optionType)
 {
     return((MultiplayerOptionsProperty)((IEnumerable <object>)optionType.GetType().GetField(optionType.ToString()).GetCustomAttributes(typeof(MultiplayerOptionsProperty), false)).Single <object>());
 }
Beispiel #21
0
 public static int GetMaximumValue(this MultiplayerOptions.OptionType optionType) => optionType.GetOptionProperty().BoundsMax;
 public void UpdateOptionValue(MultiplayerOptions.OptionType optionType, string value) => this._multiplayerOptions[(int)optionType].UpdateValue(value);
 public void UpdateOptionValue(MultiplayerOptions.OptionType optionType, bool value) => this._multiplayerOptions[(int)optionType].UpdateValue(value ? 1 : 0);
 public MultiplayerOptions.MultiplayerOption GetOptionFromOptionType(
     MultiplayerOptions.OptionType optionType,
     MultiplayerOptions.MultiplayerOptionsAccessMode mode = MultiplayerOptions.MultiplayerOptionsAccessMode.CurrentMapOptions)
 {
     return(this.GetContainer(mode).GetOptionFromOptionType(optionType));
 }