private void HandleStatusChange(Transform source, Transform target, StatusEvent message, float value) { if ((message == StatusEvent.Death) && (source == _parentTransform)) { gameObject.SetActive(false); } }
public StatusEvent Insert(StatusEvent statusEvent) { _db.StatusEvents.Add(statusEvent); _db.SaveChanges(); return statusEvent; }
public StatusEvent Edit(StatusEvent statusEvent) { _db.Entry(statusEvent).State = EntityState.Modified; _db.SaveChanges(); return statusEvent; }
public static StatusEventDTO StatusEventToDto(StatusEvent statusEvent) { return new StatusEventDTO { StatusEventId = statusEvent.StatusEventId, Name = statusEvent.Name, }; }
private void HandleStatusEvent(Transform source, Transform target, StatusEvent message, float value) { if ((target == _parentTransform) && (message == StatusEvent.SetHealthBarValue)) { if (value <= 0.0f) { gameObject.SetActive(false); } else { _barTransform.localScale = new Vector3(value, 1.0f, 1.0f); } } }
private void RunReaderSenderProcessCallback(string _filePath, string _idxFilePath, CancellationToken token) { ulong ipport; int n_bytes = 0, size = 0; int hashedID = 0; long timeoffset = 0, waitTime = 0, nowTime = 0, time = 0; int lastTimeStatusS = 0, timeStatusS = 0; // Increase timers resolution WinAPI.WinAPITime.TimeBeginPeriod(1); // Open file using (FileStream file = new FileStream(filePath, FileMode.Open, FileAccess.Read)) { if (has2UpdatePosition) { file.Seek(newPosition, SeekOrigin.Begin); has2UpdatePosition = false; resetTimeOffsetRequired = true; } while (!token.IsCancellationRequested) { // Paused if (CurrentState == State.Paused) { Thread.Sleep(500); } else { if ((n_bytes = file.Read(buffer, 0, HelperTools.headerSize)) == HelperTools.headerSize) { // Get fields replayTime = time = BitConverter.ToInt64(buffer, 0); hashedID = BitConverter.ToInt32(buffer, 8); ipport = BitConverter.ToUInt64(buffer, 12); size = BitConverter.ToInt32(buffer, 20); // Update time in secs timeStatusS = (int)(replayTime / 1000_000); // Read Payload n_bytes = file.Read(buffer, 0, size); nowTime = HelperTools.GetLocalMicrosTime(); if (resetTimeOffsetRequired) { timeoffset = nowTime - time; waitTime = 0; resetTimeOffsetRequired = false; } else { nowTime -= timeoffset; waitTime = time - nowTime; if (waitTime > 1000) // 1ms { Thread.Sleep((int)(waitTime / 1000)); } } // Send Send(ipport, hashedID, buffer, 0, n_bytes); // Update Progress if (timeStatusS != lastTimeStatusS) { Task.Run(() => ProgressEvent?.Invoke(timeStatusS)); lastTimeStatusS = timeStatusS; } if (has2UpdatePosition) { file.Seek(newPosition, SeekOrigin.Begin); has2UpdatePosition = false; resetTimeOffsetRequired = true; } } else { // End of File cancelSource.Cancel(); // Update Stop Status CurrentState = State.Stoped; StatusEvent?.Invoke(CurrentState); foreach (var k in _dataRate.Keys.ToList()) { _dataRate[k] = 0; } DataRateEvent?.Invoke(_dataRate); // rewind Seek(0); eventTimer.Dispose(); eventTimer = null; ProgressEvent?.Invoke(0); } } } } WinAPI.WinAPITime.TimeEndPeriod(1); }
public void SubscribeOnHealthDown(StatusEvent e) { OnHealthDown += e; }
//Event Subsciption public void SubscribeOnHealthZero(StatusEvent e) { OnHealthZero += e; }
public override void OnStatus(StatusEvent e) { currentState.OurEnergy = e.Status.Energy; currentState.OurVelocity = e.Status.Velocity; base.OnStatus(e); }
protected virtual void OnStatusEvent(StravaServiceEventArgs e) { StatusEvent?.Invoke(this, e); }
public override void HardpointsEvent(StatusEvent e) { }
public abstract void Execute(StatusEvent eventInfo);
protected void WriteStatus(string text, params object[] args) { text = string.Format(text, args); StatusEvent?.Invoke(this, new InterfaceStatusEvent(text)); }
public void Remove(StatusEvent statusEvent) { _db.Entry(statusEvent).State = EntityState.Deleted; _db.SaveChanges(); }
public override void OnStatus(StatusEvent e) => OnStatusModule.Action(this, e);
private static void Timer_StatusUpdate(object sender, StatusEvent e) { WriteConsoleStatus(e.Message); }
private void GameStatusCallback(StatusEvent obj) { JournalSystemRunning = obj.IsRunning; }
protected void OnStatusUpdate(StatusEvent e) { StatusUpdate?.Invoke(this, e); }
public override void ShieldsEvent(StatusEvent e) { }
void FireEvent(ImportEvent evnt) { ThreadAssist.ProxyToMain(() => { StatusEvent?.Invoke(evnt); }); }
public void ShowMirror() { Log.Logger.Debug("Attempting to open mirror"); if (Mutex.TryOpenExisting("OnlyMMirrorMutex", out var _)) { Log.Logger.Debug("OnlyMMirrorMutex mutex exists"); return; } var folder = Path.GetDirectoryName(System.Reflection.Assembly.GetEntryAssembly().Location); if (folder == null) { Log.Logger.Error("Could not get assembly folder"); return; } const string mirrorExeFileName = "OnlyMMirror.exe"; var mirrorExePath = Path.Combine(folder, mirrorExeFileName); if (!File.Exists(mirrorExePath)) { Log.Logger.Error($"Could not find {mirrorExeFileName}"); return; } Log.Logger.Debug($"Mirror path = {mirrorExePath}"); var mainWindow = Application.Current.MainWindow; if (mainWindow == null) { Log.Logger.Error("Could not get main window"); return; } var handle = new WindowInteropHelper(mainWindow).Handle; var onlyMMonitor = _monitorsService.GetMonitorForWindowHandle(handle); var mediaMonitor = _monitorsService.GetSystemMonitor(_optionsService.MediaMonitorId); if (onlyMMonitor == null || mediaMonitor == null) { Log.Logger.Debug("Cannot get monitor"); return; } if (mediaMonitor.MonitorId.Equals(onlyMMonitor.MonitorId)) { Log.Logger.Error("Cannot display mirror since OnlyM and Media window share a monitor"); return; } Log.Logger.Debug($"Main monitor = {onlyMMonitor.Monitor.DeviceName}"); Log.Logger.Debug($"Media monitor = {mediaMonitor.Monitor.DeviceName}"); StatusEvent?.Invoke(this, new WebBrowserProgressEventArgs { Description = Properties.Resources.LAUNCHING_MIRROR }); try { var zoomStr = _optionsService.MirrorZoom.ToString(CultureInfo.InvariantCulture); var hotKey = _optionsService.MirrorHotKey; var commandLineArgs = $"{onlyMMonitor.Monitor.DeviceName} {mediaMonitor.Monitor.DeviceName} {zoomStr} {hotKey}"; Log.Logger.Debug($"Starting mirror exe with args = {commandLineArgs}"); _mirrorProcess = new Process { StartInfo = { FileName = mirrorExePath, Arguments = commandLineArgs, }, EnableRaisingEvents = true, }; _mirrorProcess.Exited += HandleMirrorProcessExited; if (!_mirrorProcess.Start()) { Log.Logger.Error("Could not launch mirror"); } } catch (Exception ex) { Log.Logger.Error(ex, "Could not launch mirror"); } finally { Task.Delay(1000).ContinueWith(t => { DispatcherHelper.CheckBeginInvokeOnUI(() => { StatusEvent?.Invoke(this, new WebBrowserProgressEventArgs { Description = string.Empty }); }); }); } }
public override void OnStatus(StatusEvent evnt) { status = evnt.Status; }
/// <summary> /// This method is called by the game before each turn with the current status of our robot. /// </summary> /// <param name="statusEvent">The status event containing status data for our robot.</param> public override void OnStatus(StatusEvent statusEvent) { // 'newTarget' is used for selecting our new target to fire at. // Set this to null here, which means that we have no target... yet! ScannedRobotData newTarget = null; // Prepara a list for containing all scanned robot data. List <ScannedRobotData> currentScanData = new List <ScannedRobotData>(); // Add scanned robot data that is not too old. When data is more than 360 / 45 degrees = 8 turns old, // our radar should retrieve new information about a particular robot, unless it has died or is // out of the scan radius (1200 units). Anyways, the robot will probably have moved far ways since then. foreach (ScannedRobotData robotData in scannedRobotData.Values) { // Add entry if the the delta time (scanned event time - status event time) is less than or equal to 8 turns if (statusEvent.Time - robotData.time <= 8) { currentScanData.Add(robotData); } } // Now, make a copy of current scan data that should contain target candidates List <ScannedRobotData> targetCandidates = new List <ScannedRobotData>(currentScanData); // Prepare a new list for containing scanned robot data, but only with robots List <ScannedRobotData> newCurrentScanData = new List <ScannedRobotData>(); // Add all target candidates that are inside our sentry robot's attack range as we // will not be able to harm robots outside this range with our gun fire (is a game rule). foreach (ScannedRobotData robotData in currentScanData) { // Add robot data if its location is inside the sentry attack range if (IsInsideSentryAttackRange(robotData.x, robotData.y)) { newCurrentScanData.Add(robotData); } } // Save the new list containing robot scan data as the current robot scan data list currentScanData = newCurrentScanData; // If we don't have any target candidates, we have no candidates to fire at. // However, we will then use the current scan data for moving out robot as close to the nearest robot // outside the sentry robot's attack range, so we have a better chance to hit it when it moves too // close to the border. if (targetCandidates.Count == 0) { targetCandidates = new List <ScannedRobotData>(currentScanData); } // Now, pick the new target robot among the target candidates based on how far those are to our robot. // Pick the robot closest to our robot. double shortestDistance = double.MaxValue; // Initialize shortest distance seen, to maximum value foreach (ScannedRobotData robotData in currentScanData) { // Calculate the distance to the robot based on the hypotenuse (Pythagoras) double distance = DistanceTo(robotData.x, robotData.y); // Check if the distance is shorter than shortest distance calculated so far if (distance < shortestDistance) { // If the distance is shorter then save the calculated distance as the new shortest distance shortestDistance = distance; // Save the robot data as our new target robot newTarget = robotData; } } // Check if we got a new target robot if (newTarget != null) { // We got a new target robot.. // Calculate the target angle of the robot double targetAngle = Math.Atan2(newTarget.x - X, newTarget.y - Y); // Normalize the target angle so that the angle is kept within the range [0, PI[ targetAngle = Utils.NormalAbsoluteAngle(targetAngle); // Calculate the delta gun angle, i.e. how much of robot should be moved to the right. double deltaGunAngle = Utils.NormalRelativeAngle(targetAngle - GunHeadingRadians); // Set the gun to turn right the number of radians stored in the calculated delta gun angle. // Note: The setTurnGunRightRadians() will first be executed, when the execute() method is called. // If the delta gun angle is negative, it will automatically be moved in the opposite direction. SetTurnGunRightRadians(deltaGunAngle); // Check that the radar turn has almost completed (has less than 1 degrees left to turn) and // that the target robot is inside the entry attack range. if (RadarTurnRemaining < 1 && IsInsideSentryAttackRange(newTarget.x, newTarget.y)) { // Calculate the fire power we should use when firing at our target.. // We want to use the maximum bullet power 3, when the target is within 100 units and // the bullet power should become lesser the longer the distance is to our target. // Hence, we calculate the fire power as 3 * 100 / distance to target. double firePower = 300 / DistanceTo(newTarget.x, newTarget.y); // Set our gun to fire with the calculated amount of fire power. // Note: If the fire power is less than the minimum fire power 0.1 the gun will not fire. // If the fire power is greater than the maximum fire power 3, then gun will use 3 as fire power. SetFire(firePower); } // Paint a circle on our current target (debugging graphics) PaintCircle(newTarget.x, newTarget.y); } // Set our new target as our new "global" target, so that other methods can use it this.target = newTarget; }
private void SendStatusEvent(FixerStatus results) { StatusEvent?.Invoke(this, new FixerStatusEventArgs { Status = results }); }
public override void OnStatus(StatusEvent evnt) { dump(); }
public void NavigateMainBackWithStatus(StatusEvent statusEvent) { this.NavigateMainBack(); this.eventAggregator.Publish(statusEvent); }
public void UnsubscribeOnHealthZero(StatusEvent e) { OnHealthZero -= e; }
/// <exception cref="TorControlReplyParseException"/> public static IAsyncEvent Parse(TorControlReply reply) { if (reply.StatusCode != StatusCode.AsynchronousEventNotify) { throw new TorControlReplyParseException($"Event: Expected {StatusCode.AsynchronousEventNotify} status code."); } (string value, _) = Tokenizer.ReadUntilSeparator(reply.ResponseLines[0]); return(value switch { StatusEvent.EventNameStatusClient or StatusEvent.EventNameStatusServer or StatusEvent.EventNameStatusGeneral => StatusEvent.FromReply(reply), CircEvent.EventName => CircEvent.FromReply(reply), NetworkLivenessEvent.EventName => NetworkLivenessEvent.FromReply(reply), OrConnEvent.EventName => OrConnEvent.FromReply(reply), _ => throw new NotSupportedException("This should never happen."), });
public void UnsubscribeOnHealthDown(StatusEvent e) { OnHealthDown -= e; }
public override void OnStatus(StatusEvent e) { base.OnStatus(e); this.Status = e.Status; }
public override void OnStatus(StatusEvent e) { Out.WriteLine("live"); slowResponse(); }
public override void Execute(StatusEvent eventInfo) { eventInfo.Status["Duration"] += m_Duration; }
private void NotifyStatus(string message) { StatusEvent?.Invoke(this, new StatusEventArgs(message)); Thread.Sleep(0); }
public override void OnStatus(StatusEvent e) { StatusHistory.Add(e.Status); base.OnStatus(e); }