public static ScriptAttributes Clone(IScriptAttributes toClone) { ScriptAttributes s = new ScriptAttributes(toClone.Id); s.TimerIntervalMax = toClone.TimerIntervalMax; s.TimerIntervalMin = toClone.TimerIntervalMin; s.NextScripts = toClone.NextScripts; s.ScriptsToFinishPriorThis = toClone.ScriptsToFinishPriorThis; s.InitModel = toClone.InitModel; s.CtorParams = toClone.CtorParams; return(s); }
public bool Start(IScript script) { if (Script.HasFinished) { IScriptAttributes s = ScriptAttributes.Clone(script.Attributes); Script = Managers.AdvancedScriptManager.CreateInstance <IScript>(script.GetType(), s.CtorParams); Script.Attributes = s; } bool b = Script.CanBeStarted(); if (b) { Script.Start(); } return(b); }
//MAIN CTOR public void AddScript(Type typeOfIScript, IScriptAttributes attrib) { if (!typeOfIScript.GetInterfaces().Contains(typeof(IScript))) { var msg = $"{nameof(AddScript)}(type, attrib): parameter does not implement {nameof(IScript)} interface: {typeOfIScript}"; throw new ArgumentException(msg); } IScript sc = CreateInstance <IScript>(typeOfIScript, attrib.CtorParams); sc.Attributes = attrib; AddNewScriptToList(sc, attrib.Id); Logger.LogDebug( nameof(AdvancedScriptManager), nameof(AddScript), $"id: {sc.Attributes.Id}: script added."); }