Skip to content

Commit

Permalink
Add cosmetics change event
Browse files Browse the repository at this point in the history
  • Loading branch information
stenlan committed Jan 11, 2021
1 parent 959f012 commit eac07d7
Show file tree
Hide file tree
Showing 2 changed files with 23 additions and 0 deletions.
6 changes: 6 additions & 0 deletions AUCapture-WPF/MainWindow.xaml.cs
Expand Up @@ -112,6 +112,7 @@ public MainWindow()
GameMemReader.getInstance().ChatMessageAdded += OnChatMessageAdded;
GameMemReader.getInstance().JoinedLobby += OnJoinedLobby;
GameMemReader.getInstance().GameOver += OnGameOver;
GameMemReader.getInstance().PlayerCosmeticChanged += OnCosmeticChanged;
IPCAdapter.getInstance().OnToken += (sender, token) =>
{
this.BeginInvoke((w) =>
Expand Down Expand Up @@ -177,6 +178,11 @@ public MainWindow()
//ApplyDarkMode();
}

private void OnCosmeticChanged(object sender, PlayerCosmeticChangedEventArgs e)
{
AmongUsCapture.Settings.conInterface.WriteModuleTextColored("Cosmetic (Debug)", Color.DarkKhaki, $"{e.Name}{NormalTextColor.ToTextColor()}: {e.HatId} {e.SkinId}");
}

public async void Update()
{
Version version = new Version(context.Version);
Expand Down
17 changes: 17 additions & 0 deletions AmongUsCapture/Memory/GameMemReader.cs
Expand Up @@ -71,6 +71,8 @@ public static GameMemReader getInstance()

public event EventHandler<GameOverEventArgs> GameOver;

public event EventHandler<PlayerCosmeticChangedEventArgs> PlayerCosmeticChanged;


private bool cracked = false;

Expand Down Expand Up @@ -421,6 +423,14 @@ public void RunLoop()
Disconnected = pi.GetIsDisconnected(),
Color = pi.GetPlayerColor()
});

if (oldPlayerInfo.HatId != pi.HatId || oldPlayerInfo.SkinId != pi.SkinId)
PlayerCosmeticChanged?.Invoke(this, new PlayerCosmeticChangedEventArgs
{
Name = playerName,
HatId = pi.HatId,
SkinId = pi.SkinId
});
}
}

Expand Down Expand Up @@ -645,6 +655,13 @@ public enum PlayMap
Polus = 2
}

public class PlayerCosmeticChangedEventArgs : EventArgs
{
public string Name { get; set; }
public uint HatId { get; set; }
public uint SkinId { get; set; }
}

public class PlayerChangedEventArgs : EventArgs
{
public PlayerAction Action { get; set; }
Expand Down

0 comments on commit eac07d7

Please sign in to comment.