From 458a9384259bbe4b41ecb8fdd98c4ef3a0f6e2cf Mon Sep 17 00:00:00 2001 From: Alexejhero <32238504+Alexejhero@users.noreply.github.com> Date: Sat, 20 May 2023 17:44:26 +0300 Subject: [PATCH] Record usable target movement direction --- Neuro/Recording/Header/HeaderFrame.cs | 4 ++++ Neuro/Recording/Header/HeaderFrame.proto | 2 ++ Neuro/Recording/LocalPlayer/UsableData.cs | 17 +++++++++++++---- Neuro/Recording/RecordingDebugTab.cs | 3 +++ 4 files changed, 22 insertions(+), 4 deletions(-) diff --git a/Neuro/Recording/Header/HeaderFrame.cs b/Neuro/Recording/Header/HeaderFrame.cs index 417eb470..d944857b 100644 --- a/Neuro/Recording/Header/HeaderFrame.cs +++ b/Neuro/Recording/Header/HeaderFrame.cs @@ -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) diff --git a/Neuro/Recording/Header/HeaderFrame.proto b/Neuro/Recording/Header/HeaderFrame.proto index 78b3e0f2..0e2239bd 100644 --- a/Neuro/Recording/Header/HeaderFrame.proto +++ b/Neuro/Recording/Header/HeaderFrame.proto @@ -9,4 +9,6 @@ message HeaderFrame { bool IsImpostor = 2; RoleType Role = 3; repeated uint32 OtherImpostors = 4; + uint32 Version = 5; + bool IsFreeplay = 6; } diff --git a/Neuro/Recording/LocalPlayer/UsableData.cs b/Neuro/Recording/LocalPlayer/UsableData.cs index e014105d..da3fc697 100644 --- a/Neuro/Recording/LocalPlayer/UsableData.cs +++ b/Neuro/Recording/LocalPlayer/UsableData.cs @@ -1,4 +1,5 @@ using Neuro.Recording.Common; +using Vector2 = UnityEngine.Vector2; namespace Neuro.Recording.LocalPlayer; @@ -6,17 +7,25 @@ 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(); + 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().Platform.IsLeft ? Vector2.right : Vector2.left; + break; + } return data; } -} \ No newline at end of file +} diff --git a/Neuro/Recording/RecordingDebugTab.cs b/Neuro/Recording/RecordingDebugTab.cs index 65fb9e63..42febdd5 100644 --- a/Neuro/Recording/RecordingDebugTab.cs +++ b/Neuro/Recording/RecordingDebugTab.cs @@ -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) { @@ -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})"); }