diff --git a/code/ExamplePlayer.cs b/code/ExamplePlayer.cs index 6b73eaba..8bb12322 100644 --- a/code/ExamplePlayer.cs +++ b/code/ExamplePlayer.cs @@ -7,7 +7,7 @@ public partial class ExamplePlayer : PlayerBase public bool SupressPickupNotices { get; set; } TimeSince timeSinceDropped; - public Clothing.Container Clothing = new(); + public ClothingContainer Clothing = new(); public ExamplePlayer() { diff --git a/code/deathmatch_dep/ui/DeathmatchHud.cs b/code/deathmatch_dep/ui/DeathmatchHud.cs index d2b8ad68..c3f95180 100644 --- a/code/deathmatch_dep/ui/DeathmatchHud.cs +++ b/code/deathmatch_dep/ui/DeathmatchHud.cs @@ -12,7 +12,6 @@ public DeathmatchHud() RootPanel.StyleSheet.Load("deathmatch_dep/ui/DeathmatchHud.scss"); - RootPanel.AddChild(); RootPanel.AddChild(); RootPanel.AddChild(); diff --git a/code/deathmatch_dep/ui/InventoryBar.cs b/code/deathmatch_dep/ui/InventoryBar.cs index 2dcb02d9..5dfef99a 100644 --- a/code/deathmatch_dep/ui/InventoryBar.cs +++ b/code/deathmatch_dep/ui/InventoryBar.cs @@ -85,9 +85,9 @@ public void ProcessClientInput(InputBuilder input) // // Fire pressed when we're open - select the weapon and close. // - if (input.Down(InputButton.Attack1)) + if (input.Down(InputButton.PrimaryAttack)) { - input.SuppressButton(InputButton.Attack1); + input.SuppressButton(InputButton.PrimaryAttack); input.ActiveChild = SelectedWeapon; IsOpen = false; Sound.FromScreen("dm.ui_select"); diff --git a/code/deathmatch_dep/ui/KillFeed.cs b/code/deathmatch_dep/ui/KillFeed.cs index de8b8fd3..3069615c 100644 --- a/code/deathmatch_dep/ui/KillFeed.cs +++ b/code/deathmatch_dep/ui/KillFeed.cs @@ -4,14 +4,16 @@ using SWB_Base; using System; -public partial class KillFeed : Sandbox.UI.KillFeed +public partial class KillFeed : Panel { + public static KillFeed Current; + public KillFeed() { StyleSheet.Load("deathmatch_dep/ui/KillFeed.scss"); } - public override Panel AddEntry(long lsteamid, string left, long rsteamid, string right, string method) + public virtual Panel AddEntry(long lsteamid, string left, long rsteamid, string right, string method) { Log.Info($"{left} killed {right} using {method}"); @@ -27,7 +29,7 @@ public override Panel AddEntry(long lsteamid, string left, long rsteamid, string // Temp solution ( get reference to kill weapon icon ) if (method.StartsWith("swb_")) { - var killWeapon = Library.Create(method); // throws error when not found + var killWeapon = TypeLibrary.Create(method); // throws error when not found if (!string.IsNullOrEmpty(killWeapon.Icon)) { diff --git a/code/deathmatch_dep/ui/NameTags.cs b/code/deathmatch_dep/ui/NameTags.cs new file mode 100644 index 00000000..df780e05 --- /dev/null +++ b/code/deathmatch_dep/ui/NameTags.cs @@ -0,0 +1,100 @@ +using System; +using System.Linq; +using Sandbox; +using Sandbox.UI; +using Sandbox.UI.Construct; +using SWB_Base; + +/// +/// When a player is within radius of the camera we add this to their entity. +/// We remove it again when they go out of range. +/// +internal class NameTagComponent : EntityComponent +{ + NameTag NameTag; + + protected override void OnActivate() + { + NameTag = new NameTag(Entity.Client?.Name ?? Entity.Name, Entity.Client?.PlayerId); + } + + protected override void OnDeactivate() + { + NameTag?.Delete(); + NameTag = null; + } + + /// + /// Called for every tag, while it's active + /// + [Event.Frame] + public void FrameUpdate() + { + var tx = Entity.GetAttachment("hat") ?? Entity.Transform; + tx.Position += Vector3.Up * 10.0f; + tx.Rotation = Rotation.LookAt(-CurrentView.Rotation.Forward); + + NameTag.Transform = tx; + } + + /// + /// Called once per frame to manage component creation/deletion + /// + [Event.Frame] + public static void SystemUpdate() + { + // Check if deathmatch hud is active + var hasDeathmatchHud = Sandbox.Entity.All.OfType().Count() > 0; + + if (!hasDeathmatchHud) return; + + foreach (var player in Sandbox.Entity.All.OfType()) + { + if (player.IsLocalPawn && player.IsFirstPersonMode) + { + var c = player.Components.Get(); + c?.Remove(); + continue; + } + + var shouldRemove = player.Position.Distance(CurrentView.Position) > 500; + shouldRemove = shouldRemove || player.LifeState != LifeState.Alive; + shouldRemove = shouldRemove || player.IsDormant; + + if (shouldRemove) + { + var c = player.Components.Get(); + c?.Remove(); + continue; + } + + // Add a component if it doesn't have one + player.Components.GetOrCreate(); + } + } +} + +/// +/// A nametag panel in the world +/// +public class NameTag : WorldPanel +{ + public Panel Avatar; + public Label NameLabel; + + internal NameTag(string title, long? steamid) + { + StyleSheet.Load("deathmatch_dep/ui/Nametags.scss"); + + if (steamid != null) + { + Avatar = Add.Panel("avatar"); + Avatar.Style.SetBackgroundImage($"avatar:{steamid}"); + } + + NameLabel = Add.Label(title, "title"); + + // this is the actual size and shape of the world panel + PanelBounds = new Rect(-500, -100, 1000, 200); + } +} diff --git a/code/deathmatch_dep/ui/Nametags.scss b/code/deathmatch_dep/ui/Nametags.scss new file mode 100644 index 00000000..e47dd787 --- /dev/null +++ b/code/deathmatch_dep/ui/Nametags.scss @@ -0,0 +1,22 @@ +NameTag { + justify-content: center; + align-items: center; + mix-blend-mode: lighten; + + .title { + font-family: Roboto; + font-size: 30px; + white-space: nowrap; + color: #fa2; + mix-blend-mode: lighten; + text-shadow: 0px 0px 5px #f40; + } + + .avatar { + width: 30px; + height: 30px; + margin-right: 15px; + border-radius: 100px; + background-size: cover; + } +} diff --git a/code/swb_base/AttachmentModel.cs b/code/swb_base/AttachmentModel.cs index 5277f807..fba0754e 100644 --- a/code/swb_base/AttachmentModel.cs +++ b/code/swb_base/AttachmentModel.cs @@ -6,7 +6,7 @@ namespace SWB_Base { - public class AttachmentModel : AnimEntity + public class AttachmentModel : AnimatedEntity { public AttachmentModel() { } diff --git a/code/swb_base/BulletBase.Physical.cs b/code/swb_base/BulletBase.Physical.cs index c0a246db..42e8b260 100644 --- a/code/swb_base/BulletBase.Physical.cs +++ b/code/swb_base/BulletBase.Physical.cs @@ -201,12 +201,12 @@ private void BulletHit(TraceResult tr) { var hitRotation = Rotation.From(new Angles(tr.Normal.z, tr.Normal.y, 0) * 90); - DebugOverlay.Circle(tr.EndPosition, hitRotation, bulletSize, IsServer ? Color.Red : Color.Blue, false, maxLifeTime); + DebugOverlay.Circle(tr.EndPosition, hitRotation, bulletSize, IsServer ? Color.Red : Color.Blue, maxLifeTime, false); if (IsServer) { var distance = startPos.Distance(Position) / InchesPerMeter; - DebugOverlay.ScreenText(Rand.Int(40), distance.ToString(CultureInfo.InvariantCulture), maxLifeTime); + DebugOverlay.ScreenText(distance.ToString(CultureInfo.InvariantCulture), Rand.Int(40), maxLifeTime); } } diff --git a/code/swb_base/Commands.cs b/code/swb_base/Commands.cs index 7cf7c0ab..f73e92c7 100644 --- a/code/swb_base/Commands.cs +++ b/code/swb_base/Commands.cs @@ -4,7 +4,7 @@ namespace SWB_Base { internal class Commands { - [ServerCmd("swb_editor_model", Help = "Opens the model editor")] + [ConCmd.Server("swb_editor_model", Help = "Opens the model editor")] public static void OpenModelEditor() { Client client = ConsoleSystem.Caller; @@ -16,7 +16,7 @@ public static void OpenModelEditor() } } - [ServerCmd("swb_editor_attachment", Help = "Opens the attachment editor")] + [ConCmd.Server("swb_editor_attachment", Help = "Opens the attachment editor")] public static void OpenAttachmentEditor() { Client client = ConsoleSystem.Caller; @@ -28,7 +28,7 @@ public static void OpenAttachmentEditor() } } - [ServerCmd("swb_attachment_equip", Help = "Equips an attachment by name")] + [ConCmd.Server("swb_attachment_equip", Help = "Equips an attachment by name")] public static void EquipAttachmentCMD(string name, bool enabled) { Client client = ConsoleSystem.Caller; diff --git a/code/swb_base/PlayerBase.cs b/code/swb_base/PlayerBase.cs index 10f0cf28..bd4a2b35 100644 --- a/code/swb_base/PlayerBase.cs +++ b/code/swb_base/PlayerBase.cs @@ -1,4 +1,5 @@ -using System.Linq; +using System; +using System.Linq; using Sandbox; using SWB_Base.UI; @@ -7,6 +8,9 @@ namespace SWB_Base public partial class PlayerBase : Player { public DamageInfo LastDamage; + private ScreenShakeStruct lastScreenShake; + private TimeSince timeSinceShake; + private float nextShake; public override void TakeDamage(DamageInfo info) { @@ -34,6 +38,27 @@ public override void TakeDamage(DamageInfo info) } } + public override void PostCameraSetup(ref CameraSetup camSetup) + { + base.PostCameraSetup(ref camSetup); + + if (timeSinceShake < lastScreenShake.Length && timeSinceShake > nextShake) + { + var random = new Random(); + camSetup.Position += new Vector3(random.Float(0, lastScreenShake.Size), random.Float(0, lastScreenShake.Size), random.Float(0, lastScreenShake.Size)); + camSetup.Rotation *= Rotation.From(new Angles(random.Float(0, lastScreenShake.Rotation), random.Float(0, lastScreenShake.Rotation), 0)); + + nextShake = timeSinceShake + lastScreenShake.Delay; + } + } + + public virtual void ScreenShake(ScreenShakeStruct screenShake) + { + lastScreenShake = screenShake; + timeSinceShake = 0; + nextShake = 0; + } + public virtual bool Alive() { return Health > 0; diff --git a/code/swb_base/ViewModelBase.cs b/code/swb_base/ViewModelBase.cs index a86339a1..3c34a541 100644 --- a/code/swb_base/ViewModelBase.cs +++ b/code/swb_base/ViewModelBase.cs @@ -45,6 +45,7 @@ public ViewModelBase(WeaponBase weapon) public override void PostCameraSetup(ref CameraSetup camSetup) { base.PostCameraSetup(ref camSetup); + camSetup.FieldOfView = weapon.FOV; Rotation = camSetup.Rotation; Position = camSetup.Position; diff --git a/code/swb_base/WeaponBase.Attack.cs b/code/swb_base/WeaponBase.Attack.cs index 41bd3458..2cec7e5b 100644 --- a/code/swb_base/WeaponBase.Attack.cs +++ b/code/swb_base/WeaponBase.Attack.cs @@ -46,7 +46,7 @@ public virtual bool CanAttack(ClipInfo clipInfo, TimeSince lastAttackTime, Input /// public virtual bool CanPrimaryAttack() { - return CanAttack(Primary, TimeSincePrimaryAttack, InputButton.Attack1); + return CanAttack(Primary, TimeSincePrimaryAttack, InputButton.PrimaryAttack); } /// @@ -54,7 +54,7 @@ public virtual bool CanPrimaryAttack() /// public virtual bool CanSecondaryAttack() { - return CanAttack(Secondary, TimeSinceSecondaryAttack, InputButton.Attack2); + return CanAttack(Secondary, TimeSinceSecondaryAttack, InputButton.SecondaryAttack); } /// @@ -104,7 +104,7 @@ public virtual void Attack(ClipInfo clipInfo, bool isPrimary) } // Player anim - (Owner as AnimEntity).SetAnimParameter("b_attack", true); + (Owner as AnimatedEntity).SetAnimParameter("b_attack", true); // Shoot effects if (IsLocalPawn) @@ -163,7 +163,7 @@ async Task AsyncAttack(ClipInfo clipInfo, bool isPrimary, float delay) TimeSinceSecondaryAttack -= delay; // Player anim - (Owner as AnimEntity).SetAnimParameter("b_attack", true); + (Owner as AnimatedEntity).SetAnimParameter("b_attack", true); // Play pre-fire animation ShootEffects(null, null, GetShootAnimation(clipInfo)); @@ -378,7 +378,7 @@ protected virtual void ShootEffects(string muzzleFlashParticle, string bulletEje if (!string.IsNullOrEmpty(shootAnim)) { ViewModelEntity?.SetAnimParameter(shootAnim, true); - CrosshairPanel?.CreateEvent("fire", (60f / Primary.RPM)); + crosshair?.CreateEvent("fire", (60f / Primary.RPM)); } } } diff --git a/code/swb_base/WeaponBase.Entity.cs b/code/swb_base/WeaponBase.Entity.cs index 793aac54..df1427c8 100644 --- a/code/swb_base/WeaponBase.Entity.cs +++ b/code/swb_base/WeaponBase.Entity.cs @@ -115,7 +115,7 @@ public override void Attack(ClipInfo clipInfo, bool isPrimary) } // Player anim - (Owner as AnimEntity).SetAnimParameter("b_attack", true); + (Owner as AnimatedEntity).SetAnimParameter("b_attack", true); // Shoot effects if (IsLocalPawn) @@ -143,7 +143,7 @@ async Task AsyncAttack(ClipInfo clipInfo, bool isPrimary, float delay) TimeSinceSecondaryAttack -= delay; // Player anim - (Owner as AnimEntity).SetAnimParameter("b_attack", true); + (Owner as AnimatedEntity).SetAnimParameter("b_attack", true); // Play pre-fire animation ShootEffects(null, null, GetShootAnimation(clipInfo)); diff --git a/code/swb_base/WeaponBase.Getters.cs b/code/swb_base/WeaponBase.Getters.cs index 38d148ab..5f89a0ed 100644 --- a/code/swb_base/WeaponBase.Getters.cs +++ b/code/swb_base/WeaponBase.Getters.cs @@ -75,11 +75,13 @@ public virtual float GetRealSpread(float baseSpread = -1) // Aiming if (IsZooming && this is not WeaponBaseShotty) floatMod /= 4; - - if (Owner.GroundEntity == null) { + + if (Owner.GroundEntity == null) + { // Jumping floatMod += 0.75f; - } else if (Owner.Velocity.Length > 100) + } + else if (Owner.Velocity.Length > 100) { // Moving floatMod += 0.25f; diff --git a/code/swb_base/WeaponBase.Melee.cs b/code/swb_base/WeaponBase.Melee.cs index b9ad3082..421a8bb6 100644 --- a/code/swb_base/WeaponBase.Melee.cs +++ b/code/swb_base/WeaponBase.Melee.cs @@ -87,7 +87,7 @@ public virtual void MeleeAttack(float damage, float force, string hitAnimation, } DoMeleeEffects(hitAnimation, sound); - (Owner as AnimEntity).SetAnimParameter("b_attack", true); + (Owner as AnimatedEntity).SetAnimParameter("b_attack", true); if (!hitEntity || !IsServer) return; @@ -112,12 +112,12 @@ private bool CanMelee(TimeSince lastAttackTime, float attackSpeed, InputButton i public override bool CanPrimaryAttack() { - return CanMelee(TimeSincePrimaryAttack, SwingSpeed, InputButton.Attack1); + return CanMelee(TimeSincePrimaryAttack, SwingSpeed, InputButton.PrimaryAttack); } public override bool CanSecondaryAttack() { - return CanMelee(TimeSincePrimaryAttack, StabSpeed, InputButton.Attack2); + return CanMelee(TimeSincePrimaryAttack, StabSpeed, InputButton.SecondaryAttack); } public override void AttackPrimary() diff --git a/code/swb_base/WeaponBase.Shotty.cs b/code/swb_base/WeaponBase.Shotty.cs index fe613b70..d888842d 100644 --- a/code/swb_base/WeaponBase.Shotty.cs +++ b/code/swb_base/WeaponBase.Shotty.cs @@ -15,7 +15,7 @@ public partial class WeaponBaseShotty : WeaponBase /// Duration of the reload insert animatio public virtual float ShellReloadTimeInsert => -1; - /// The shell eject delay after firing + /// The shell eject delay after firing public virtual float ShellEjectDelay => -1; /// Animation for finishing the reload diff --git a/code/swb_base/WeaponBase.Sniper.cs b/code/swb_base/WeaponBase.Sniper.cs index 1db3c2b7..d1dd9414 100644 --- a/code/swb_base/WeaponBase.Sniper.cs +++ b/code/swb_base/WeaponBase.Sniper.cs @@ -116,12 +116,12 @@ public override void Simulate(Client owner) base.Simulate(owner); var shouldTuck = ShouldTuck(); - if (((Input.Pressed(InputButton.Attack2) && !IsReloading && !IsRunning) || (IsZooming && !IsScoped)) && !shouldTuck) + if (((Input.Pressed(InputButton.SecondaryAttack) && !IsReloading && !IsRunning) || (IsZooming && !IsScoped)) && !shouldTuck) { OnScopedStart(); } - if (Input.Released(InputButton.Attack2) || (IsScoped && (IsRunning || shouldTuck))) + if (Input.Released(InputButton.SecondaryAttack) || (IsScoped && (IsRunning || shouldTuck))) { OnScopedEnd(); } diff --git a/code/swb_base/WeaponBase.UI.cs b/code/swb_base/WeaponBase.UI.cs index 5e0928ab..ef75d3fc 100644 --- a/code/swb_base/WeaponBase.UI.cs +++ b/code/swb_base/WeaponBase.UI.cs @@ -15,6 +15,7 @@ public partial class WeaponBase private Panel customizationMenu; private Panel hitmarker; + private Panel crosshair; public override void CreateHudElements() { @@ -25,8 +26,8 @@ public override void CreateHudElements() if (UISettings.ShowCrosshair) { - CrosshairPanel = CreateCrosshair(); - CrosshairPanel.Parent = Local.Hud; + crosshair = CreateCrosshair(); + crosshair.Parent = Local.Hud; } if (UISettings.ShowHitmarker) @@ -54,7 +55,7 @@ public override void CreateHudElements() } } - public new virtual Panel CreateCrosshair() + public virtual Panel CreateCrosshair() { return new Crosshair(); } @@ -66,6 +67,7 @@ public override void DestroyHudElements() if (healthDisplay != null) healthDisplay.Delete(true); if (ammoDisplay != null) ammoDisplay.Delete(true); if (hitmarker != null) hitmarker.Delete(true); + if (crosshair != null) crosshair.Delete(true); if (customizationMenu != null) customizationMenu.Delete(); } diff --git a/code/swb_base/WeaponBase.Var.cs b/code/swb_base/WeaponBase.Var.cs index 3e082c38..ce6359b5 100644 --- a/code/swb_base/WeaponBase.Var.cs +++ b/code/swb_base/WeaponBase.Var.cs @@ -87,10 +87,7 @@ public partial class WeaponBase // Properties // /// Display name - public string PrintName { get { return ClassInfo.Title; } } - - /// Class name - public string ClassName { get { return ClassInfo.Name; } } + public string PrintName { get { return DisplayInfo.For(this).Name; } } /// Extra actions that use certain key combinations to trigger animations public List AnimatedActions { get; set; } diff --git a/code/swb_base/WeaponBase.cs b/code/swb_base/WeaponBase.cs index e4add608..64d72a5e 100644 --- a/code/swb_base/WeaponBase.cs +++ b/code/swb_base/WeaponBase.cs @@ -138,14 +138,14 @@ public override void Simulate(Client player) IsRunning = Input.Down(InputButton.Run) && RunAnimData != AngPos.Zero && Owner.Velocity.Length >= 200; if (Secondary == null && ZoomAnimData != AngPos.Zero && this is not WeaponBaseMelee) - IsZooming = Input.Down(InputButton.Attack2) && !IsRunning && !IsReloading; + IsZooming = Input.Down(InputButton.SecondaryAttack) && !IsRunning && !IsReloading; if (TimeSinceDeployed < General.DrawTime) return; // Burst fire - ResetBurstFireCount(Primary, InputButton.Attack1); - ResetBurstFireCount(Secondary, InputButton.Attack2); + ResetBurstFireCount(Primary, InputButton.PrimaryAttack); + ResetBurstFireCount(Secondary, InputButton.SecondaryAttack); if (!IsReloading || this is WeaponBaseShotty) { @@ -193,7 +193,7 @@ public virtual void Reload() IsReloading = true; // Player anim - (Owner as AnimEntity).SetAnimParameter("b_reload", true); + (Owner as AnimatedEntity).SetAnimParameter("b_reload", true); StartReloadEffects(isEmptyReload); } diff --git a/code/swb_base/bullets/BaseTypes.cs b/code/swb_base/bullets/BaseTypes.cs index 13e527cf..78b9cd1a 100644 --- a/code/swb_base/bullets/BaseTypes.cs +++ b/code/swb_base/bullets/BaseTypes.cs @@ -22,7 +22,7 @@ public class ShotgunBullet : PhysicalBulletBase { public override float Mass => 30f; public override float Drag => 0.5f; - public override float Velocity => 115f; + public override float Velocity => 250f; } // .45 ACP diff --git a/code/swb_base/editor/ui/components/DropDown.cs b/code/swb_base/editor/ui/components/DropDown.cs index cef2d5ee..4216b4e1 100644 --- a/code/swb_base/editor/ui/components/DropDown.cs +++ b/code/swb_base/editor/ui/components/DropDown.cs @@ -11,7 +11,7 @@ namespace SWB_Base.Editor /// /// A UI control which provides multiple options via a dropdown box /// - [Library("swb_Select", Alias = new[] { "swb_Dropdown" })] + [Library("swb_Select"), Alias("swb_Dropdown")] public class DropDown : PopupButton { protected IconPanel DropdownIndicator; diff --git a/code/swb_base/structures/ScreenShake.cs b/code/swb_base/structures/ScreenShake.cs index 4a496e16..a63af3da 100644 --- a/code/swb_base/structures/ScreenShake.cs +++ b/code/swb_base/structures/ScreenShake.cs @@ -1,16 +1,17 @@ -using Sandbox; +using System; +using Sandbox; namespace SWB_Base { public partial class ScreenShake : BaseNetworkable { - /// Duration length + /// Duration length (s) [Net] public float Length { get; set; } = 0f; - /// Shake speed + /// Delay between shakes (s) [Net] - public float Speed { get; set; } = 0f; + public float Delay { get; set; } = 0f; /// Screen disposition amount [Net] @@ -19,5 +20,19 @@ public partial class ScreenShake : BaseNetworkable /// Screen rotation amount [Net] public float Rotation { get; set; } = 0f; + + public override string ToString() + { + return String.Format("Length: {0}, Speed: {1}, Size: {2}, Rotation: {3} ", Length, Delay, Size, Rotation); + } + } + + // For client usage + public struct ScreenShakeStruct + { + public float Length { get; set; } = 0f; + public float Delay { get; set; } = 0f; + public float Size { get; set; } = 0f; + public float Rotation { get; set; } = 0f; } } diff --git a/code/swb_base/ui/Crosshair.cs b/code/swb_base/ui/Crosshair.cs index c1e63219..c4edc134 100644 --- a/code/swb_base/ui/Crosshair.cs +++ b/code/swb_base/ui/Crosshair.cs @@ -5,7 +5,6 @@ namespace SWB_Base.UI { - public class Crosshair : Panel { diff --git a/code/swb_base/util/ScreenUtil.cs b/code/swb_base/util/ScreenUtil.cs index 6c9c4d5e..e4a40ef9 100644 --- a/code/swb_base/util/ScreenUtil.cs +++ b/code/swb_base/util/ScreenUtil.cs @@ -5,30 +5,48 @@ namespace SWB_Base { partial class ScreenUtil { - public static void Shake(float length = 0, float speed = 0, float size = 0, float rotation = 0) + [ClientRpc] + public static void ShakeRPC(float length = 0, float delay = 0, float size = 0, float rotation = 0) + { + Shake(length, delay, size, rotation); + } + + public static void Shake(float length = 0, float delay = 0, float size = 0, float rotation = 0) { - ShakeRPC(length, speed, size, rotation); + if (Local.Pawn is PlayerBase player) + { + var screenShake = new ScreenShakeStruct + { + Length = length, + Delay = delay, + Size = size, + Rotation = rotation + }; + + player.ScreenShake(screenShake); + } } - public static void Shake(To to, float length = 0, float speed = 0, float size = 0, float rotation = 0) + public static void Shake(To to, float length = 0, float delay = 0, float size = 0, float rotation = 0) { - ShakeRPC(to, length, speed, size, rotation); + ShakeRPC(to, length, delay, size, rotation); } public static void Shake(To to, ScreenShake screenShake) { if (screenShake != null) - Shake(to, screenShake.Length, screenShake.Speed, screenShake.Size, screenShake.Rotation); + Shake(to, screenShake.Length, screenShake.Delay, screenShake.Size, screenShake.Rotation); } public static void Shake(ScreenShake screenShake) { - if (screenShake != null) - Shake(screenShake.Length, screenShake.Speed, screenShake.Size, screenShake.Rotation); + + Shake(screenShake.Length, screenShake.Delay, screenShake.Size, screenShake.Rotation); } - public static void ShakeAt(Vector3 origin, float radius = 0, float length = 0, float speed = 0, float size = 0, float rotation = 0) + public static void ShakeAt(Vector3 origin, float radius = 0, float delay = 0, float speed = 0, float size = 0, float rotation = 0) { + LogUtil.Info("HERE"); var objects = Entity.FindInSphere(origin, radius); foreach (var obj in objects) @@ -48,20 +66,14 @@ public static void ShakeAt(Vector3 origin, float radius = 0, float length = 0, f rotation *= distanceMul; size *= distanceMul; - ShakeRPC(To.Single(ply), length, speed, size, rotation); + ShakeRPC(To.Single(ply), delay, speed, size, rotation); } } public static void ShakeAt(Vector3 position, float radius, ScreenShake screenShake) { if (screenShake != null) - ShakeAt(position, radius, screenShake.Length, screenShake.Speed, screenShake.Size, screenShake.Rotation); - } - - [ClientRpc] - public static void ShakeRPC(float length = 0, float speed = 0, float size = 0, float rotation = 0) - { - new Sandbox.ScreenShake.Perlin(length, speed, size, rotation); + ShakeAt(position, radius, screenShake.Length, screenShake.Delay, screenShake.Size, screenShake.Rotation); } } } diff --git a/code/swb_css/AK47.cs b/code/swb_css/AK47.cs index 7304689a..fd6392a7 100644 --- a/code/swb_css/AK47.cs +++ b/code/swb_css/AK47.cs @@ -38,10 +38,10 @@ public AK47() FiringType = FiringType.auto, ScreenShake = new ScreenShake { - Length = 0.5f, - Speed = 4.0f, + Length = 0.08f, + Delay = 0.02f, Size = 0.5f, - Rotation = 0.5f + Rotation = 0.1f }, DryFireSound = "swb_rifle.empty", diff --git a/code/swb_css/AWP.cs b/code/swb_css/AWP.cs index 02292db8..1556df37 100644 --- a/code/swb_css/AWP.cs +++ b/code/swb_css/AWP.cs @@ -49,10 +49,10 @@ public AWP() FiringType = FiringType.semi, ScreenShake = new ScreenShake { - Length = 0.5f, - Speed = 4.0f, - Size = 1f, - Rotation = 0.5f + Length = 0.08f, + Delay = 0.02f, + Size = 0.5f, + Rotation = 0.1f }, DryFireSound = "swb_sniper.empty", diff --git a/code/swb_css/Deagle.cs b/code/swb_css/Deagle.cs index 54f1f760..9bd8d68d 100644 --- a/code/swb_css/Deagle.cs +++ b/code/swb_css/Deagle.cs @@ -37,10 +37,10 @@ public Deagle() FiringType = FiringType.semi, ScreenShake = new ScreenShake { - Length = 0.5f, - Speed = 4.0f, - Size = 1.0f, - Rotation = 0.5f + Length = 0.08f, + Delay = 0.02f, + Size = 0.5f, + Rotation = 0.1f }, DryFireSound = "swb_pistol.empty", diff --git a/code/swb_css/GrenadeHE.cs b/code/swb_css/GrenadeHE.cs index 6760e186..366a6ad4 100644 --- a/code/swb_css/GrenadeHE.cs +++ b/code/swb_css/GrenadeHE.cs @@ -60,10 +60,10 @@ private FiredEntity CreateGrenadeEntity(ClipInfo clipInfo, bool isPrimary) grenade.ExplosionEffect = "weapons/swb/css/grenade_he/particles/grenade_he_explosion.vpcf"; grenade.ExplosionShake = new ScreenShake { - Length = 1f, - Speed = 5f, - Size = 5f, - Rotation = 2f, + Length = 0.5f, + Delay = 0.05f, + Size = 10f, + Rotation = 1f }; return grenade; diff --git a/code/swb_css/M249.cs b/code/swb_css/M249.cs index 508acda5..7b76cd79 100644 --- a/code/swb_css/M249.cs +++ b/code/swb_css/M249.cs @@ -38,10 +38,10 @@ public M249() FiringType = FiringType.auto, ScreenShake = new ScreenShake { - Length = 0.5f, - Speed = 4.0f, - Size = 1.0f, - Rotation = 0.5f + Length = 0.08f, + Delay = 0.02f, + Size = 0.5f, + Rotation = 0.1f }, DryFireSound = "swb_lmg.empty", diff --git a/code/swb_css/M249HE.cs b/code/swb_css/M249HE.cs index 7f8e6396..099d28bc 100644 --- a/code/swb_css/M249HE.cs +++ b/code/swb_css/M249HE.cs @@ -51,10 +51,10 @@ public M249HE() FiringType = FiringType.auto, ScreenShake = new ScreenShake { - Length = 0.5f, - Speed = 4.0f, - Size = 1.0f, - Rotation = 0.5f + Length = 0.08f, + Delay = 0.02f, + Size = 0.5f, + Rotation = 0.1f }, DryFireSound = "swb_lmg.empty", @@ -97,7 +97,7 @@ private FiredEntity CreateGrenadeEntity(ClipInfo clipInfo, bool isPrimary) grenade.ExplosionShake = new ScreenShake { Length = 1f, - Speed = 5f, + Delay = 5f, Size = 5f, Rotation = 2f, }; diff --git a/code/swb_css/M4A1.cs b/code/swb_css/M4A1.cs index 549ec2ba..0be7d90a 100644 --- a/code/swb_css/M4A1.cs +++ b/code/swb_css/M4A1.cs @@ -39,10 +39,10 @@ public M4A1() FiringType = FiringType.auto, ScreenShake = new ScreenShake { - Length = 0.5f, - Speed = 4.0f, + Length = 0.08f, + Delay = 0.02f, Size = 0.5f, - Rotation = 0.5f + Rotation = 0.1f }, DryFireSound = "swb_rifle.empty", diff --git a/code/swb_css/MAC10.cs b/code/swb_css/MAC10.cs index a813da92..6878ec16 100644 --- a/code/swb_css/MAC10.cs +++ b/code/swb_css/MAC10.cs @@ -38,10 +38,10 @@ public MAC10() FiringType = FiringType.auto, ScreenShake = new ScreenShake { - Length = 0.5f, - Speed = 4.0f, - Size = 0.3f, - Rotation = 0.4f + Length = 0.08f, + Delay = 0.02f, + Size = 0.5f, + Rotation = 0.1f }, DryFireSound = "swb_smg.empty", diff --git a/code/swb_css/Super90.cs b/code/swb_css/Super90.cs index 8af8780a..d3a92c74 100644 --- a/code/swb_css/Super90.cs +++ b/code/swb_css/Super90.cs @@ -37,10 +37,10 @@ public Super90() FiringType = FiringType.semi, ScreenShake = new ScreenShake { - Length = 0.5f, - Speed = 4.0f, - Size = 1.0f, - Rotation = 0.5f + Length = 0.08f, + Delay = 0.02f, + Size = 0.5f, + Rotation = 0.1f }, DryFireSound = "swb_shotty.empty", diff --git a/code/swb_explosives/RPG-7.cs b/code/swb_explosives/RPG-7.cs index 1969fd6a..d322433c 100644 --- a/code/swb_explosives/RPG-7.cs +++ b/code/swb_explosives/RPG-7.cs @@ -60,10 +60,10 @@ public RPG7() FiringType = FiringType.semi, ScreenShake = new ScreenShake { - Length = 0.5f, - Speed = 4.0f, - Size = 1.0f, - Rotation = 1f + Length = 0.08f, + Delay = 0.02f, + Size = 2f, + Rotation = 0.2f }, DryFireSound = "swb_lmg.empty", @@ -113,10 +113,10 @@ private FiredEntity CreateRocketEntity(ClipInfo clipInfo, bool isPrimary) }; rocket.ExplosionShake = new ScreenShake { - Length = 1f, - Speed = 5f, - Size = 7f, - Rotation = 3f + Length = 0.5f, + Delay = 0.05f, + Size = 10f, + Rotation = 1f }; return rocket; diff --git a/code/swb_weapons/DEAGLE.cs b/code/swb_weapons/DEAGLE.cs index 99f4aee6..fbfb25db 100644 --- a/code/swb_weapons/DEAGLE.cs +++ b/code/swb_weapons/DEAGLE.cs @@ -48,10 +48,10 @@ public DEAGLE() FiringType = FiringType.semi, ScreenShake = new ScreenShake { - Length = 0.5f, - Speed = 4.0f, - Size = 1.0f, - Rotation = 0.5f + Length = 0.08f, + Delay = 0.02f, + Size = 2f, + Rotation = 0.1f }, DryFireSound = "swb_pistol.empty", diff --git a/code/swb_weapons/FAL.cs b/code/swb_weapons/FAL.cs index e6ecf68c..c58f385a 100644 --- a/code/swb_weapons/FAL.cs +++ b/code/swb_weapons/FAL.cs @@ -49,10 +49,10 @@ public FAL() FiringType = FiringType.semi, ScreenShake = new ScreenShake { - Length = 0.5f, - Speed = 4.0f, - Size = 0.5f, - Rotation = 0.5f + Length = 0.08f, + Delay = 0.02f, + Size = 1f, + Rotation = 0.1f }, DryFireSound = "swb_rifle.empty", diff --git a/code/swb_weapons/L96A1.cs b/code/swb_weapons/L96A1.cs index 52f03bc6..a023007f 100644 --- a/code/swb_weapons/L96A1.cs +++ b/code/swb_weapons/L96A1.cs @@ -62,10 +62,10 @@ public L96A1() FiringType = FiringType.semi, ScreenShake = new ScreenShake { - Length = 0.5f, - Speed = 4.0f, - Size = 1f, - Rotation = 0.5f + Length = 0.08f, + Delay = 0.02f, + Size = 2f, + Rotation = 0.2f }, DryFireSound = "swb_sniper.empty", diff --git a/code/swb_weapons/SPAS12.cs b/code/swb_weapons/SPAS12.cs index b2e50bce..aae04dd9 100644 --- a/code/swb_weapons/SPAS12.cs +++ b/code/swb_weapons/SPAS12.cs @@ -6,7 +6,7 @@ namespace SWB_WEAPONS { - [Library("swb_css_spas12", Title = "SPAS-12")] + [Library("swb_spas12", Title = "SPAS-12")] public class SPAS12 : WeaponBaseShotty { public override int Bucket => 2; @@ -42,10 +42,10 @@ public SPAS12() FiringType = FiringType.semi, ScreenShake = new ScreenShake { - Length = 0.5f, - Speed = 4.0f, - Size = 1.0f, - Rotation = 0.5f + Length = 0.08f, + Delay = 0.02f, + Size = 2f, + Rotation = 0.15f }, DryFireSound = "swb_shotty.empty", diff --git a/code/swb_weapons/UMP45.cs b/code/swb_weapons/UMP45.cs index d00f147b..022324b4 100644 --- a/code/swb_weapons/UMP45.cs +++ b/code/swb_weapons/UMP45.cs @@ -44,10 +44,10 @@ public UMP45() FiringType = FiringType.auto, ScreenShake = new ScreenShake { - Length = 0.4f, - Speed = 3.0f, - Size = 0.35f, - Rotation = 0.35f + Length = 0.08f, + Delay = 0.02f, + Size = 0.5f, + Rotation = 0.1f }, DryFireSound = "swb_smg.empty", diff --git a/weapons/swb/melee/bayonet/sounds/bayonet.slash.vsnd_c b/weapons/swb/melee/bayonet/sounds/bayonet.slash.vsnd_c index 3297947b..f0947526 100644 Binary files a/weapons/swb/melee/bayonet/sounds/bayonet.slash.vsnd_c and b/weapons/swb/melee/bayonet/sounds/bayonet.slash.vsnd_c differ