Example #1
0
        internal int FromIndexName(MegaloScriptValueIndexTarget target, string name)
        {
            int id = TypeExtensionsBlam.IndexOfByPropertyNotFoundResult;

            switch (target)
            {
            case MegaloScriptValueIndexTarget.ObjectType:           id = FindNameIndex(ObjectTypeList.Types, name); break;

            case MegaloScriptValueIndexTarget.Name:                         id = FindNameIndex(Names, name); break;

            case MegaloScriptValueIndexTarget.Sound:                        id = FindNameIndex(Sounds, name); break;

            case MegaloScriptValueIndexTarget.Incident:                     id = FindNameIndex(Incidents, name); break;

            case MegaloScriptValueIndexTarget.HudWidgetIcon:        id = FindNameIndex(HudWidgetIcons, name); break;

            case MegaloScriptValueIndexTarget.GameEngineIcon:       id = FindNameIndex(GameEngineIcons, name); break;

            case MegaloScriptValueIndexTarget.Medal:                        id = FindNameIndex(Medals, name); break;

            case MegaloScriptValueIndexTarget.Ordnance:                     id = FindNameIndex(OrdnanceList.Sets, name); break;

            default: throw new KSoft.Debug.UnreachableException(target.ToString());
            }

            if (id == TypeExtensionsBlam.IndexOfByPropertyNotFoundResult)
            {
                throw new KeyNotFoundException(string.Format("Couldn't find an {0} entry named {1}",
                                                             target, name));
            }

            return(id);
        }
Example #2
0
        internal int GetIndexTargetBitLength(MegaloScriptValueIndexTarget target, MegaloScriptValueIndexTraits traits)
        {
            // use the index bit length (true) or the count bit length (false)
            bool use_index = traits != MegaloScriptValueIndexTraits.Pointer;

            switch (target)
            {
                #region Scripting
            case MegaloScriptValueIndexTarget.Trigger:                      return(Triggers.GetBitLength(use_index));

                #endregion
                #region Static
            case MegaloScriptValueIndexTarget.ObjectType:           return(MultiplayerObjectTypes.IndexBitLength);

            case MegaloScriptValueIndexTarget.Name:                         return(MegaloStringIds.IndexBitLength);

            case MegaloScriptValueIndexTarget.Sound:                        return(MegaloEngineSounds.IndexBitLength);

            case MegaloScriptValueIndexTarget.Incident:                     return(GameIncidentTypes.IndexBitLength);

            case MegaloScriptValueIndexTarget.HudWidgetIcon:        return(MegaloHudWidgetIcons.IndexBitLength);

            case MegaloScriptValueIndexTarget.GameEngineIcon:       return(GameEngineIcons.IndexBitLength);

            case MegaloScriptValueIndexTarget.Medal:                        return(GameMedals.IndexBitLength);

            case MegaloScriptValueIndexTarget.Ordnance:                     return(GameOrdnanceTypes.IndexBitLength);

                #endregion
                #region Variant
            case MegaloScriptValueIndexTarget.LoadoutPalette:       return(LoadoutPalettes.GetBitLength(use_index));

            case MegaloScriptValueIndexTarget.Option:                       return(UserDefinedOptions.GetBitLength(use_index));

            case MegaloScriptValueIndexTarget.String:                       return(VariantStrings.GetBitLength(use_index));

            case MegaloScriptValueIndexTarget.PlayerTraits:         return(PlayerTraits.GetBitLength(use_index));

            case MegaloScriptValueIndexTarget.Statistic:            return(GameStatistics.GetBitLength(use_index));

            case MegaloScriptValueIndexTarget.Widget:                       return(HudWidgets.GetBitLength(use_index));

            case MegaloScriptValueIndexTarget.ObjectFilter:         return(ObjectFilters.GetBitLength(use_index));

                #endregion

            default: throw new KSoft.Debug.UnreachableException(target.ToString());
            }
        }
Example #3
0
        internal string ToIndexName(MegaloScriptValueIndexTarget target, int index)
        {
            switch (target)
            {
            case MegaloScriptValueIndexTarget.ObjectType:           return(ObjectTypeList.Types[index].Name);

            case MegaloScriptValueIndexTarget.Name:                         return(Names[index].Name);

            case MegaloScriptValueIndexTarget.Sound:                        return(Sounds[index].Name);

            case MegaloScriptValueIndexTarget.Incident:                     return(Incidents[index].Name);

            case MegaloScriptValueIndexTarget.HudWidgetIcon:        return(HudWidgetIcons[index].Name);

            case MegaloScriptValueIndexTarget.GameEngineIcon:       return(GameEngineIcons[index].Name);

            case MegaloScriptValueIndexTarget.Medal:                        return(Medals[index].Name);

            case MegaloScriptValueIndexTarget.Ordnance:                     return(OrdnanceList.Sets[index].Name);

            default: throw new KSoft.Debug.UnreachableException(target.ToString());
            }
        }