diff --git a/Refs/Assembly-CSharp-Publicized.dll b/Refs/Assembly-CSharp-Publicized.dll index bf221d84..0f08585a 100644 Binary files a/Refs/Assembly-CSharp-Publicized.dll and b/Refs/Assembly-CSharp-Publicized.dll differ diff --git a/Synapse/Api/Dummy.cs b/Synapse/Api/Dummy.cs index 13dabed5..65bfaf70 100644 --- a/Synapse/Api/Dummy.cs +++ b/Synapse/Api/Dummy.cs @@ -1,4 +1,5 @@ -using System.Collections.Generic; +using System; +using System.Collections.Generic; using InventorySystem; using Mirror; using RemoteAdmin; @@ -99,7 +100,11 @@ public string BadgeColor public PlayerMovementState Movement { get => Player.AnimationController.MoveState; - set => Player.AnimationController.UserCode_CmdChangeSpeedState((byte)value); + set + { + Player.AnimationController.MoveState = Movement; + Player.AnimationController.RpcReceiveState((byte)Movement); + } } public MovementDirection Direction { get; set; } @@ -116,68 +121,75 @@ private IEnumerator Update() for(; ; ) { yield return MEC.Timing.WaitForSeconds(0.1f); - if (GameObject == null) yield break; - if (Direction == MovementDirection.Stop) - { - continue; - } - - var wall = false; - var speed = 0f; - - switch (Movement) - { - case PlayerMovementState.Sneaking: - speed = SneakSpeed; - break; - - case PlayerMovementState.Sprinting: - speed = RunSpeed * Map.Get.SprintSpeed; - break; - - case PlayerMovementState.Walking: - speed = WalkSpeed * Map.Get.WalkSpeed; - break; - } - - switch (Direction) + try { - case MovementDirection.Forward: - var pos = Position + Player.CameraReference.forward / 10 * speed; - - if (!Physics.Linecast(Position, pos, Player.PlayerMovementSync.CollidableSurfaces)) - Player.PlayerMovementSync.OverridePosition(pos, 0f, true); - else wall = true; - break; - - case MovementDirection.BackWards: - pos = Position - Player.CameraReference.forward / 10 * speed; - - if (!Physics.Linecast(Position, pos, Player.PlayerMovementSync.CollidableSurfaces)) - Player.PlayerMovementSync.OverridePosition(pos, 0f, true); - else wall = true; - break; - - case MovementDirection.Right: - pos = Position + Quaternion.AngleAxis(90, Vector3.up) * Player.CameraReference.forward / 10 * speed; - - if (!Physics.Linecast(Position, pos, Player.PlayerMovementSync.CollidableSurfaces)) - Player.PlayerMovementSync.OverridePosition(pos, 0f, true); - else wall = true; - break; - - case MovementDirection.Left: - pos = Position - Quaternion.AngleAxis(90, Vector3.up) * Player.CameraReference.forward / 10 * speed; - - if (!Physics.Linecast(Position, pos, Player.PlayerMovementSync.CollidableSurfaces)) - Player.PlayerMovementSync.OverridePosition(pos, 0f, true); - else wall = true; - break; + if (GameObject == null) yield break; + if (Direction == MovementDirection.Stop) + { + continue; + } + + var wall = false; + var speed = 0f; + + switch (Movement) + { + case PlayerMovementState.Sneaking: + speed = SneakSpeed; + break; + + case PlayerMovementState.Sprinting: + speed = RunSpeed * Map.Get.SprintSpeed; + break; + + case PlayerMovementState.Walking: + speed = WalkSpeed * Map.Get.WalkSpeed; + break; + } + + switch (Direction) + { + case MovementDirection.Forward: + var pos = Position + Player.CameraReference.forward / 10 * speed; + + if (!Physics.Linecast(Position, pos, Player.PlayerMovementSync.CollidableSurfaces)) + Player.PlayerMovementSync.OverridePosition(pos, 0f, true); + else wall = true; + break; + + case MovementDirection.BackWards: + pos = Position - Player.CameraReference.forward / 10 * speed; + + if (!Physics.Linecast(Position, pos, Player.PlayerMovementSync.CollidableSurfaces)) + Player.PlayerMovementSync.OverridePosition(pos, 0f, true); + else wall = true; + break; + + case MovementDirection.Right: + pos = Position + Quaternion.AngleAxis(90, Vector3.up) * Player.CameraReference.forward / 10 * speed; + + if (!Physics.Linecast(Position, pos, Player.PlayerMovementSync.CollidableSurfaces)) + Player.PlayerMovementSync.OverridePosition(pos, 0f, true); + else wall = true; + break; + + case MovementDirection.Left: + pos = Position - Quaternion.AngleAxis(90, Vector3.up) * Player.CameraReference.forward / 10 * speed; + + if (!Physics.Linecast(Position, pos, Player.PlayerMovementSync.CollidableSurfaces)) + Player.PlayerMovementSync.OverridePosition(pos, 0f, true); + else wall = true; + break; + } + + if (wall) + { + Direction = MovementDirection.Stop; + } } - - if (wall) + catch(Exception e) { - Direction = MovementDirection.Stop; + Logger.Get.Error($"Synapse-Dummy: Dummy Update Failed:\n{e}"); } } } @@ -196,7 +208,7 @@ private IEnumerator Update() public Dummy(Vector3 pos, Vector2 rot, RoleType role = RoleType.ClassD, string name = "(null)", string badgetext = "", string badgecolor = "") { GameObject obj = - Object.Instantiate( + UnityEngine.Object.Instantiate( NetworkManager.singleton.playerPrefab); GameObject = obj; @@ -217,6 +229,7 @@ public Dummy(Vector3 pos, Vector2 rot, RoleType role = RoleType.ClassD, string n Player.RankName = badgetext; Player.RankColor = badgecolor; Player.GodMode = true; + Player.PlayerMovementSync.NetworkGrounded = true; RunSpeed = CharacterClassManager._staticClasses[(int)role].runSpeed; WalkSpeed = CharacterClassManager._staticClasses[(int)role].walkSpeed; MEC.Timing.RunCoroutine(Update()); @@ -254,7 +267,7 @@ public void Spawn() /// public void Destroy() { - Object.Destroy(GameObject); + UnityEngine.Object.Destroy(GameObject); Map.Get.Dummies.Remove(this); } diff --git a/Synapse/Api/Events/EventHandler.cs b/Synapse/Api/Events/EventHandler.cs index ce94fc3f..ecceb96e 100644 --- a/Synapse/Api/Events/EventHandler.cs +++ b/Synapse/Api/Events/EventHandler.cs @@ -21,7 +21,10 @@ private void KeyPress(SynapseEventArguments.PlayerKeyPressEventArgs ev) { switch (ev.KeyCode) { - + case KeyCode.Alpha1: + Logger.Get.Debug(ev.Player.ItemInHand.ID); + + break; } } diff --git a/Synapse/Api/Items/ItemManager.cs b/Synapse/Api/Items/ItemManager.cs index 59e4a654..772b0c98 100644 --- a/Synapse/Api/Items/ItemManager.cs +++ b/Synapse/Api/Items/ItemManager.cs @@ -8,7 +8,7 @@ public class ItemManager { public static ItemManager Get => Server.Get.ItemManager; - public const int HighestItem = (int)ItemType.GunShotgun; + public const int HighestItem = (int)ItemType.SCP2176; private readonly List customItems = new List(); diff --git a/Synapse/Api/Items/PlayerInventory.cs b/Synapse/Api/Items/PlayerInventory.cs index fb2a0297..79bc013f 100644 --- a/Synapse/Api/Items/PlayerInventory.cs +++ b/Synapse/Api/Items/PlayerInventory.cs @@ -17,7 +17,7 @@ public SynapseItem this[int index] get => Items[index]; } - public List Items => player.VanillaInventory.UserInventory.Items.Select(x => x.Value.GetSynapseItem()).ToList(); + public List Items => player.VanillaInventory.UserInventory.Items.Select(x => x.Value.GetSynapseItem()).Where(x => x != null).ToList(); public void AddItem(SynapseItem item) => item.PickUp(player); @@ -36,7 +36,7 @@ public void DropAll() try { foreach (var item in Items) - item.Drop(); + item?.Drop(); foreach (var ammo in player.VanillaInventory.UserInventory.ReserveAmmo.ToList()) player.VanillaInventory.ServerDropAmmo(ammo.Key, ammo.Value); diff --git a/Synapse/Api/Items/SynapseItem.cs b/Synapse/Api/Items/SynapseItem.cs index 723d26f0..174433e8 100644 --- a/Synapse/Api/Items/SynapseItem.cs +++ b/Synapse/Api/Items/SynapseItem.cs @@ -297,6 +297,7 @@ public Vector3 Scale } } + private float durabillity = 0; public float Durabillity { get @@ -331,10 +332,16 @@ public float Durabillity break; } - return 0; + return durabillity; } set { + if(State == ItemState.Despawned) + { + durabillity = value; + return; + } + switch (ItemCategory) { case ItemCategory.Radio: @@ -372,6 +379,7 @@ public float Durabillity } } + private uint attachments = 0; public uint WeaponAttachments { get @@ -384,10 +392,16 @@ public uint WeaponAttachments { return armpickup.Status.Attachments; } - return 0; + return attachments; } set { + if (State == ItemState.Despawned) + { + attachments = value; + return; + } + if (ItemBase is Firearm arm) { arm.ApplyAttachmentsCode(value,true); @@ -412,6 +426,8 @@ public void PickUp(Player player) case ItemState.Despawned: player.VanillaInventory.ServerAddItem(ItemType, Serial); + Durabillity = durabillity; + WeaponAttachments = attachments; break; case ItemState.Inventory: @@ -449,6 +465,9 @@ public void Drop(Vector3 position) PickupBase.transform.localScale = Scale; NetworkServer.Spawn(PickupBase.gameObject); PickupBase.InfoReceived(default, info); + + Durabillity = durabillity; + WeaponAttachments = attachments; } break; } @@ -465,6 +484,9 @@ public void Drop() public void Despawn() { + durabillity = Durabillity; + attachments = WeaponAttachments; + DespawnItemBase(); DespawnPickup(); Throwable.DestroyProjectile(); diff --git a/Synapse/Api/MapPoint.cs b/Synapse/Api/MapPoint.cs index 22998e8b..a11d755d 100644 --- a/Synapse/Api/MapPoint.cs +++ b/Synapse/Api/MapPoint.cs @@ -1,5 +1,6 @@ using System; using System.Linq; +using MapGeneration; using UnityEngine; namespace Synapse.Api @@ -62,6 +63,34 @@ public MapPoint(string mappointstring) RelativePosition = new Vector3(x, y, z); } + /// + /// Creates a MapPoint + /// + /// + /// + /// + /// + public MapPoint(RoomName type, float x, float y, float z) + { + var synapseroom = SynapseController.Server.Map.GetRoom(type); + Room = synapseroom ?? throw new Exception("Parsing of string to MapPoint failed because of the roomname"); + RelativePosition = new Vector3(x, y, z); + } + + /// + /// Creates a MapPoint + /// + /// + /// + /// + /// + public MapPoint(string room, float x, float y, float z) + { + var synapseroom = SynapseController.Server.Map.Rooms.FirstOrDefault(r => r.RoomName.ToLower() == room.ToLower()); + Room = synapseroom ?? throw new Exception("Parsing of string to MapPoint failed because of the roomname"); + RelativePosition = new Vector3(x, y, z); + } + /// /// The Room of which the MapPoint is relative too diff --git a/Synapse/Api/Player.cs b/Synapse/Api/Player.cs index 13234f57..81cb8f58 100644 --- a/Synapse/Api/Player.cs +++ b/Synapse/Api/Player.cs @@ -589,7 +589,7 @@ public RoleType RoleType public Room Room { - get => RoomIdUtils.RoomAtPosition(Position).GetSynapseRoom(); + get => RoomIdUtils.RoomAtPosition(Position).GetSynapseRoom() ?? Map.Get.Rooms.OrderBy(x => Vector3.Distance(x.Position, Position)).FirstOrDefault(); set => Position = value.Position; } @@ -667,7 +667,11 @@ public ushort this[AmmoType ammo] return 0; } - set => player.VanillaInventory.UserInventory.ReserveAmmo[(ItemType)ammo] = value; + set + { + player.VanillaInventory.UserInventory.ReserveAmmo[(ItemType)ammo] = value; + player.VanillaInventory.SendAmmoNextFrame = true; + } } } @@ -771,9 +775,9 @@ public SynapseItem ItemInHand { get { - if (VanillaInventory.CurItem == ItemIdentifier.None) return SynapseItem.None; + if (VanillaInventory.CurItem == ItemIdentifier.None || VanillaInventory.CurInstance == null) return SynapseItem.None; - return VanillaInventory.CurInstance.GetSynapseItem(); + return SynapseItem.AllItems[VanillaInventory.CurItem.SerialNumber]; } set { diff --git a/Synapse/Patches/EventsPatches/PlayerPatches/PlayerDamagePatch.cs b/Synapse/Patches/EventsPatches/PlayerPatches/PlayerDamagePatch.cs index cf83977f..e6251202 100644 --- a/Synapse/Patches/EventsPatches/PlayerPatches/PlayerDamagePatch.cs +++ b/Synapse/Patches/EventsPatches/PlayerPatches/PlayerDamagePatch.cs @@ -34,7 +34,7 @@ private static bool HurtPlayer(PlayerStats __instance, out bool __result, Player bool friendlyFire = default; DamageTypes.DamageType damageType = default; - if (!TryPlayerDamageEvent(killer, victim, out (float artificialHealth, float health, bool friendlyFire, DamageTypes.DamageType damageType) temp)) + if (!TryPlayerDamageEvent(ref killer, victim, out (float artificialHealth, float health, bool friendlyFire, DamageTypes.DamageType damageType) temp)) return false; (artificialHealth, health, friendlyFire, damageType) = (temp.artificialHealth, temp.health, temp.friendlyFire, temp.damageType); @@ -367,7 +367,7 @@ void HandleDamage(float artificialHealth, Player victim) victim.PlayerStats.lastHitInfo = info; } - bool TryPlayerDamageEvent(Player killer, Player victim, out (float ArtificialHealth, float Health, bool FriendlyFire, DamageTypes.DamageType DamageType) paramInfo) + bool TryPlayerDamageEvent(ref Player killer, Player victim, out (float ArtificialHealth, float Health, bool FriendlyFire, DamageTypes.DamageType DamageType) paramInfo) { paramInfo.ArtificialHealth = 0; paramInfo.Health = 0; diff --git a/Synapse/Patches/EventsPatches/ScpPatches/Scp079/Scp079BulkPatch.cs b/Synapse/Patches/EventsPatches/ScpPatches/Scp079/Scp079BulkPatch.cs index 6b0d5750..19f85885 100644 --- a/Synapse/Patches/EventsPatches/ScpPatches/Scp079/Scp079BulkPatch.cs +++ b/Synapse/Patches/EventsPatches/ScpPatches/Scp079/Scp079BulkPatch.cs @@ -495,12 +495,6 @@ out var actualResult } } - if (roomInteractablesHashSet.Count == 0 || lockdownInteractable == null || __instance._scheduledUnlocks.Count > 0) - { - string str2 = string.Format("(code: {0}x{1}x{2})", roomInteractablesHashSet.Count, __instance._scheduledUnlocks.Count, (lockdownInteractable == null) ? 0 : 1); - GameCore.Console.AddDebugLog("SCP079", "This room can't be locked down " + str2, MessageImportance.LessImportant, false); - return false; - } if (__instance.CurrentLDCooldown > 0f) { GameCore.Console.AddDebugLog("SCP079", "Lockdown still on cooldown.", MessageImportance.LessImportant, false); @@ -546,15 +540,6 @@ out var actualResult { case Scp079EventMisc.InteractionResult.Allow: { - if (doorHashSet.Count > 0) - { - __instance._scheduledUnlocks.Add(Time.realtimeSinceStartup + __instance.LockdownDuration, doorHashSet); - GameCore.Console.AddDebugLog("SCP079", "Locking " + doorHashSet.Count + " doors", MessageImportance.LeastImportant, false); - } - else - { - GameCore.Console.AddDebugLog("SCP079", "No doors to lock found, code " + roomInteractablesHashSet.Count(x => x.type == Scp079Interactable.InteractableType.Door), MessageImportance.LessImportant, false); - } foreach (FlickerableLightController flickerableLightController in __instance.CurrentRoom.GetComponentsInChildren()) { if (flickerableLightController != null) diff --git a/Synapse/Properties/AssemblyInfo.cs b/Synapse/Properties/AssemblyInfo.cs index debcf636..7883933c 100644 --- a/Synapse/Properties/AssemblyInfo.cs +++ b/Synapse/Properties/AssemblyInfo.cs @@ -5,5 +5,5 @@ [assembly: AssemblyCompany("Synapse-DevTeam")] [assembly: AssemblyProduct("Synapse")] [assembly: AssemblyCopyright("Copyright © Synapse-DevTeam 2021")] -[assembly: AssemblyVersion("2.7.1.0")] -[assembly: AssemblyFileVersion("2.7.1.0")] \ No newline at end of file +[assembly: AssemblyVersion("2.7.2.0")] +[assembly: AssemblyFileVersion("2.7.2.0")] \ No newline at end of file diff --git a/Synapse/SynapseVersion.cs b/Synapse/SynapseVersion.cs index 2e21323c..03d97f91 100644 --- a/Synapse/SynapseVersion.cs +++ b/Synapse/SynapseVersion.cs @@ -7,13 +7,13 @@ public static class SynapseVersion public const int Minor = 7; - public const int Patch = 1; + public const int Patch = 2; public const VersionType Type = VersionType.None; public const string SubVersion = ""; - public const string BasedGameVersion = "11.0.0"; + public const string BasedGameVersion = "11.0.1-2021-halloween-ff7ed68c"; public static bool Debug { get; private set; } = false;