public override void Invoke(CancellationToken token) { OnBegin?.Invoke(); var tasks = new List <Task>(); for (var i = 0; i < Workers; i++) { tasks.Add(Task.Factory.StartNew(() => { foreach (var source in Sources.GetConsumingEnumerable()) { token.ThrowIfCancellationRequested(); foreach (var result in filter(source)) { Results.Add(result, token); OnInnerInterval?.Invoke(result); } OnInterval?.Invoke(source); } }, token)); } Task.WaitAll(tasks.ToArray()); Results.CompleteAdding(); OnFinish?.Invoke(); }
public override void Invoke(CancellationToken token) { OnBegin?.Invoke(); var box = new List <List <TItem> > { new List <TItem>() }; var idx = 0; foreach (var item in Sources.GetConsumingEnumerable()) { token.ThrowIfCancellationRequested(); OnInterval?.Invoke(item); box[idx].Add(item); if (box[idx].Count != Size) { continue; } Results.Add(box[idx].ToArray(), token); idx++; box.Add(new List <TItem>()); } if (box[idx].Any()) { Results.Add(box[idx].ToArray(), token); } Results.CompleteAdding(); OnFinish?.Invoke(); }
public void Start(bool reverse) { IsReversed = _hasBegunReversed = reverse; TimeLeft = Duration; Value = Percent = IsReversed ? 1f : 0f; IsActive = true; OnBegin?.Invoke(this); }
public void Begin() { if (IsActive) { return; } IsActive = true; OnBegin?.Invoke(this, EventArgs.Empty); BeginImpl(); }
private void Initialize(Scene scene) { if (Initialized) { return; } Initialized = true; WrappedScene.Begin(); scene.RendererList.Add(Renderer); Renderer.Alloc(); OnBegin?.Invoke(WrappedScene); }
public void AwaitKeyPress() { OnBegin?.Invoke(); if (!string.IsNullOrWhiteSpace(Title)) { Console.Title = Title; } Console.BackgroundColor = Background; Console.Clear(); foreach (var group in Groups) { if (!string.IsNullOrWhiteSpace(group.Caption)) { Console.WriteLine(); Console.WriteLine(new string(' ', Indent) + group.Caption); } Console.WriteLine(); foreach (var item in group.Items) { if (!string.IsNullOrWhiteSpace(item.Caption)) { Console.WriteLine(new string(' ', Indent) + item.Caption.Replace("{key}", item.Key.ToString())); } } } Console.WriteLine(); Console.WriteLine(" " + new string('┈', Console.BufferWidth - 2) + " "); EndingCursorTop = Console.CursorTop; while (!exit) { var key = Console.ReadKey(true).Key; var menuItem = Groups.SelectMany(g => g.Items).SingleOrDefault(i => i.Key == key); if (menuItem != null) { if (menuItem.OnSelection == null) { exit = true; } else { menuItem.OnSelection.Invoke(); } } } OnEnd?.Invoke(); }
protected virtual void Initialize() { // systems initialization Debug.Console.Start(); OnBegin?.Invoke(); OnBegin = null; SwitchScene(StartSceneName); UpdateCurrentScene(); // late systems initialization Util.Tween.Tweener.Instance.Start(); }
public void Subscribe(EventHandler <TResponse> value) { OnData += value; Task.Run(async() => { using NamedPipeClientStream stream = new NamedPipeClientStream(pipeName); using StreamReader reader = new StreamReader(stream); using StreamWriter writer = new StreamWriter(stream); await stream.ConnectAsync(5000, _externCancellationToken).ConfigureAwait(false); await writer.WriteLineAsync(request.ToJson()).ConfigureAwait(false); await writer.FlushAsync().ConfigureAwait(false); stream.WaitForPipeDrain(); while (!_externCancellationToken.IsCancellationRequested && !unsubscribeToken.IsCancellationRequested) { string responsJson = await reader.ReadLineAsync().ConfigureAwait(false); StreamlabsOBSResponse response = JsonConvert.DeserializeObject <StreamlabsOBSResponse>(responsJson); response.JsonResponse = responsJson; if (response.Results.Value <string>("_type").Equals("SUBSCRIPTION")) { OnBegin?.Invoke(this, response); } else if (response.Results.Value <string>("_type").Equals("EVENT")) { StreamlabsOBSEvent eventData = response.GetResultFirstOrDefault <StreamlabsOBSEvent>(); OnEvent?.Invoke(this, eventData); if (typeof(TResponse).IsAssignableFrom(typeof(StreamlabsOBSEvent))) { OnData?.Invoke(this, eventData as TResponse); } else { OnData?.Invoke(this, eventData.GetDataFirstOrDefault <TResponse>()); } } else { OnUnsupported?.Invoke(this, responsJson); } } }, _externCancellationToken); }
/// <summary> /// Initializes a session object with a custom Begin performative. /// </summary> /// <param name="connection">The connection in which the session will be created.</param> /// <param name="begin">The Begin performative to be sent to the remote peer.</param> /// <param name="onBegin">The callback to invoke when a begin is received from peer.</param> public Session(Connection connection, Begin begin, OnBegin onBegin) { this.connection = connection; this.onBegin = onBegin; this.handleMax = begin.HandleMax; this.nextOutgoingId = begin.NextOutgoingId; this.incomingWindow = defaultWindowSize; this.outgoingWindow = begin.IncomingWindow; this.incomingDeliveryId = uint.MaxValue; this.localLinks = new Link[1]; this.remoteLinks = new Link[1]; this.incomingList = new LinkedList(); this.outgoingList = new LinkedList(); this.channel = connection.AddSession(this); this.state = State.BeginSent; this.SendBegin(begin); }
/// <summary> /// Starts the game or round. Initializes the GameFlowHandler to begin the round. /// </summary> public virtual void Begin() { if (Game.RoundNumber == 0) { LastTurn = new GameBeginningTurn(PlayerOnTurn); } else { LastTurn = new GameTurn(PlayerOnTurn); } RedrawToPlayersPerspective(); OnBegin?.Invoke(); var factory = new GameBotFactory(); var bot = factory.CreateFromGame(Game, PlayerOnTurn, GameBotType.MonteCarloTreeSearchBot); //bot.FindBestMove(); }
public Exception Run(CancellationToken token, string logFile) { OnBegin?.Invoke(); // init logger Logger = new Logger.Logger(); if (!string.IsNullOrEmpty(logFile)) { Logger.AddHook(new FileHook(logFile)); } // Bind Vtn = new Transistor(Bind(VtnString, (VtnThreshold, VtnSigma, VtnNumberOfSigma), Sigma)); Vtp = new Transistor(Bind(VtpString, (VtpThreshold, VtpSigma, VtpNumberOfSigma), Sigma)); var rt = Do(token); OnFinish?.Invoke(); return(rt); }
public void Begin() { lives = 3; foreach (Image im in hearts) { im.color = heartCol; } skinnedMesh.materials[1].mainTexture = idle; skinnedMesh.materials[0].color = skinCol; score = 0; DisplayScore(); // if (mode == Difficulty.Easy) { // StartCoroutine(SpawnConstantly(()=>minSpeed + Mathf.Log(1+.01f*Time.time), // ()=>minDelay + (maxDelay-minDelay)/(1+.01f*Time.time))); // } else if (mode == Difficulty.Hard) { StartCoroutine(SpawnConstantly(() => minSpeed + (float)Math.Log(1 + Math.Sqrt(.01 * score)), () => minDelay + (maxDelay - minDelay) / (1 + (float)Math.Sqrt(.01f * score)))); // } OnBegin.Invoke(); }
//Public Methods: public void FireBegin() { Active = true; OnBegin?.Invoke(); }
private void BeginRound(object sender, EventArgs e) { OnBegin?.Invoke(); }
IEnumerator<ITask> OnBeginHandler(OnBegin onBegin) { if (onBegin.TeamForm == _TeamForm) { CreateService(SimpleDashboard.Proxy.Contract.Identifier, Microsoft.Robotics.Simulation.Partners.CreateEntityPartner("http://localhost/simpledashboard")); Thread.Sleep(1000); CreateService(ImageProcessingResult.Contract.Identifier, Microsoft.Robotics.Simulation.Partners.CreateEntityPartner("http://localhost/imageprocessingresult")); } yield break; }
public override void WriteData(ESPWriter writer) { if (EditorID != null) { EditorID.WriteBinary(writer); } if (Data != null) { Data.WriteBinary(writer); } if (Location1 != null) { Location1.WriteBinary(writer); } if (Location2 != null) { Location2.WriteBinary(writer); } if (Schedule != null) { Schedule.WriteBinary(writer); } if (Target1 != null) { Target1.WriteBinary(writer); } if (Conditions != null) { foreach (var item in Conditions) { item.WriteBinary(writer); } } if (IdleFlags != null) { IdleFlags.WriteBinary(writer); } if (IdleCount != null) { IdleCount.WriteBinary(writer); } if (IdleTimerSetting != null) { IdleTimerSetting.WriteBinary(writer); } if (IdleAnimations != null) { IdleAnimations.WriteBinary(writer); } if (Unused != null) { Unused.WriteBinary(writer); } if (CombatStyle != null) { CombatStyle.WriteBinary(writer); } if (EatMarker != null) { EatMarker.WriteBinary(writer); } if (EscortDistance != null) { EscortDistance.WriteBinary(writer); } if (FollowDistance_StartLocation_TriggerRadius != null) { FollowDistance_StartLocation_TriggerRadius.WriteBinary(writer); } if (PatrolIsRepeatable != null) { PatrolIsRepeatable.WriteBinary(writer); } if (UseWeaponData != null) { UseWeaponData.WriteBinary(writer); } if (Target2 != null) { Target2.WriteBinary(writer); } if (UseItemMarker != null) { UseItemMarker.WriteBinary(writer); } if (AmbushMarker != null) { AmbushMarker.WriteBinary(writer); } if (DialogData != null) { DialogData.WriteBinary(writer); } WriteDummyIgnore(writer); if (OnBegin != null) { OnBegin.WriteBinary(writer); } if (OnEnd != null) { OnEnd.WriteBinary(writer); } if (OnChange != null) { OnChange.WriteBinary(writer); } }
public virtual void Begin() { OnBegin?.Invoke(); }
internal BehaviorStage(OnBegin begin) : this() { BeginEvent += begin; }
public void Begin() { isActive = true; startedAt = DateTime.Now; OnBegin.Raise(Name); }
public override void ReadDataXML(XElement ele, ElderScrollsPlugin master) { XElement subEle; if (ele.TryPathTo("EditorID", false, out subEle)) { if (EditorID == null) { EditorID = new SimpleSubrecord <String>(); } EditorID.ReadXML(subEle, master); } if (ele.TryPathTo("Data", false, out subEle)) { if (Data == null) { Data = new PackageData(); } Data.ReadXML(subEle, master); } if (ele.TryPathTo("Location1", false, out subEle)) { if (Location1 == null) { Location1 = new PackageLocation(); } Location1.ReadXML(subEle, master); } if (ele.TryPathTo("Location2", false, out subEle)) { if (Location2 == null) { Location2 = new PackageLocation(); } Location2.ReadXML(subEle, master); } if (ele.TryPathTo("Schedule", false, out subEle)) { if (Schedule == null) { Schedule = new PackageScheduleData(); } Schedule.ReadXML(subEle, master); } if (ele.TryPathTo("Target1", false, out subEle)) { if (Target1 == null) { Target1 = new PackageTarget(); } Target1.ReadXML(subEle, master); } if (ele.TryPathTo("Conditions", false, out subEle)) { if (Conditions == null) { Conditions = new List <Condition>(); } foreach (XElement e in subEle.Elements()) { Condition tempCTDA = new Condition(); tempCTDA.ReadXML(e, master); Conditions.Add(tempCTDA); } } if (ele.TryPathTo("Idle/Flags", false, out subEle)) { if (IdleFlags == null) { IdleFlags = new SimpleSubrecord <PackageIdleFlags>(); } IdleFlags.ReadXML(subEle, master); } if (ele.TryPathTo("Idle/Count", false, out subEle)) { if (IdleCount == null) { IdleCount = new SimpleSubrecord <Byte>(); } IdleCount.ReadXML(subEle, master); } if (ele.TryPathTo("Idle/TimerSetting", false, out subEle)) { if (IdleTimerSetting == null) { IdleTimerSetting = new SimpleSubrecord <Single>(); } IdleTimerSetting.ReadXML(subEle, master); } if (ele.TryPathTo("Idle/Animations", false, out subEle)) { if (IdleAnimations == null) { IdleAnimations = new FormArray(); } IdleAnimations.ReadXML(subEle, master); } if (ele.TryPathTo("Unused", false, out subEle)) { if (Unused == null) { Unused = new SimpleSubrecord <Byte[]>(); } Unused.ReadXML(subEle, master); } if (ele.TryPathTo("CombatStyle", false, out subEle)) { if (CombatStyle == null) { CombatStyle = new RecordReference(); } CombatStyle.ReadXML(subEle, master); } if (ele.TryPathTo("EatMarker", false, out subEle)) { if (EatMarker == null) { EatMarker = new SubMarker(); } EatMarker.ReadXML(subEle, master); } if (ele.TryPathTo("EscortDistance", false, out subEle)) { if (EscortDistance == null) { EscortDistance = new SimpleSubrecord <UInt32>(); } EscortDistance.ReadXML(subEle, master); } if (ele.TryPathTo("FollowDistance_StartLocation_TriggerRadius", false, out subEle)) { if (FollowDistance_StartLocation_TriggerRadius == null) { FollowDistance_StartLocation_TriggerRadius = new SimpleSubrecord <UInt32>(); } FollowDistance_StartLocation_TriggerRadius.ReadXML(subEle, master); } if (ele.TryPathTo("PatrolIsRepeatable", false, out subEle)) { if (PatrolIsRepeatable == null) { PatrolIsRepeatable = new SimpleSubrecord <NoYesByte>(); } PatrolIsRepeatable.ReadXML(subEle, master); } if (ele.TryPathTo("UseWeaponData", false, out subEle)) { if (UseWeaponData == null) { UseWeaponData = new PackageUseWeaponData(); } UseWeaponData.ReadXML(subEle, master); } if (ele.TryPathTo("Target2", false, out subEle)) { if (Target2 == null) { Target2 = new PackageTarget(); } Target2.ReadXML(subEle, master); } if (ele.TryPathTo("UseItemMarker", false, out subEle)) { if (UseItemMarker == null) { UseItemMarker = new SubMarker(); } UseItemMarker.ReadXML(subEle, master); } if (ele.TryPathTo("AmbushMarker", false, out subEle)) { if (AmbushMarker == null) { AmbushMarker = new SubMarker(); } AmbushMarker.ReadXML(subEle, master); } if (ele.TryPathTo("DialogData", false, out subEle)) { if (DialogData == null) { DialogData = new PackageDialogData(); } DialogData.ReadXML(subEle, master); } if (ele.TryPathTo("DummyIgnore", false, out subEle)) { if (DummyIgnore == null) { DummyIgnore = new PackageLocation(); } DummyIgnore.ReadXML(subEle, master); } if (ele.TryPathTo("OnBegin", false, out subEle)) { if (OnBegin == null) { OnBegin = new PackageEvent(); } OnBegin.ReadXML(subEle, master); } if (ele.TryPathTo("OnEnd", false, out subEle)) { if (OnEnd == null) { OnEnd = new PackageEvent(); } OnEnd.ReadXML(subEle, master); } if (ele.TryPathTo("OnChange", false, out subEle)) { if (OnChange == null) { OnChange = new PackageEvent(); } OnChange.ReadXML(subEle, master); } }
public override void WriteDataXML(XElement ele, ElderScrollsPlugin master) { XElement subEle; if (EditorID != null) { ele.TryPathTo("EditorID", true, out subEle); EditorID.WriteXML(subEle, master); } if (Data != null) { ele.TryPathTo("Data", true, out subEle); Data.WriteXML(subEle, master); } if (Location1 != null) { ele.TryPathTo("Location1", true, out subEle); Location1.WriteXML(subEle, master); } if (Location2 != null) { ele.TryPathTo("Location2", true, out subEle); Location2.WriteXML(subEle, master); } if (Schedule != null) { ele.TryPathTo("Schedule", true, out subEle); Schedule.WriteXML(subEle, master); } if (Target1 != null) { ele.TryPathTo("Target1", true, out subEle); Target1.WriteXML(subEle, master); } if (Conditions != null) { ele.TryPathTo("Conditions", true, out subEle); List <string> xmlNames = new List <string> { "Condition" }; int i = 0; foreach (var entry in Conditions) { i = i % xmlNames.Count(); XElement newEle = new XElement(xmlNames[i]); entry.WriteXML(newEle, master); subEle.Add(newEle); i++; } } if (IdleFlags != null) { ele.TryPathTo("Idle/Flags", true, out subEle); IdleFlags.WriteXML(subEle, master); } if (IdleCount != null) { ele.TryPathTo("Idle/Count", true, out subEle); IdleCount.WriteXML(subEle, master); } if (IdleTimerSetting != null) { ele.TryPathTo("Idle/TimerSetting", true, out subEle); IdleTimerSetting.WriteXML(subEle, master); } if (IdleAnimations != null) { ele.TryPathTo("Idle/Animations", true, out subEle); IdleAnimations.WriteXML(subEle, master); } if (Unused != null) { ele.TryPathTo("Unused", true, out subEle); Unused.WriteXML(subEle, master); } if (CombatStyle != null) { ele.TryPathTo("CombatStyle", true, out subEle); CombatStyle.WriteXML(subEle, master); } if (EatMarker != null) { ele.TryPathTo("EatMarker", true, out subEle); EatMarker.WriteXML(subEle, master); } if (EscortDistance != null) { ele.TryPathTo("EscortDistance", true, out subEle); EscortDistance.WriteXML(subEle, master); } if (FollowDistance_StartLocation_TriggerRadius != null) { ele.TryPathTo("FollowDistance_StartLocation_TriggerRadius", true, out subEle); FollowDistance_StartLocation_TriggerRadius.WriteXML(subEle, master); } if (PatrolIsRepeatable != null) { ele.TryPathTo("PatrolIsRepeatable", true, out subEle); PatrolIsRepeatable.WriteXML(subEle, master); } if (UseWeaponData != null) { ele.TryPathTo("UseWeaponData", true, out subEle); UseWeaponData.WriteXML(subEle, master); } if (Target2 != null) { ele.TryPathTo("Target2", true, out subEle); Target2.WriteXML(subEle, master); } if (UseItemMarker != null) { ele.TryPathTo("UseItemMarker", true, out subEle); UseItemMarker.WriteXML(subEle, master); } if (AmbushMarker != null) { ele.TryPathTo("AmbushMarker", true, out subEle); AmbushMarker.WriteXML(subEle, master); } if (DialogData != null) { ele.TryPathTo("DialogData", true, out subEle); DialogData.WriteXML(subEle, master); } if (DummyIgnore != null) { ele.TryPathTo("DummyIgnore", true, out subEle); DummyIgnore.WriteXML(subEle, master); } if (OnBegin != null) { ele.TryPathTo("OnBegin", true, out subEle); OnBegin.WriteXML(subEle, master); } if (OnEnd != null) { ele.TryPathTo("OnEnd", true, out subEle); OnEnd.WriteXML(subEle, master); } if (OnChange != null) { ele.TryPathTo("OnChange", true, out subEle); OnChange.WriteXML(subEle, master); } }
public void Begin() { OnBegin?.Invoke(); }
public void Begin() { state = ActionState.Running; OnBegin.Call(this); }
public override void ReadData(ESPReader reader, long dataEnd) { while (reader.BaseStream.Position < dataEnd) { string subTag = reader.PeekTag(); switch (subTag) { case "EDID": if (EditorID == null) { EditorID = new SimpleSubrecord <String>(); } EditorID.ReadBinary(reader); break; case "PKDT": if (Data == null) { Data = new PackageData(); } Data.ReadBinary(reader); break; case "PLDT": if (Location1 == null) { Location1 = new PackageLocation(); } Location1.ReadBinary(reader); break; case "PLD2": if (Location2 == null) { Location2 = new PackageLocation(); } Location2.ReadBinary(reader); break; case "PSDT": if (Schedule == null) { Schedule = new PackageScheduleData(); } Schedule.ReadBinary(reader); break; case "PTDT": if (Target1 == null) { Target1 = new PackageTarget(); } Target1.ReadBinary(reader); break; case "CTDA": if (Conditions == null) { Conditions = new List <Condition>(); } Condition tempCTDA = new Condition(); tempCTDA.ReadBinary(reader); Conditions.Add(tempCTDA); break; case "IDLF": if (IdleFlags == null) { IdleFlags = new SimpleSubrecord <PackageIdleFlags>(); } IdleFlags.ReadBinary(reader); break; case "IDLC": if (IdleCount == null) { IdleCount = new SimpleSubrecord <Byte>(); } IdleCount.ReadBinary(reader); break; case "IDLT": if (IdleTimerSetting == null) { IdleTimerSetting = new SimpleSubrecord <Single>(); } IdleTimerSetting.ReadBinary(reader); break; case "IDLA": if (IdleAnimations == null) { IdleAnimations = new FormArray(); } IdleAnimations.ReadBinary(reader); break; case "IDLB": if (Unused == null) { Unused = new SimpleSubrecord <Byte[]>(); } Unused.ReadBinary(reader); break; case "CNAM": if (CombatStyle == null) { CombatStyle = new RecordReference(); } CombatStyle.ReadBinary(reader); break; case "PKED": if (EatMarker == null) { EatMarker = new SubMarker(); } EatMarker.ReadBinary(reader); break; case "PKE2": if (EscortDistance == null) { EscortDistance = new SimpleSubrecord <UInt32>(); } EscortDistance.ReadBinary(reader); break; case "PKFD": if (FollowDistance_StartLocation_TriggerRadius == null) { FollowDistance_StartLocation_TriggerRadius = new SimpleSubrecord <UInt32>(); } FollowDistance_StartLocation_TriggerRadius.ReadBinary(reader); break; case "PKPT": if (PatrolIsRepeatable == null) { PatrolIsRepeatable = new SimpleSubrecord <NoYesByte>(); } PatrolIsRepeatable.ReadBinary(reader); break; case "PKW3": if (UseWeaponData == null) { UseWeaponData = new PackageUseWeaponData(); } UseWeaponData.ReadBinary(reader); break; case "PTD2": if (Target2 == null) { Target2 = new PackageTarget(); } Target2.ReadBinary(reader); break; case "PUID": if (UseItemMarker == null) { UseItemMarker = new SubMarker(); } UseItemMarker.ReadBinary(reader); break; case "PKAM": if (AmbushMarker == null) { AmbushMarker = new SubMarker(); } AmbushMarker.ReadBinary(reader); break; case "PKDD": if (DialogData == null) { DialogData = new PackageDialogData(); } DialogData.ReadBinary(reader); break; case "DUMY": if (DummyIgnore == null) { DummyIgnore = new PackageLocation(); } DummyIgnore.ReadBinary(reader); break; case "POBA": if (OnBegin == null) { OnBegin = new PackageEvent(); } OnBegin.ReadBinary(reader); break; case "POEA": if (OnEnd == null) { OnEnd = new PackageEvent(); } OnEnd.ReadBinary(reader); break; case "POCA": if (OnChange == null) { OnChange = new PackageEvent(); } OnChange.ReadBinary(reader); break; default: throw new Exception(); } } }