protected MegaloScriptModel(Variants.GameEngineVariant variantManager, Variants.GameEngineMegaloVariant variant)
        {
            Database      = variantManager.MegaloProtoSystem.GetMegaloDatabaseAsync(variantManager.GameBuild).Result;
            MegaloVariant = variant;

            var db = Database;

            UnionGroups           = new Collections.ActiveList <MegaloScriptUnionGroup>(db.Limits.UnionGroupsDesc);
            Values                = new Collections.ActiveList <MegaloScriptValueBase>(db.Limits.ScriptValuesDesc);
            VirtualTriggers       = new Collections.ActiveList <MegaloScriptVirtualTrigger>(db.Limits.VirtualTriggersDesc);
            TriggerExecutionOrder = new ObservableCollection <int>();

            Conditions     = new Collections.ActiveList <MegaloScriptCondition>(db.Limits.ConditionsDesc);
            Actions        = new Collections.ActiveList <MegaloScriptAction>(db.Limits.ActionsDesc);
            Triggers       = new Collections.ActiveList <MegaloScriptTrigger>(db.Limits.TriggersDesc);
            GameStatistics = new ObservableCollection <MegaloScriptGameStatistic>();
            #region Variable Sets
            GlobalVariables = new MegaloScriptModelVariableSet(Database, MegaloScriptVariableSet.Globals);
            PlayerVariables = new MegaloScriptModelVariableSet(Database, MegaloScriptVariableSet.Player);
            ObjectVariables = new MegaloScriptModelVariableSet(Database, MegaloScriptVariableSet.Object);
            TeamVariables   = new MegaloScriptModelVariableSet(Database, MegaloScriptVariableSet.Team);
            #endregion
            HudWidgets = new ObservableCollection <MegaloScriptHudWidget>();
            #region Trigger entry points
            InitializationTriggerIndex           = LocalInitializationTriggerIndex =
                HostMigrationTriggerIndex        = DoubleHostMigrationTriggerIndex =
                    ObjectDeathEventTriggerIndex =
                        LocalTriggerIndex        = PregameTriggerIndex =
                            IncidentTriggerIndex =
                                TypeExtensions.kNone;
            #endregion
            ObjectTypeReferences = new Collections.BitSet(db.Limits.MultiplayerObjectTypes.MaxCount);
            ObjectFilters        = new ObservableCollection <MegaloScriptObjectFilter>();
            CandySpawnerFilters  = new ObservableCollection <MegaloScriptGameObjectFilter>();
        }
        internal static MegaloScriptModel Create(Variants.GameEngineVariant variantManager, Variants.GameEngineMegaloVariant variant)
        {
            var gameBuild = variantManager.GameBuild;

            if (gameBuild.IsWithinSameBranch(Engine.EngineRegistry.EngineBranchHaloReach))
            {
                return(new Games.HaloReach.Megalo.Model.MegaloScriptModelHaloReach(variantManager,
                                                                                   variant as Games.HaloReach.RuntimeData.Variants.GameEngineMegaloVariantHaloReach));
            }

            if (gameBuild.IsWithinSameBranch(Engine.EngineRegistry.EngineBranchHalo4))
            {
                return(new Games.Halo4.Megalo.Model.MegaloScriptModelHalo4(variantManager,
                                                                           variant as Games.Halo4.RuntimeData.Variants.GameEngineMegaloVariantHalo4));
            }

            throw new KSoft.Debug.UnreachableException(gameBuild.ToDisplayString());
        }