mirror of
https://github.com/BubbaGumpShrump/AutoTrackR2.git
synced 2025-06-19 13:09:07 +00:00
27 lines
No EOL
786 B
C#
27 lines
No EOL
786 B
C#
using System.Text.RegularExpressions;
|
|
|
|
namespace AutoTrackR2.LogEventHandlers;
|
|
|
|
public class JumpDriveStateChangedEvent : ILogEventHandler
|
|
{
|
|
public Regex Pattern { get; }
|
|
private Regex _cleanUpPattern = new Regex(@"(.+?)_\d+$");
|
|
|
|
public JumpDriveStateChangedEvent()
|
|
{
|
|
Pattern = new Regex(@"<Jump Drive State Changed>.*.adam: (?<ShipName>.*.) in");
|
|
}
|
|
|
|
public void Handle(LogEntry entry)
|
|
{
|
|
if (entry.Message is null) return;
|
|
var match = Pattern.Match(entry.Message);
|
|
if (!match.Success) return;
|
|
|
|
match = _cleanUpPattern.Match(match.Groups["ShipName"].Value);
|
|
if (match.Success)
|
|
{
|
|
TrackREventDispatcher.OnJumpDriveStateChangedEvent(match.Groups[1].Value);;
|
|
}
|
|
}
|
|
} |