This commit is contained in:
D1GQ committed 2026-03-21 02:58:35 -05:00
1 parent 844dee8f6f
commit 84be9c4fcd
12 files changed
+76 -71

No files matched your search

+2 -1
View File
@@ -8,9 +8,10 @@ namespace BetterAmongUs.Data.Replay.Events;
[Serializable]
internal sealed class AppearReplayEvent : IReplayEvent<(int playerId, bool animate)>
{
[JsonPropertyName("id")]
public string Id => "player_appear";
[JsonInclude]
[JsonPropertyName("eventData")]
public (int playerId, bool animate) EventData { get; set; }
public void Play()
+2 -1
View File
@@ -7,9 +7,10 @@ namespace BetterAmongUs.Data.Replay.Events;
[Serializable]
internal sealed class MurderReplayEvent : IReplayEvent<(int killerId, int targetId)>
{
[JsonPropertyName("id")]
public string Id => "player_murder";
[JsonInclude]
[JsonPropertyName("eventData")]
public (int killerId, int targetId) EventData { get; set; }
public void Play()
+2 -1
View File
@@ -8,9 +8,10 @@ namespace BetterAmongUs.Data.Replay.Events;
[Serializable]
internal sealed class ProtectReplayEvent : IReplayEvent<(int playerId, int targetId)>
{
[JsonPropertyName("id")]
public string Id => "protect_player";
[JsonInclude]
[JsonPropertyName("eventData")]
public (int playerId, int targetId) EventData { get; set; }
public void Play()
@@ -7,9 +7,10 @@ namespace BetterAmongUs.Data.Replay.Events;
[Serializable]
internal sealed class ProtectedReplayEvent : IReplayEvent<(int killerId, int targetId)>
{
[JsonPropertyName("id")]
public string Id => "player_protected";
[JsonInclude]
[JsonPropertyName("eventData")]
public (int killerId, int targetId) EventData { get; set; }
public void Play()
+31
View File
@@ -0,0 +1,31 @@
using AmongUs.GameOptions;
using BetterAmongUs.Helpers;
using BetterAmongUs.Interfaces;
using System.Text.Json.Serialization;
namespace BetterAmongUs.Data.Replay.Events;
[Serializable]
internal sealed class SetRoleEvent : IReplayEvent<(int playerId, int roleType)>
{
[JsonPropertyName("id")]
public string Id => "set_role";
[JsonPropertyName("eventData")]
public (int playerId, int roleType) EventData { get; set; }
public void Play()
{
var player = Utils.PlayerFromPlayerId(EventData.playerId);
if (player != null)
{
var roleType = (RoleTypes)EventData.roleType;
player.RpcSetRole(roleType, true);
}
}
public void Record(PlayerControl player, RoleTypes roleType)
{
EventData = (player.Data.PlayerId, (int)roleType);
}
}
@@ -8,9 +8,10 @@ namespace BetterAmongUs.Data.Replay.Events;
[Serializable]
internal sealed class ShapeshiftReplayEvent : IReplayEvent<(int playerId, int targetId, bool animate)>
{
[JsonPropertyName("id")]
public string Id => "player_shapeshift";
[JsonInclude]
[JsonPropertyName("eventData")]
public (int playerId, int targetId, bool animate) EventData { get; set; }
public void Play()
@@ -1,10 +1,15 @@
using BetterAmongUs.Interfaces;
using System.Text.Json.Serialization;
namespace BetterAmongUs.Data.Replay.Events;
[Serializable]
internal sealed class StartMeetingReplayEvent : IReplayEvent<(int playerId, int targetId)>
{
[JsonPropertyName("id")]
public string Id => "start_meeting";
[JsonPropertyName("eventData")]
public (int playerId, int targetId) EventData { get; set; }
public void Play()
@@ -7,9 +7,10 @@ namespace BetterAmongUs.Data.Replay.Events;
[Serializable]
internal sealed class UpdateSystemReplayEvent : IReplayEvent<(byte systemType, int playerId, byte amount)>
{
[JsonPropertyName("id")]
public string Id => "update_system";
[JsonInclude]
[JsonPropertyName("eventData")]
public (byte systemType, int playerId, byte amount) EventData { get; set; }
public void Play()
+2 -1
View File
@@ -8,9 +8,10 @@ namespace BetterAmongUs.Data.Replay.Events;
[Serializable]
internal sealed class VanishReplayEvent : IReplayEvent<int>
{
[JsonPropertyName("id")]
public string Id => "player_vanish";
[JsonInclude]
[JsonPropertyName("eventData")]
public int EventData { get; set; }
public void Play()
+2 -1
View File
@@ -7,9 +7,10 @@ namespace BetterAmongUs.Data.Replay.Events;
[Serializable]
internal sealed class VentReplayEvent : IReplayEvent<(int playerId, bool exit, int ventId)>
{
[JsonPropertyName("id")]
public string Id => "player_vent";
[JsonInclude]
[JsonPropertyName("eventData")]
public (int playerId, bool exit, int ventId) EventData { get; set; }
public void Play()
+17 -22
View File
@@ -1,36 +1,31 @@
using AmongUs.GameOptions;
using System.Text.Json.Serialization;
using UnityEngine;
namespace BetterAmongUs.Data.Replay;
/// <summary>
/// Represents player data for replay functionality.
/// </summary>
[Serializable]
internal class PlayerReplayData
{
/// <summary>
/// Gets or sets the player's ID.
/// </summary>
[JsonPropertyName("playerId")]
public int PlayerId;
/// <summary>
/// Gets or sets the player's name.
/// </summary>
[JsonPropertyName("playerName")]
public string PlayerName = "";
/// <summary>
/// Gets or sets the player's role type.
/// </summary>
public RoleTypes Role;
[JsonPropertyName("movementData")]
public List<(float timeStamp, Vector2 pos)> MovementDataBuffer = [];
/// <summary>
/// Gets or sets the buffer of movement data containing timestamps and positions.
/// </summary>
public (float timeStamp, Vector2 pos)[] MovementDataBuffer = [];
/// <summary>
/// Gets or sets the player's cosmetic data.
/// </summary>
[JsonPropertyName("cosmeticData")]
public (int colorId, string skinId, string visorId, string petId, string namePlateId) CosmeticData = new();
internal void Set(PlayerControl player)
{
PlayerId = player.Data.PlayerId;
PlayerName = player.Data.PlayerName;
}
internal void RecordMovement(Vector2 pos)
{
MovementDataBuffer.Add((0, pos));
}
}
+7 -41
View File
@@ -1,72 +1,38 @@
using BetterAmongUs.Interfaces;
using System.Text.Json.Serialization;
namespace BetterAmongUs.Data.Replay;
/// <summary>
/// Represents a replay of a game session.
/// </summary>
[Serializable]
internal class Replay
{
/// <summary>
/// Gets or sets the map ID for the replay.
/// </summary>
[JsonPropertyName("mapId")]
public int MapId;
/// <summary>
/// Gets or sets the list of player data for the replay.
/// </summary>
[JsonPropertyName("playerData")]
public List<PlayerReplayData> PlayerData = [];
/// <summary>
/// Gets or sets the dictionary of replay events keyed by timestamp.
/// </summary>
[JsonPropertyName("events")]
public Dictionary<float, List<IReplayEvent>> Events = [];
/// <summary>
/// Loads the replay and initializes the game session.
/// </summary>
/// <remarks>
/// Sets up the map and host game, then creates player instances.
/// </remarks>
public void Load()
internal void Load()
{
AmongUsClient.Instance.TutorialMapId = MapId;
UnityEngine.Object.FindFirstObjectByType<FreeplayPopover>().hostGameButton.OnClick();
CreatePlayers();
}
/// <summary>
/// Creates player instances for the replay.
/// </summary>
/// <remarks>
/// This method is currently a placeholder and needs implementation.
/// </remarks>
private void CreatePlayers()
{
// TODO: Implement player creation logic
}
/// <summary>
/// Updates player movement data at the specified timestamp.
/// </summary>
/// <param name="timeStamp">The timestamp to update movement for.</param>
/// <remarks>
/// This method is currently a placeholder and needs implementation.
/// </remarks>
public void UpdateMovement(float timeStamp)
internal void UpdateMovement(float timeStamp)
{
// TODO: Implement movement update logic
}
/// <summary>
/// Updates replay events at the specified timestamp.
/// </summary>
/// <param name="timeStamp">The timestamp to update events for.</param>
/// <remarks>
/// This method is currently a placeholder and needs implementation.
/// </remarks>
public void UpdateEvents(float timeStamp)
internal void UpdateEvents(float timeStamp)
{
// TODO: Implement event update logic
}