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>(); }
/// <summary>Setup a newly created object in its respective list, with an optional existing id</summary> /// <typeparam name="T"></typeparam> /// <param name="list"></param> /// <param name="theObject"></param> /// <param name="id"></param> /// <returns></returns> protected static T CreateObjectPostprocess <T>(Collections.ActiveList <T> list, T theObject, int id = TypeExtensions.kNone) where T : MegaloScriptModelObject { if (id.IsNone()) { list.Add(theObject, out id); theObject.Id = id; } else { list.AddExplicit(theObject, id); } return(theObject); }
/// <summary>Setup a newly created object in its respective list, with an optional existing id</summary> /// <typeparam name="T"></typeparam> /// <param name="list"></param> /// <param name="obj"></param> /// <param name="id"></param> /// <returns></returns> protected T CreateObjectPostprocess <T>(Collections.ActiveList <T> list, T obj, int id = TypeExtensions.kNone) where T : MegaloScriptModelObject { if (id.IsNone()) { list.Add(obj, out id); obj.Id = id; } else { list.AddExplicit(obj, id); } return(obj); }