Content update for NetEntities (#18935)
This commit is contained in:
@@ -74,7 +74,7 @@ public sealed partial class MeleeWeaponSystem : SharedMeleeWeaponSystem
|
||||
{
|
||||
if (weapon.Attacking)
|
||||
{
|
||||
RaisePredictiveEvent(new StopAttackEvent(weaponUid));
|
||||
RaisePredictiveEvent(new StopAttackEvent(GetNetEntity(weaponUid)));
|
||||
}
|
||||
}
|
||||
|
||||
@@ -126,7 +126,7 @@ public sealed partial class MeleeWeaponSystem : SharedMeleeWeaponSystem
|
||||
target = screen.GetClickedEntity(mousePos);
|
||||
}
|
||||
|
||||
EntityManager.RaisePredictiveEvent(new DisarmAttackEvent(target, coordinates));
|
||||
EntityManager.RaisePredictiveEvent(new DisarmAttackEvent(GetNetEntity(target), GetNetCoordinates(coordinates)));
|
||||
return;
|
||||
}
|
||||
|
||||
@@ -152,7 +152,7 @@ public sealed partial class MeleeWeaponSystem : SharedMeleeWeaponSystem
|
||||
target = screen.GetClickedEntity(mousePos);
|
||||
}
|
||||
|
||||
RaisePredictiveEvent(new LightAttackEvent(target, weaponUid, coordinates));
|
||||
RaisePredictiveEvent(new LightAttackEvent(GetNetEntity(target), GetNetEntity(weaponUid), GetNetCoordinates(coordinates)));
|
||||
}
|
||||
}
|
||||
|
||||
@@ -182,15 +182,17 @@ public sealed partial class MeleeWeaponSystem : SharedMeleeWeaponSystem
|
||||
return false;
|
||||
}
|
||||
|
||||
var target = GetEntity(ev.Target);
|
||||
|
||||
// They need to either have hands...
|
||||
if (!HasComp<HandsComponent>(ev.Target!.Value))
|
||||
if (!HasComp<HandsComponent>(target!.Value))
|
||||
{
|
||||
// or just be able to be shoved over.
|
||||
if (TryComp<StatusEffectsComponent>(ev.Target!.Value, out var status) && status.AllowedEffects.Contains("KnockedDown"))
|
||||
if (TryComp<StatusEffectsComponent>(target, out var status) && status.AllowedEffects.Contains("KnockedDown"))
|
||||
return true;
|
||||
|
||||
if (Timing.IsFirstTimePredicted && HasComp<MobStateComponent>(ev.Target.Value))
|
||||
PopupSystem.PopupEntity(Loc.GetString("disarm-action-disarmable", ("targetName", ev.Target.Value)), ev.Target.Value);
|
||||
if (Timing.IsFirstTimePredicted && HasComp<MobStateComponent>(target.Value))
|
||||
PopupSystem.PopupEntity(Loc.GetString("disarm-action-disarmable", ("targetName", target.Value)), target.Value);
|
||||
|
||||
return false;
|
||||
}
|
||||
@@ -222,14 +224,16 @@ public sealed partial class MeleeWeaponSystem : SharedMeleeWeaponSystem
|
||||
|
||||
// This should really be improved. GetEntitiesInArc uses pos instead of bounding boxes.
|
||||
// Server will validate it with InRangeUnobstructed.
|
||||
var entities = ArcRayCast(userPos, direction.ToWorldAngle(), component.Angle, distance, userXform.MapID, user).ToList();
|
||||
RaisePredictiveEvent(new HeavyAttackEvent(meleeUid, entities.GetRange(0, Math.Min(MaxTargets, entities.Count)), coordinates));
|
||||
var entities = GetNetEntityList(ArcRayCast(userPos, direction.ToWorldAngle(), component.Angle, distance, userXform.MapID, user).ToList());
|
||||
RaisePredictiveEvent(new HeavyAttackEvent(GetNetEntity(meleeUid), entities.GetRange(0, Math.Min(MaxTargets, entities.Count)), GetNetCoordinates(coordinates)));
|
||||
}
|
||||
|
||||
private void OnMeleeLunge(MeleeLungeEvent ev)
|
||||
{
|
||||
var ent = GetEntity(ev.Entity);
|
||||
|
||||
// Entity might not have been sent by PVS.
|
||||
if (Exists(ev.Entity))
|
||||
DoLunge(ev.Entity, ev.Angle, ev.LocalPos, ev.Animation);
|
||||
if (Exists(ent))
|
||||
DoLunge(ent, ev.Angle, ev.LocalPos, ev.Animation);
|
||||
}
|
||||
}
|
||||
|
||||
@@ -91,7 +91,7 @@ public sealed class TetherGunSystem : SharedTetherGunSystem
|
||||
|
||||
RaisePredictiveEvent(new RequestTetherMoveEvent()
|
||||
{
|
||||
Coordinates = coords
|
||||
Coordinates = GetNetCoordinates(coords)
|
||||
});
|
||||
}
|
||||
|
||||
|
||||
@@ -43,7 +43,7 @@ public sealed partial class GunSystem
|
||||
EnsureShootable(ent.Value);
|
||||
}
|
||||
|
||||
if (ent != null && ent.Value.IsClientSide())
|
||||
if (ent != null && IsClientSide(ent.Value))
|
||||
Del(ent.Value);
|
||||
|
||||
var cycledEvent = new GunCycledEvent();
|
||||
|
||||
@@ -47,7 +47,7 @@ public sealed partial class GunSystem
|
||||
|
||||
// This is dirty af. Prediction moment.
|
||||
// We may be predicting spawning entities and the engine just removes them from the container so we'll just delete them.
|
||||
if (removedArgs.Entity.IsClientSide())
|
||||
if (IsClientSide(removedArgs.Entity))
|
||||
QueueDel(args.Entity);
|
||||
|
||||
// AFAIK the only main alternative is having some client-specific handling via a bool or otherwise for the state.
|
||||
|
||||
@@ -16,10 +16,12 @@ public sealed partial class GunSystem
|
||||
|
||||
private void OnRevolverEntRemove(EntityUid uid, RevolverAmmoProviderComponent component, EntRemovedFromContainerMessage args)
|
||||
{
|
||||
if (args.Container.ID != RevolverContainer) return;
|
||||
if (args.Container.ID != RevolverContainer)
|
||||
return;
|
||||
|
||||
// See ChamberMagazineAmmoProvider
|
||||
if (!args.Entity.IsClientSide()) return;
|
||||
if (!IsClientSide(args.Entity))
|
||||
return;
|
||||
|
||||
QueueDel(args.Entity);
|
||||
}
|
||||
|
||||
@@ -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);
|
||||
|
||||
Reference in New Issue
Block a user