Content update for NetEntities (#18935)

This commit is contained in:
metalgearsloth
2023-09-11 09:42:41 +10:00
committed by GitHub
parent 389c8d1a2c
commit 5a0fc68be2
526 changed files with 3058 additions and 2215 deletions

View File

@@ -16,6 +16,7 @@ using Robust.Client.Player;
using Robust.Shared.Animations;
using Robust.Shared.Input;
using Robust.Shared.Map;
using Robust.Shared.Prototypes;
using Robust.Shared.Utility;
using SharedGunSystem = Content.Shared.Weapons.Ranged.Systems.SharedGunSystem;
@@ -30,6 +31,9 @@ public sealed partial class GunSystem : SharedGunSystem
[Dependency] private readonly InputSystem _inputSystem = default!;
[Dependency] private readonly SharedCameraRecoilSystem _recoil = default!;
[ValidatePrototypeId<EntityPrototype>]
public const string HitscanProto = "HitscanEffect";
public bool SpreadOverlay
{
get => _spreadOverlay;
@@ -76,7 +80,7 @@ public sealed partial class GunSystem : SharedGunSystem
private void OnMuzzleFlash(MuzzleFlashEvent args)
{
CreateEffect(args.Uid, args);
CreateEffect(GetEntity(args.Uid), args);
}
private void OnHitscan(HitscanEvent ev)
@@ -84,13 +88,15 @@ public sealed partial class GunSystem : SharedGunSystem
// ALL I WANT IS AN ANIMATED EFFECT
foreach (var a in ev.Sprites)
{
if (a.Sprite is not SpriteSpecifier.Rsi rsi ||
Deleted(a.coordinates.EntityId))
{
if (a.Sprite is not SpriteSpecifier.Rsi rsi)
continue;
}
var ent = Spawn("HitscanEffect", a.coordinates);
var coords = GetCoordinates(a.coordinates);
if (Deleted(coords.EntityId))
continue;
var ent = Spawn(HitscanProto, coords);
var sprite = Comp<SpriteComponent>(ent);
var xform = Transform(ent);
xform.LocalRotation = a.angle;
@@ -144,7 +150,7 @@ public sealed partial class GunSystem : SharedGunSystem
if (_inputSystem.CmdStates.GetState(useKey) != BoundKeyState.Down)
{
if (gun.ShotCounter != 0)
EntityManager.RaisePredictiveEvent(new RequestStopShootEvent { Gun = gunUid });
EntityManager.RaisePredictiveEvent(new RequestStopShootEvent { Gun = GetNetEntity(gunUid) });
return;
}
@@ -156,7 +162,7 @@ public sealed partial class GunSystem : SharedGunSystem
if (mousePos.MapId == MapId.Nullspace)
{
if (gun.ShotCounter != 0)
EntityManager.RaisePredictiveEvent(new RequestStopShootEvent { Gun = gunUid });
EntityManager.RaisePredictiveEvent(new RequestStopShootEvent { Gun = GetNetEntity(gunUid) });
return;
}
@@ -168,8 +174,8 @@ public sealed partial class GunSystem : SharedGunSystem
EntityManager.RaisePredictiveEvent(new RequestShootEvent
{
Coordinates = coordinates,
Gun = gunUid,
Coordinates = GetNetCoordinates(coordinates),
Gun = GetNetEntity(gunUid),
});
}
@@ -188,7 +194,7 @@ public sealed partial class GunSystem : SharedGunSystem
if (throwItems)
{
Recoil(user, direction, gun.CameraRecoilScalar);
if (ent!.Value.IsClientSide())
if (IsClientSide(ent!.Value))
Del(ent.Value);
else
RemoveShootable(ent.Value);
@@ -214,7 +220,7 @@ public sealed partial class GunSystem : SharedGunSystem
Audio.PlayPredicted(gun.SoundEmpty, gunUid, user);
}
if (ent!.Value.IsClientSide())
if (IsClientSide(ent!.Value))
Del(ent.Value);
break;
@@ -222,7 +228,7 @@ public sealed partial class GunSystem : SharedGunSystem
MuzzleFlash(gunUid, newAmmo, user);
Audio.PlayPredicted(gun.SoundGunshot, gunUid, user);
Recoil(user, direction, gun.CameraRecoilScalar);
if (ent!.Value.IsClientSide())
if (IsClientSide(ent!.Value))
Del(ent.Value);
else
RemoveShootable(ent.Value);