Skip to content

Commit

Permalink
Record usable target movement direction
Browse files Browse the repository at this point in the history
  • Loading branch information
Alexejhero committed May 20, 2023
1 parent 52bd286 commit 458a938
Show file tree
Hide file tree
Showing 4 changed files with 22 additions and 4 deletions.
4 changes: 4 additions & 0 deletions Neuro/Recording/Header/HeaderFrame.cs
Original file line number Diff line number Diff line change
Expand Up @@ -10,11 +10,15 @@ public static HeaderFrame Generate()

HeaderFrame frame = new()
{
Version = 2,
Map = ShipStatus.Instance.GetTypeForMessage(),
IsFreeplay = TutorialManager.InstanceExists,
Role = PlayerControl.LocalPlayer.Data.Role.Role.ForMessage(),
IsImpostor = PlayerControl.LocalPlayer.Data.Role.IsImpostor
};

Warning("IS FREEPLAY: " + frame.IsFreeplay);

if (frame.IsImpostor)
{
foreach (PlayerControl player in PlayerControl.AllPlayerControls)
Expand Down
2 changes: 2 additions & 0 deletions Neuro/Recording/Header/HeaderFrame.proto
Original file line number Diff line number Diff line change
Expand Up @@ -9,4 +9,6 @@ message HeaderFrame {
bool IsImpostor = 2;
RoleType Role = 3;
repeated uint32 OtherImpostors = 4;
uint32 Version = 5;
bool IsFreeplay = 6;
}
17 changes: 13 additions & 4 deletions Neuro/Recording/LocalPlayer/UsableData.cs
Original file line number Diff line number Diff line change
@@ -1,22 +1,31 @@
using Neuro.Recording.Common;
using Vector2 = UnityEngine.Vector2;

namespace Neuro.Recording.LocalPlayer;

public partial class UsableData
{
public static UsableData Create(IUsable usable)
{
if (usable == null) return new UsableData() { Type = UsableType.NoneUsableType };
if (usable == null) return new UsableData() {Type = UsableType.NoneUsableType};

UsableData data = new()
{
Type = usable.GetTypeForMessage()
};

if (data.Type is not (UsableType.Ladder or UsableType.FlyingPlatform)) return data;
switch (data.Type)
{
case UsableType.Ladder:
Ladder ladder = usable.Cast<Ladder>();
data.Direction = ladder.Destination.transform.position.y > ladder.transform.position.y ? Vector2.up : Vector2.down;
break;

//TODO: Get the target movement direction
case UsableType.FlyingPlatform:
data.Direction = usable.Cast<PlatformConsole>().Platform.IsLeft ? Vector2.right : Vector2.left;
break;
}

return data;
}
}
}
3 changes: 3 additions & 0 deletions Neuro/Recording/RecordingDebugTab.cs
Original file line number Diff line number Diff line change
Expand Up @@ -45,11 +45,13 @@ private void BuildLocalPlayerRecorderUI()
Label(1, $"{nameof(LocalPlayerFrame.SabotageUsed)}: {LocalPlayerRecorder.Instance.Frame.SabotageUsed}");
Label(1, $"{nameof(LocalPlayerFrame.DoorsUsed)}: {LocalPlayerRecorder.Instance.Frame.DoorsUsed}");
Label(1, $"{nameof(LocalPlayerFrame.KillCooldown)}: {LocalPlayerRecorder.Instance.Frame.KillCooldown}");
Label(1, $"{nameof(LocalPlayerFrame.UsableTarget)}: T({LocalPlayerRecorder.Instance.Frame.UsableTarget.Type}), D{LocalPlayerRecorder.Instance.Frame.UsableTarget.Direction}");
}

private void BuildMapRecorderUI()
{
GUILayout.Label(nameof(MapFrame));

Label(1, $"{nameof(MapFrame.NearbyDoors)} ({MapRecorder.Instance.Frame.NearbyDoors.Count})");
foreach (DoorData door in MapRecorder.Instance.Frame.NearbyDoors)
{
Expand All @@ -61,6 +63,7 @@ private void BuildMapRecorderUI()
{
Label(2, $"- D({vent.Position.TotalDistance:F2})");
}

Label(1, $"{nameof(MapFrame.MeetingButton)} - D({MapRecorder.Instance.Frame.MeetingButton.TotalDistance:F2})");
}

Expand Down

0 comments on commit 458a938

Please sign in to comment.