diff --git a/EXILED/EXILED.props b/EXILED/EXILED.props index bf96b2e251..2d1f11bec6 100644 --- a/EXILED/EXILED.props +++ b/EXILED/EXILED.props @@ -15,7 +15,7 @@ - 9.0.0-alpha.3 + 9.0.0-alpha.4 false diff --git a/EXILED/Exiled.API/Enums/DoorType.cs b/EXILED/Exiled.API/Enums/DoorType.cs index 52fb3ef34e..6b3498baaa 100644 --- a/EXILED/Exiled.API/Enums/DoorType.cs +++ b/EXILED/Exiled.API/Enums/DoorType.cs @@ -235,7 +235,12 @@ public enum DoorType /// /// Represents the Gate in the Checkpoint between EZ and HCZ. /// - CheckpointGate, + CheckpointGateA, + + /// + /// Represents the Gate in the Checkpoint between EZ and HCZ. + /// + CheckpointGateB, /// /// Represents the Gate in the Checkpoint between EZ and HCZ. diff --git a/EXILED/Exiled.API/Enums/RoomType.cs b/EXILED/Exiled.API/Enums/RoomType.cs index 380db04d00..4402ae7e30 100644 --- a/EXILED/Exiled.API/Enums/RoomType.cs +++ b/EXILED/Exiled.API/Enums/RoomType.cs @@ -272,7 +272,12 @@ public enum RoomType /// /// Entrance Zone's straight hall before the entrance/heavy checkpoint. /// - EzCheckpointHallway, + EzCheckpointHallwayA, + + /// + /// Entrance Zone's straight hall before the entrance/heavy checkpoint. + /// + EzCheckpointHallwayB, /// /// Heavy Containment Zone's test room's straight hall. @@ -293,5 +298,40 @@ public enum RoomType /// Lazy TODO. /// HczCrossRoomWater, + + /// + /// Lazy TODO. + /// + HczCornerDeep, + + /// + /// Lazy TODO. + /// + HczIntersectionJunk, + + /// + /// Lazy TODO. + /// + HczIntersection, + + /// + /// Lazy TODO. + /// + HczStraightC, + + /// + /// Lazy TODO. + /// + HczStraightPipeRoom, + + /// + /// Lazy TODO. + /// + HczStraightVariant, + + /// + /// Lazy TODO. + /// + EzSmallrooms, } } \ No newline at end of file diff --git a/EXILED/Exiled.API/Features/Doors/Door.cs b/EXILED/Exiled.API/Features/Doors/Door.cs index 5334419c05..c15e5c3b4a 100644 --- a/EXILED/Exiled.API/Features/Doors/Door.cs +++ b/EXILED/Exiled.API/Features/Doors/Door.cs @@ -603,7 +603,8 @@ private DoorType GetDoorType() }, "Unsecured Pryable GateDoor" => Room?.Type switch { - RoomType.EzCheckpointHallway => DoorType.CheckpointGate, + RoomType.EzCheckpointHallwayA => DoorType.CheckpointGateA, + RoomType.EzCheckpointHallwayB => DoorType.CheckpointGateB, RoomType.Hcz049 => Position.y < -805 ? DoorType.Scp049Gate : DoorType.Scp173NewGate, _ => DoorType.UnknownGate, }, diff --git a/EXILED/Exiled.API/Features/Player.cs b/EXILED/Exiled.API/Features/Player.cs index 788493ca98..3251d1b347 100644 --- a/EXILED/Exiled.API/Features/Player.cs +++ b/EXILED/Exiled.API/Features/Player.cs @@ -47,6 +47,7 @@ namespace Exiled.API.Features using Mirror.LiteNetLib4Mirror; using PlayerRoles; using PlayerRoles.FirstPersonControl; + using PlayerRoles.FirstPersonControl.Thirdperson.Subcontrollers; using PlayerRoles.RoleAssign; using PlayerRoles.Spectating; using PlayerRoles.Voice; @@ -732,6 +733,15 @@ public bool IsBypassModeEnabled set => ReferenceHub.serverRoles.BypassMode = value; } + /// + /// Gets or sets the player's emotion. + /// + public EmotionPresetType Emotion + { + get => EmotionSync.GetEmotionPreset(ReferenceHub); + set => EmotionSync.ServerSetEmotionPreset(ReferenceHub, value); + } + /// /// Gets or sets a value indicating whether the player is muted. /// diff --git a/EXILED/Exiled.API/Features/Room.cs b/EXILED/Exiled.API/Features/Room.cs index d21aee638e..d1361ac07e 100644 --- a/EXILED/Exiled.API/Features/Room.cs +++ b/EXILED/Exiled.API/Features/Room.cs @@ -438,10 +438,16 @@ private static RoomType FindType(GameObject gameObject) "HCZ_Nuke" => RoomType.HczNuke, "HCZ_Tesla_Rework" => RoomType.HczTesla, "HCZ_Servers" => RoomType.HczServers, - "HCZ_Room3" or "HCZ_Intersection_Junk" or "HCZ_Intersection" => RoomType.HczTCross, + "HCZ_Room3" => RoomType.HczTCross, + "HCZ_Intersection_Junk" => RoomType.HczIntersectionJunk, + "HCZ_Intersection" => RoomType.HczIntersectionJunk, "HCZ_096" => RoomType.Hcz096, - "HCZ_Curve" or "HCZ_Corner_Deep" => RoomType.HczCurve, - "HCZ_Straight_C" or "HCZ_Straight" or "HCZ_Straight_PipeRoom" or "HCZ_Straight Variant" => RoomType.HczStraight, + "HCZ_Curve" => RoomType.HczCurve, + "HCZ_Corner_Deep" => RoomType.HczCornerDeep, + "HCZ_Straight_C" => RoomType.HczStraightC, + "HCZ_Straight" => RoomType.HczStraight, + "HCZ_Straight_PipeRoom"=> RoomType.HczStraightPipeRoom, + "HCZ_Straight Variant" => RoomType.HczStraightVariant, "HCZ_Crossroom_Water" => RoomType.HczCrossRoomWater, "EZ_Endoof" => RoomType.EzVent, "EZ_Intercom" => RoomType.EzIntercom, @@ -451,7 +457,8 @@ private static RoomType FindType(GameObject gameObject) "EZ_PCs" => RoomType.EzPcs, "EZ_Crossing" => RoomType.EzCrossing, "EZ_CollapsedTunnel" => RoomType.EzCollapsedTunnel, - "EZ_Smallrooms2" or "EZ_Smallrooms1" => RoomType.EzConference, + "EZ_Smallrooms1" => RoomType.EzConference, + "EZ_Smallrooms2" => RoomType.EzSmallrooms, "EZ_Chef" => RoomType.EzChef, "EZ_Straight" => RoomType.EzStraight, "EZ_Cafeteria" => RoomType.EzCafeteria, @@ -462,7 +469,11 @@ private static RoomType FindType(GameObject gameObject) "PocketWorld" => RoomType.Pocket, "Outside" => RoomType.Surface, "HCZ_939" => RoomType.Hcz939, - "EZ_HCZ_Checkpoint Part" => RoomType.EzCheckpointHallway, + "EZ_HCZ_Checkpoint Part" => gameObject.transform.position.z switch + { + > 80 => RoomType.EzCheckpointHallwayA, + _ => RoomType.EzCheckpointHallwayB, + }, "HCZ_ChkpA" => RoomType.HczElevatorA, "HCZ_ChkpB" => RoomType.HczElevatorB, "HCZ_EZ_Checkpoint Part" => gameObject.transform.position.z switch diff --git a/EXILED/Exiled.Events/EventArgs/Player/ChangedEmotionEventArgs.cs b/EXILED/Exiled.Events/EventArgs/Player/ChangedEmotionEventArgs.cs new file mode 100644 index 0000000000..230cf07843 --- /dev/null +++ b/EXILED/Exiled.Events/EventArgs/Player/ChangedEmotionEventArgs.cs @@ -0,0 +1,38 @@ +// ----------------------------------------------------------------------- +// +// Copyright (c) ExMod Team. All rights reserved. +// Licensed under the CC BY-SA 3.0 license. +// +// ----------------------------------------------------------------------- + +namespace Exiled.Events.EventArgs.Player +{ + using Exiled.API.Features; + using Exiled.Events.EventArgs.Interfaces; + using PlayerRoles.FirstPersonControl.Thirdperson.Subcontrollers; + + /// + /// Contains all the information after the player's emotion. + /// + public class ChangedEmotionEventArgs : IPlayerEvent + { + /// + /// Initializes a new instance of the class. + /// + /// + /// + public ChangedEmotionEventArgs(ReferenceHub hub, EmotionPresetType emotionPresetType) + { + Player = Exiled.API.Features.Player.Get(hub); + EmotionPresetType = emotionPresetType; + } + + /// + /// Gets the player's emotion. + /// + public EmotionPresetType EmotionPresetType { get; } + + /// + public Player Player { get; } + } +} \ No newline at end of file diff --git a/EXILED/Exiled.Events/EventArgs/Player/ChangingEmotionEventArgs.cs b/EXILED/Exiled.Events/EventArgs/Player/ChangingEmotionEventArgs.cs new file mode 100644 index 0000000000..d76207282a --- /dev/null +++ b/EXILED/Exiled.Events/EventArgs/Player/ChangingEmotionEventArgs.cs @@ -0,0 +1,50 @@ +// ----------------------------------------------------------------------- +// +// Copyright (c) ExMod Team. All rights reserved. +// Licensed under the CC BY-SA 3.0 license. +// +// ----------------------------------------------------------------------- + +namespace Exiled.Events.EventArgs.Player +{ + using Exiled.API.Features; + using Exiled.Events.EventArgs.Interfaces; + using PlayerRoles.FirstPersonControl.Thirdperson.Subcontrollers; + + /// + /// Contains all the information before the player's emotion changes. + /// + public class ChangingEmotionEventArgs : IDeniableEvent, IPlayerEvent + { + /// + /// Initializes a new instance of the class. + /// + /// + /// + /// + /// + public ChangingEmotionEventArgs(ReferenceHub hub, EmotionPresetType emotionPresetTypeNew, EmotionPresetType emotionPresetTypeOld, bool isAllowed = true) + { + Player = Exiled.API.Features.Player.Get(hub); + EmotionPresetTypeNew = emotionPresetTypeNew; + EmotionPresetTypeOld = emotionPresetTypeOld; + IsAllowed = isAllowed; + } + + /// + public bool IsAllowed { get; set; } + + /// + /// Gets the old player's emotion. + /// + public EmotionPresetType EmotionPresetTypeOld { get; } + + /// + /// Gets or sets the new player's emotion. + /// + public EmotionPresetType EmotionPresetTypeNew { get; set; } + + /// + public Player Player { get; } + } +} \ No newline at end of file diff --git a/EXILED/Exiled.Events/Handlers/Player.cs b/EXILED/Exiled.Events/Handlers/Player.cs index 581b10014e..af69cf8072 100644 --- a/EXILED/Exiled.Events/Handlers/Player.cs +++ b/EXILED/Exiled.Events/Handlers/Player.cs @@ -549,6 +549,28 @@ public class Player /// public static Event ChangingNickname { get; set; } = new(); + /// + /// Invoked before a player's emotion changed. + /// + public static Event ChangingEmotion { get; set; } = new(); + + /// + /// Invoked after a player's emotion changed. + /// + public static Event ChangedEmotion { get; set; } = new(); + + /// + /// Called before a player's emotion changed. + /// + /// The instance. + public static void OnChangingEmotion(ChangingEmotionEventArgs ev) => ChangingEmotion.InvokeSafely(ev); + + /// + /// Called after a player's emotion changed. + /// + /// The instance. + public static void OnChangedEmotion(ChangedEmotionEventArgs ev) => ChangedEmotion.InvokeSafely(ev); + /// /// Called before reserved slot is resolved for a . /// diff --git a/EXILED/Exiled.Events/Patches/Events/Player/Emotion.cs b/EXILED/Exiled.Events/Patches/Events/Player/Emotion.cs new file mode 100644 index 0000000000..3fbc212f5c --- /dev/null +++ b/EXILED/Exiled.Events/Patches/Events/Player/Emotion.cs @@ -0,0 +1,38 @@ +// ----------------------------------------------------------------------- +// +// Copyright (c) ExMod Team. All rights reserved. +// Licensed under the CC BY-SA 3.0 license. +// +// ----------------------------------------------------------------------- + +namespace Exiled.Events.Patches.Events.Player +{ + using Exiled.Events.Attributes; + using Exiled.Events.EventArgs.Player; + using HarmonyLib; + using PlayerRoles.FirstPersonControl.Thirdperson.Subcontrollers; + + /// + /// Patches . + /// Adds the event and + /// event. + /// + [EventPatch(typeof(Handlers.Player), nameof(Handlers.Player.ChangingEmotion))] + [EventPatch(typeof(Handlers.Player), nameof(Handlers.Player.ChangedEmotion))] + [HarmonyPatch(typeof(EmotionSync), nameof(EmotionSync.ServerSetEmotionPreset))] + internal static class Emotion + { + private static bool Prefix(this ReferenceHub hub, EmotionPresetType preset) + { + ChangingEmotionEventArgs ev = new(hub, preset, EmotionSync.GetEmotionPreset(hub)); + Handlers.Player.OnChangingEmotion(ev); + return ev.IsAllowed; + } + + private static void Postfix(this ReferenceHub hub, EmotionPresetType preset) + { + ChangedEmotionEventArgs ev = new(hub, EmotionSync.GetEmotionPreset(hub)); + Handlers.Player.OnChangedEmotion(ev); + } + } +} diff --git a/EXILED/Exiled.Events/Patches/Events/Scp1344/Deactivating.cs b/EXILED/Exiled.Events/Patches/Events/Scp1344/Deactivating.cs index e1b3066099..9cf35fe606 100644 --- a/EXILED/Exiled.Events/Patches/Events/Scp1344/Deactivating.cs +++ b/EXILED/Exiled.Events/Patches/Events/Scp1344/Deactivating.cs @@ -33,7 +33,7 @@ private static bool Prefix(ref Scp1344Item __instance) { if (__instance._useTime == 0) { - var ev = new TryingDeactivatingEventArgs(Item.Get(__instance)); + TryingDeactivatingEventArgs ev = new(Item.Get(__instance)); Exiled.Events.Handlers.Scp1344.OnTryingDeactivating(ev); if (!ev.IsAllowed) @@ -44,7 +44,7 @@ private static bool Prefix(ref Scp1344Item __instance) if (__instance._useTime + Time.deltaTime >= 5.1f) { - var deactivating = new DeactivatingEventArgs(Item.Get(__instance)); + DeactivatingEventArgs deactivating = new(Item.Get(__instance)); Exiled.Events.Handlers.Scp1344.OnDeactivating(deactivating); if (!deactivating.IsAllowed) @@ -55,7 +55,7 @@ private static bool Prefix(ref Scp1344Item __instance) __instance.ActivateFinalEffects(); __instance.ServerDropItem(__instance); - var ev = new DeactivatedEventArgs(Item.Get(__instance)); + DeactivatedEventArgs ev = new(Item.Get(__instance)); Exiled.Events.Handlers.Scp1344.OnDeactivated(ev); return false; } diff --git a/EXILED/Exiled.Loader/Loader.cs b/EXILED/Exiled.Loader/Loader.cs index 783a1137e0..1a8a55c7c4 100644 --- a/EXILED/Exiled.Loader/Loader.cs +++ b/EXILED/Exiled.Loader/Loader.cs @@ -46,6 +46,7 @@ public Loader() Log.Warn("You are running a public beta build. It is not compatible with another version of the game."); #endif + Log.SendRaw($"Exiled.API - Version {PluginAPI.Loader.AssemblyLoader.Dependencies.FirstOrDefault(x => x.GetName().Name == "Exiled.API").GetCustomAttribute().InformationalVersion}", ConsoleColor.DarkRed); Log.SendRaw($"{Assembly.GetExecutingAssembly().GetName().Name} - Version {Assembly.GetExecutingAssembly().GetCustomAttribute().InformationalVersion}", ConsoleColor.DarkRed); if (MultiAdminFeatures.MultiAdminUsed) @@ -145,8 +146,7 @@ public static void LoadPlugins() AssemblyInformationalVersionAttribute attribute = plugin.Assembly.GetCustomAttribute(); - Log.Info($"Loaded plugin {plugin.Name}@{(plugin.Version is not null ? $"{plugin.Version.Major}.{plugin.Version.Minor}.{plugin.Version.Build}" : attribute is not null ? attribute.InformationalVersion : string.Empty)}"); - + Log.Info($"Loaded plugin {plugin.Name}@{(attribute is not null ? attribute.InformationalVersion : plugin.Version is not null ? $"{plugin.Version.Major}.{plugin.Version.Minor}.{plugin.Version.Build}" : string.Empty)}"); Server.PluginAssemblies.Add(assembly, plugin); Plugins.Add(plugin); } diff --git a/EXILED/Exiled.Loader/Updater.cs b/EXILED/Exiled.Loader/Updater.cs index 49ee5adc6e..448adfd6c2 100644 --- a/EXILED/Exiled.Loader/Updater.cs +++ b/EXILED/Exiled.Loader/Updater.cs @@ -16,6 +16,7 @@ namespace Exiled.Loader using System.Reflection; using System.Runtime.InteropServices; using System.Text; + using System.Threading; using Exiled.API.Features; using Exiled.Loader.GHApi; @@ -112,9 +113,16 @@ internal static Updater Initialize(Config config) /// internal void CheckUpdate() { - using HttpClient client = CreateHttpClient(); - if (Busy = FindUpdate(client, !File.Exists(Path.Combine(Paths.Dependencies, "Exiled.API.dll")), out NewVersion newVersion)) - Update(client, newVersion); + try + { + using HttpClient client = CreateHttpClient(); + if (Busy = FindUpdate(client, !PluginAPI.Loader.AssemblyLoader.Dependencies.Exists(x => x.GetName().Name == "Exiled.API"), out NewVersion newVersion)) + Update(client, newVersion); + } + catch (Exception e) + { + Log.Error(e); + } } /// @@ -144,6 +152,7 @@ private bool FindUpdate(HttpClient client, bool forced, out NewVersion newVersio { try { + Thread.Sleep(5000); // Wait for the assemblies to load ExiledLib smallestVersion = ExiledLib.Min(); Log.Info($"Found the smallest version of Exiled - {smallestVersion.Library.GetName().Name}:{smallestVersion.Version}");