Fix errors
This commit is contained in:
@@ -31,7 +31,7 @@ namespace Content.Client.DoAfter
|
|||||||
/// </summary>
|
/// </summary>
|
||||||
public const float ExcessTime = 0.5f;
|
public const float ExcessTime = 0.5f;
|
||||||
|
|
||||||
private EntityUid _attachedEntity;
|
private EntityUid? _attachedEntity;
|
||||||
|
|
||||||
public override void Initialize()
|
public override void Initialize()
|
||||||
{
|
{
|
||||||
@@ -51,7 +51,8 @@ namespace Content.Client.DoAfter
|
|||||||
var currentTime = _gameTiming.CurTime;
|
var currentTime = _gameTiming.CurTime;
|
||||||
|
|
||||||
// Can't see any I guess?
|
// Can't see any I guess?
|
||||||
if (_attachedEntity == default || (!EntityManager.EntityExists(_attachedEntity) ? EntityLifeStage.Deleted : EntityManager.GetComponent<MetaDataComponent>(_attachedEntity).EntityLifeStage) >= EntityLifeStage.Deleted)
|
if (_attachedEntity is not {Valid: true} entity ||
|
||||||
|
(!EntityManager.EntityExists(_attachedEntity.Value) ? EntityLifeStage.Deleted : EntityManager.GetComponent<MetaDataComponent>(entity).EntityLifeStage) >= EntityLifeStage.Deleted)
|
||||||
return;
|
return;
|
||||||
|
|
||||||
var viewbox = _eyeManager.GetWorldViewport().Enlarged(2.0f);
|
var viewbox = _eyeManager.GetWorldViewport().Enlarged(2.0f);
|
||||||
@@ -62,19 +63,19 @@ namespace Content.Client.DoAfter
|
|||||||
var compPos = EntityManager.GetComponent<TransformComponent>(comp.Owner).WorldPosition;
|
var compPos = EntityManager.GetComponent<TransformComponent>(comp.Owner).WorldPosition;
|
||||||
|
|
||||||
if (doAfters.Count == 0 ||
|
if (doAfters.Count == 0 ||
|
||||||
EntityManager.GetComponent<TransformComponent>(comp.Owner).MapID != EntityManager.GetComponent<TransformComponent>(_attachedEntity).MapID ||
|
EntityManager.GetComponent<TransformComponent>(comp.Owner).MapID != EntityManager.GetComponent<TransformComponent>(entity).MapID ||
|
||||||
!viewbox.Contains(compPos))
|
!viewbox.Contains(compPos))
|
||||||
{
|
{
|
||||||
comp.Disable();
|
comp.Disable();
|
||||||
continue;
|
continue;
|
||||||
}
|
}
|
||||||
|
|
||||||
var range = (compPos - EntityManager.GetComponent<TransformComponent>(_attachedEntity).WorldPosition).Length +
|
var range = (compPos - EntityManager.GetComponent<TransformComponent>(entity).WorldPosition).Length +
|
||||||
0.01f;
|
0.01f;
|
||||||
|
|
||||||
if (comp.Owner != _attachedEntity &&
|
if (comp.Owner != _attachedEntity &&
|
||||||
!ExamineSystemShared.InRangeUnOccluded(
|
!ExamineSystemShared.InRangeUnOccluded(
|
||||||
EntityManager.GetComponent<TransformComponent>(_attachedEntity).MapPosition,
|
EntityManager.GetComponent<TransformComponent>(entity).MapPosition,
|
||||||
EntityManager.GetComponent<TransformComponent>(comp.Owner).MapPosition, range,
|
EntityManager.GetComponent<TransformComponent>(comp.Owner).MapPosition, range,
|
||||||
entity => entity == comp.Owner || entity == _attachedEntity))
|
entity => entity == comp.Owner || entity == _attachedEntity))
|
||||||
{
|
{
|
||||||
|
|||||||
@@ -15,9 +15,10 @@ namespace Content.Client.HealthOverlay
|
|||||||
public class HealthOverlaySystem : EntitySystem
|
public class HealthOverlaySystem : EntitySystem
|
||||||
{
|
{
|
||||||
[Dependency] private readonly IEyeManager _eyeManager = default!;
|
[Dependency] private readonly IEyeManager _eyeManager = default!;
|
||||||
|
[Dependency] private readonly IEntityManager _entities = default!;
|
||||||
|
|
||||||
private readonly Dictionary<EntityUid, HealthOverlayGui> _guis = new();
|
private readonly Dictionary<EntityUid, HealthOverlayGui> _guis = new();
|
||||||
private EntityUid _attachedEntity;
|
private EntityUid? _attachedEntity;
|
||||||
private bool _enabled;
|
private bool _enabled;
|
||||||
|
|
||||||
public bool Enabled
|
public bool Enabled
|
||||||
@@ -72,7 +73,7 @@ namespace Content.Client.HealthOverlay
|
|||||||
return;
|
return;
|
||||||
}
|
}
|
||||||
|
|
||||||
if (_attachedEntity == null || (!IoCManager.Resolve<IEntityManager>().EntityExists(_attachedEntity) ? EntityLifeStage.Deleted : IoCManager.Resolve<IEntityManager>().GetComponent<MetaDataComponent>(_attachedEntity).EntityLifeStage) >= EntityLifeStage.Deleted)
|
if (_attachedEntity == null || (!_entities.EntityExists(_attachedEntity.Value) ? EntityLifeStage.Deleted : _entities.GetComponent<MetaDataComponent>(_attachedEntity.Value).EntityLifeStage) >= EntityLifeStage.Deleted)
|
||||||
{
|
{
|
||||||
return;
|
return;
|
||||||
}
|
}
|
||||||
@@ -83,8 +84,8 @@ namespace Content.Client.HealthOverlay
|
|||||||
{
|
{
|
||||||
var entity = mobState.Owner;
|
var entity = mobState.Owner;
|
||||||
|
|
||||||
if (IoCManager.Resolve<IEntityManager>().GetComponent<TransformComponent>(_attachedEntity).MapID != IoCManager.Resolve<IEntityManager>().GetComponent<TransformComponent>(entity).MapID ||
|
if (_entities.GetComponent<TransformComponent>(_attachedEntity.Value).MapID != _entities.GetComponent<TransformComponent>(entity).MapID ||
|
||||||
!viewBox.Contains(IoCManager.Resolve<IEntityManager>().GetComponent<TransformComponent>(entity).WorldPosition))
|
!viewBox.Contains(_entities.GetComponent<TransformComponent>(entity).WorldPosition))
|
||||||
{
|
{
|
||||||
if (_guis.TryGetValue(entity, out var oldGui))
|
if (_guis.TryGetValue(entity, out var oldGui))
|
||||||
{
|
{
|
||||||
|
|||||||
@@ -44,8 +44,7 @@ namespace Content.Client.Physics.Controllers
|
|||||||
// If we're being pulled then we won't predict anything and will receive server lerps so it looks way smoother.
|
// If we're being pulled then we won't predict anything and will receive server lerps so it looks way smoother.
|
||||||
if (EntityManager.TryGetComponent(player, out SharedPullableComponent? pullableComp))
|
if (EntityManager.TryGetComponent(player, out SharedPullableComponent? pullableComp))
|
||||||
{
|
{
|
||||||
var puller = pullableComp.Puller;
|
if (pullableComp.Puller is {Valid: true} puller && EntityManager.TryGetComponent<PhysicsComponent?>(puller, out var pullerBody))
|
||||||
if (puller != default && EntityManager.TryGetComponent<PhysicsComponent?>(puller, out var pullerBody))
|
|
||||||
{
|
{
|
||||||
pullerBody.Predict = false;
|
pullerBody.Predict = false;
|
||||||
body.Predict = false;
|
body.Predict = false;
|
||||||
@@ -55,9 +54,7 @@ namespace Content.Client.Physics.Controllers
|
|||||||
// If we're pulling a mob then make sure that isn't predicted so it doesn't fuck our velocity up.
|
// If we're pulling a mob then make sure that isn't predicted so it doesn't fuck our velocity up.
|
||||||
if (EntityManager.TryGetComponent(player, out SharedPullerComponent? pullerComp))
|
if (EntityManager.TryGetComponent(player, out SharedPullerComponent? pullerComp))
|
||||||
{
|
{
|
||||||
var pulling = pullerComp.Pulling;
|
if (pullerComp.Pulling is {Valid: true} pulling &&
|
||||||
|
|
||||||
if (pulling != default &&
|
|
||||||
EntityManager.HasComponent<MobStateComponent>(pulling) &&
|
EntityManager.HasComponent<MobStateComponent>(pulling) &&
|
||||||
EntityManager.TryGetComponent(pulling, out PhysicsComponent? pullingBody))
|
EntityManager.TryGetComponent(pulling, out PhysicsComponent? pullingBody))
|
||||||
{
|
{
|
||||||
|
|||||||
@@ -91,14 +91,14 @@ namespace Content.IntegrationTests.Tests
|
|||||||
|
|
||||||
server.Post(() =>
|
server.Post(() =>
|
||||||
{
|
{
|
||||||
IoCManager.Resolve<IEntityManager>().DeleteEntity((EntityUid) playerEnt);
|
IoCManager.Resolve<IEntityManager>().DeleteEntity(playerEnt);
|
||||||
});
|
});
|
||||||
|
|
||||||
server.RunTicks(1);
|
server.RunTicks(1);
|
||||||
|
|
||||||
server.Assert(() =>
|
server.Assert(() =>
|
||||||
{
|
{
|
||||||
Assert.That(IoCManager.Resolve<IEntityManager>().EntityExists(mind.CurrentEntity), Is.True);
|
Assert.That(IoCManager.Resolve<IEntityManager>().EntityExists(mind.CurrentEntity!.Value), Is.True);
|
||||||
});
|
});
|
||||||
|
|
||||||
await server.WaitIdleAsync();
|
await server.WaitIdleAsync();
|
||||||
@@ -149,7 +149,7 @@ namespace Content.IntegrationTests.Tests
|
|||||||
|
|
||||||
server.Assert(() =>
|
server.Assert(() =>
|
||||||
{
|
{
|
||||||
Assert.That(IoCManager.Resolve<IEntityManager>().EntityExists(mind.CurrentEntity), Is.True);
|
Assert.That(IoCManager.Resolve<IEntityManager>().EntityExists(mind.CurrentEntity!.Value), Is.True);
|
||||||
Assert.That(mind.CurrentEntity, Is.Not.EqualTo(playerEnt));
|
Assert.That(mind.CurrentEntity, Is.Not.EqualTo(playerEnt));
|
||||||
});
|
});
|
||||||
|
|
||||||
|
|||||||
@@ -49,7 +49,7 @@ namespace Content.Server.Chat.Commands
|
|||||||
return;
|
return;
|
||||||
}
|
}
|
||||||
|
|
||||||
chat.EntityMe(mindComponent.OwnedEntity, action);
|
chat.EntityMe(mindComponent.OwnedEntity.Value, action);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|||||||
@@ -62,11 +62,11 @@ namespace Content.Server.Chat.Commands
|
|||||||
return;
|
return;
|
||||||
}
|
}
|
||||||
|
|
||||||
var emote = chatSanitizer.TrySanitizeOutSmilies(message, mindComponent.OwnedEntity, out var sanitized, out var emoteStr);
|
var emote = chatSanitizer.TrySanitizeOutSmilies(message, mindComponent.OwnedEntity.Value, out var sanitized, out var emoteStr);
|
||||||
if (sanitized.Length != 0)
|
if (sanitized.Length != 0)
|
||||||
chat.EntitySay(mindComponent.OwnedEntity, sanitized);
|
chat.EntitySay(mindComponent.OwnedEntity.Value, sanitized);
|
||||||
if (emote)
|
if (emote)
|
||||||
chat.EntityMe(mindComponent.OwnedEntity, emoteStr!);
|
chat.EntityMe(mindComponent.OwnedEntity.Value, emoteStr!);
|
||||||
}
|
}
|
||||||
|
|
||||||
}
|
}
|
||||||
|
|||||||
@@ -288,10 +288,10 @@ namespace Content.Server.Chemistry.EntitySystems
|
|||||||
UpdateChemicals(uid, solution);
|
UpdateChemicals(uid, solution);
|
||||||
}
|
}
|
||||||
|
|
||||||
public FixedPoint2 GetReagentQuantity(EntityUid Owner, string reagentId)
|
public FixedPoint2 GetReagentQuantity(EntityUid owner, string reagentId)
|
||||||
{
|
{
|
||||||
var reagentQuantity = FixedPoint2.New(0);
|
var reagentQuantity = FixedPoint2.New(0);
|
||||||
if (EntityManager.EntityExists(Owner)
|
if (EntityManager.EntityExists(owner)
|
||||||
&& IoCManager.Resolve<IEntityManager>().TryGetComponent(owner, out SolutionContainerManagerComponent? managerComponent))
|
&& IoCManager.Resolve<IEntityManager>().TryGetComponent(owner, out SolutionContainerManagerComponent? managerComponent))
|
||||||
{
|
{
|
||||||
foreach (var solution in managerComponent.Solutions.Values)
|
foreach (var solution in managerComponent.Solutions.Values)
|
||||||
|
|||||||
@@ -22,10 +22,10 @@ namespace Content.Server.Chemistry.EntitySystems
|
|||||||
SubscribeLocalEvent<TransformableContainerComponent, SolutionChangedEvent>(OnSolutionChange);
|
SubscribeLocalEvent<TransformableContainerComponent, SolutionChangedEvent>(OnSolutionChange);
|
||||||
}
|
}
|
||||||
|
|
||||||
private void OnSolutionChange(EntityUid uid, TransformableContainerComponent component,
|
private void OnSolutionChange(EntityUid owner, TransformableContainerComponent component,
|
||||||
SolutionChangedEvent args)
|
SolutionChangedEvent args)
|
||||||
{
|
{
|
||||||
if (!_solutionsSystem.TryGetFitsInDispenser(uid, out var solution))
|
if (!_solutionsSystem.TryGetFitsInDispenser(owner, out var solution))
|
||||||
return;
|
return;
|
||||||
//Transform container into initial state when emptied
|
//Transform container into initial state when emptied
|
||||||
if (component.CurrentReagent != null && solution.Contents.Count == 0)
|
if (component.CurrentReagent != null && solution.Contents.Count == 0)
|
||||||
@@ -50,15 +50,14 @@ namespace Content.Server.Chemistry.EntitySystems
|
|||||||
var spriteSpec =
|
var spriteSpec =
|
||||||
new SpriteSpecifier.Rsi(
|
new SpriteSpecifier.Rsi(
|
||||||
new ResourcePath("Objects/Consumable/Drinks/" + proto.SpriteReplacementPath), "icon");
|
new ResourcePath("Objects/Consumable/Drinks/" + proto.SpriteReplacementPath), "icon");
|
||||||
var Owner
|
if (IoCManager.Resolve<IEntityManager>().TryGetComponent(owner, out SpriteComponent? sprite))
|
||||||
if (IoCManager.Resolve<IEntityManager>().TryGetComponent(ownerEntity, out SpriteComponent? sprite))
|
|
||||||
{
|
{
|
||||||
sprite?.LayerSetSprite(0, spriteSpec);
|
sprite?.LayerSetSprite(0, spriteSpec);
|
||||||
}
|
}
|
||||||
|
|
||||||
string val = proto.Name + " glass";
|
string val = proto.Name + " glass";
|
||||||
IoCManager.Resolve<IEntityManager>().GetComponent<MetaDataComponent>(ownerEntity).EntityName = val;
|
IoCManager.Resolve<IEntityManager>().GetComponent<MetaDataComponent>(owner).EntityName = val;
|
||||||
IoCManager.Resolve<IEntityManager>().GetComponent<MetaDataComponent>(ownerEntity).EntityDescription = proto.Description;
|
IoCManager.Resolve<IEntityManager>().GetComponent<MetaDataComponent>(owner).EntityDescription = proto.Description;
|
||||||
component.CurrentReagent = proto;
|
component.CurrentReagent = proto;
|
||||||
component.Transformed = true;
|
component.Transformed = true;
|
||||||
}
|
}
|
||||||
|
|||||||
@@ -27,7 +27,7 @@ public class DoAction : ReagentEffect
|
|||||||
if (actions.IsGranted(proto.ActionType))
|
if (actions.IsGranted(proto.ActionType))
|
||||||
{
|
{
|
||||||
var attempt = new ActionAttempt(proto);
|
var attempt = new ActionAttempt(proto);
|
||||||
attempt.DoInstantAction(args.args.SolutionEntity)
|
attempt.DoInstantAction(args.SolutionEntity);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|||||||
@@ -22,6 +22,8 @@ namespace Content.Server.Climbing.Components
|
|||||||
[ComponentReference(typeof(IClimbable))]
|
[ComponentReference(typeof(IClimbable))]
|
||||||
public class ClimbableComponent : SharedClimbableComponent
|
public class ClimbableComponent : SharedClimbableComponent
|
||||||
{
|
{
|
||||||
|
[Dependency] private readonly IEntityManager _entities = default!;
|
||||||
|
|
||||||
/// <summary>
|
/// <summary>
|
||||||
/// The time it takes to climb onto the entity.
|
/// The time it takes to climb onto the entity.
|
||||||
/// </summary>
|
/// </summary>
|
||||||
@@ -35,7 +37,7 @@ namespace Content.Server.Climbing.Components
|
|||||||
|
|
||||||
if (!Owner.EnsureComponent(out PhysicsComponent _))
|
if (!Owner.EnsureComponent(out PhysicsComponent _))
|
||||||
{
|
{
|
||||||
Logger.Warning($"Entity {IoCManager.Resolve<IEntityManager>().GetComponent<MetaDataComponent>(Owner).EntityName} at {IoCManager.Resolve<IEntityManager>().GetComponent<TransformComponent>(Owner).MapPosition} didn't have a {nameof(PhysicsComponent)}");
|
Logger.Warning($"Entity {_entities.GetComponent<MetaDataComponent>(Owner).EntityName} at {_entities.GetComponent<TransformComponent>(Owner).MapPosition} didn't have a {nameof(PhysicsComponent)}");
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
@@ -73,8 +75,8 @@ namespace Content.Server.Climbing.Components
|
|||||||
return false;
|
return false;
|
||||||
}
|
}
|
||||||
|
|
||||||
if (!IoCManager.Resolve<IEntityManager>().HasComponent<ClimbingComponent>(user) ||
|
if (!_entities.HasComponent<ClimbingComponent>(user) ||
|
||||||
!IoCManager.Resolve<IEntityManager>().TryGetComponent(user, out SharedBodyComponent? body))
|
!_entities.TryGetComponent(user, out SharedBodyComponent? body))
|
||||||
{
|
{
|
||||||
reason = Loc.GetString("comp-climbable-cant-climb");
|
reason = Loc.GetString("comp-climbable-cant-climb");
|
||||||
return false;
|
return false;
|
||||||
@@ -113,7 +115,7 @@ namespace Content.Server.Climbing.Components
|
|||||||
return false;
|
return false;
|
||||||
}
|
}
|
||||||
|
|
||||||
if (target == null || !IoCManager.Resolve<IEntityManager>().HasComponent<ClimbingComponent>(dragged))
|
if (target == null || !_entities.HasComponent<ClimbingComponent>(dragged))
|
||||||
{
|
{
|
||||||
reason = Loc.GetString("comp-climbable-cant-climb");
|
reason = Loc.GetString("comp-climbable-cant-climb");
|
||||||
return false;
|
return false;
|
||||||
@@ -158,14 +160,14 @@ namespace Content.Server.Climbing.Components
|
|||||||
|
|
||||||
var result = await EntitySystem.Get<DoAfterSystem>().WaitDoAfter(doAfterEventArgs);
|
var result = await EntitySystem.Get<DoAfterSystem>().WaitDoAfter(doAfterEventArgs);
|
||||||
|
|
||||||
if (result != DoAfterStatus.Cancelled && IoCManager.Resolve<IEntityManager>().TryGetComponent(entityToMove, out PhysicsComponent? body) && body.Fixtures.Count >= 1)
|
if (result != DoAfterStatus.Cancelled && _entities.TryGetComponent(entityToMove, out PhysicsComponent? body) && body.Fixtures.Count >= 1)
|
||||||
{
|
{
|
||||||
var entityPos = IoCManager.Resolve<IEntityManager>().GetComponent<TransformComponent>(entityToMove).WorldPosition;
|
var entityPos = _entities.GetComponent<TransformComponent>(entityToMove).WorldPosition;
|
||||||
|
|
||||||
var direction = (IoCManager.Resolve<IEntityManager>().GetComponent<TransformComponent>(Owner).WorldPosition - entityPos).Normalized;
|
var direction = (_entities.GetComponent<TransformComponent>(Owner).WorldPosition - entityPos).Normalized;
|
||||||
var endPoint = IoCManager.Resolve<IEntityManager>().GetComponent<TransformComponent>(Owner).WorldPosition;
|
var endPoint = _entities.GetComponent<TransformComponent>(Owner).WorldPosition;
|
||||||
|
|
||||||
var climbMode = IoCManager.Resolve<IEntityManager>().GetComponent<ClimbingComponent>(entityToMove);
|
var climbMode = _entities.GetComponent<ClimbingComponent>(entityToMove);
|
||||||
climbMode.IsClimbing = true;
|
climbMode.IsClimbing = true;
|
||||||
|
|
||||||
if (MathF.Abs(direction.X) < 0.6f) // user climbed mostly vertically so lets make it a clean straight line
|
if (MathF.Abs(direction.X) < 0.6f) // user climbed mostly vertically so lets make it a clean straight line
|
||||||
@@ -192,7 +194,7 @@ namespace Content.Server.Climbing.Components
|
|||||||
|
|
||||||
public async void TryClimb(EntityUid user)
|
public async void TryClimb(EntityUid user)
|
||||||
{
|
{
|
||||||
if (!IoCManager.Resolve<IEntityManager>().TryGetComponent(user, out ClimbingComponent? climbingComponent) || climbingComponent.IsClimbing)
|
if (!_entities.TryGetComponent(user, out ClimbingComponent? climbingComponent) || climbingComponent.IsClimbing)
|
||||||
return;
|
return;
|
||||||
|
|
||||||
var doAfterEventArgs = new DoAfterEventArgs(user, _climbDelay, default, Owner)
|
var doAfterEventArgs = new DoAfterEventArgs(user, _climbDelay, default, Owner)
|
||||||
@@ -205,24 +207,24 @@ namespace Content.Server.Climbing.Components
|
|||||||
|
|
||||||
var result = await EntitySystem.Get<DoAfterSystem>().WaitDoAfter(doAfterEventArgs);
|
var result = await EntitySystem.Get<DoAfterSystem>().WaitDoAfter(doAfterEventArgs);
|
||||||
|
|
||||||
if (result != DoAfterStatus.Cancelled && IoCManager.Resolve<IEntityManager>().TryGetComponent(user, out PhysicsComponent? body) && body.Fixtures.Count >= 1)
|
if (result != DoAfterStatus.Cancelled && _entities.TryGetComponent(user, out PhysicsComponent? body) && body.Fixtures.Count >= 1)
|
||||||
{
|
{
|
||||||
// TODO: Remove the copy-paste code
|
// TODO: Remove the copy-paste code
|
||||||
var userPos = IoCManager.Resolve<IEntityManager>().GetComponent<TransformComponent>(user).WorldPosition;
|
var userPos = _entities.GetComponent<TransformComponent>(user).WorldPosition;
|
||||||
|
|
||||||
var direction = (IoCManager.Resolve<IEntityManager>().GetComponent<TransformComponent>(Owner).WorldPosition - userPos).Normalized;
|
var direction = (_entities.GetComponent<TransformComponent>(Owner).WorldPosition - userPos).Normalized;
|
||||||
var endPoint = IoCManager.Resolve<IEntityManager>().GetComponent<TransformComponent>(Owner).WorldPosition;
|
var endPoint = _entities.GetComponent<TransformComponent>(Owner).WorldPosition;
|
||||||
|
|
||||||
var climbMode = IoCManager.Resolve<IEntityManager>().GetComponent<ClimbingComponent>(user);
|
var climbMode = _entities.GetComponent<ClimbingComponent>(user);
|
||||||
climbMode.IsClimbing = true;
|
climbMode.IsClimbing = true;
|
||||||
|
|
||||||
if (MathF.Abs(direction.X) < 0.6f) // user climbed mostly vertically so lets make it a clean straight line
|
if (MathF.Abs(direction.X) < 0.6f) // user climbed mostly vertically so lets make it a clean straight line
|
||||||
{
|
{
|
||||||
endPoint = new Vector2(IoCManager.Resolve<IEntityManager>().GetComponent<TransformComponent>(user).WorldPosition.X, endPoint.Y);
|
endPoint = new Vector2(_entities.GetComponent<TransformComponent>(user).WorldPosition.X, endPoint.Y);
|
||||||
}
|
}
|
||||||
else if (MathF.Abs(direction.Y) < 0.6f) // user climbed mostly horizontally so lets make it a clean straight line
|
else if (MathF.Abs(direction.Y) < 0.6f) // user climbed mostly horizontally so lets make it a clean straight line
|
||||||
{
|
{
|
||||||
endPoint = new Vector2(endPoint.X, IoCManager.Resolve<IEntityManager>().GetComponent<TransformComponent>(user).WorldPosition.Y);
|
endPoint = new Vector2(endPoint.X, _entities.GetComponent<TransformComponent>(user).WorldPosition.Y);
|
||||||
}
|
}
|
||||||
|
|
||||||
climbMode.TryMoveTo(userPos, endPoint);
|
climbMode.TryMoveTo(userPos, endPoint);
|
||||||
|
|||||||
@@ -34,9 +34,9 @@ namespace Content.Server.Cloning
|
|||||||
|
|
||||||
internal void TransferMindToClone(Mind.Mind mind)
|
internal void TransferMindToClone(Mind.Mind mind)
|
||||||
{
|
{
|
||||||
if (!ClonesWaitingForMind.TryGetValue(mind, out var entityUid) ||
|
if (!ClonesWaitingForMind.TryGetValue(mind, out var entity) ||
|
||||||
!EntityManager.EntityExists(entityUid) ||
|
!EntityManager.EntityExists(entity) ||
|
||||||
!IoCManager.Resolve<IEntityManager>().TryGetComponent(entity, out MindComponent? mindComp) ||
|
!EntityManager.TryGetComponent(entity, out MindComponent? mindComp) ||
|
||||||
mindComp.Mind != null)
|
mindComp.Mind != null)
|
||||||
return;
|
return;
|
||||||
|
|
||||||
@@ -48,7 +48,7 @@ namespace Content.Server.Cloning
|
|||||||
private void HandleActivate(EntityUid uid, CloningPodComponent component, ActivateInWorldEvent args)
|
private void HandleActivate(EntityUid uid, CloningPodComponent component, ActivateInWorldEvent args)
|
||||||
{
|
{
|
||||||
if (!component.Powered ||
|
if (!component.Powered ||
|
||||||
!IoCManager.Resolve<IEntityManager>().TryGetComponent(args.User, out ActorComponent? actor))
|
!EntityManager.TryGetComponent(args.User, out ActorComponent? actor))
|
||||||
{
|
{
|
||||||
return;
|
return;
|
||||||
}
|
}
|
||||||
@@ -60,10 +60,10 @@ namespace Content.Server.Cloning
|
|||||||
{
|
{
|
||||||
if (component.Parent == EntityUid.Invalid ||
|
if (component.Parent == EntityUid.Invalid ||
|
||||||
!EntityManager.EntityExists(component.Parent) ||
|
!EntityManager.EntityExists(component.Parent) ||
|
||||||
!IoCManager.Resolve<IEntityManager>().TryGetComponent<CloningPodComponent?>(parent, out var cloningPodComponent) ||
|
!EntityManager.TryGetComponent<CloningPodComponent?>(component.Parent, out var cloningPodComponent) ||
|
||||||
component.Owner != cloningPodComponent.BodyContainer?.ContainedEntity)
|
component.Owner != cloningPodComponent.BodyContainer?.ContainedEntity)
|
||||||
{
|
{
|
||||||
IoCManager.Resolve<IEntityManager>().RemoveComponent<BeingClonedComponent>(component.Owner);
|
EntityManager.RemoveComponent<BeingClonedComponent>(component.Owner);
|
||||||
return;
|
return;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|||||||
@@ -23,10 +23,12 @@ namespace Content.Server.Cloning.Components
|
|||||||
public class CloningPodComponent : SharedCloningPodComponent
|
public class CloningPodComponent : SharedCloningPodComponent
|
||||||
{
|
{
|
||||||
[Dependency] private readonly IPlayerManager _playerManager = null!;
|
[Dependency] private readonly IPlayerManager _playerManager = null!;
|
||||||
|
[Dependency] private readonly IEntityManager _entities = default!;
|
||||||
|
|
||||||
[Dependency] private readonly EuiManager _euiManager = null!;
|
[Dependency] private readonly EuiManager _euiManager = null!;
|
||||||
|
|
||||||
[ViewVariables]
|
[ViewVariables]
|
||||||
public bool Powered => !IoCManager.Resolve<IEntityManager>().TryGetComponent(Owner, out ApcPowerReceiverComponent? receiver) || receiver.Powered;
|
public bool Powered => !_entities.TryGetComponent(Owner, out ApcPowerReceiverComponent? receiver) || receiver.Powered;
|
||||||
|
|
||||||
[ViewVariables]
|
[ViewVariables]
|
||||||
public BoundUserInterface? UserInterface =>
|
public BoundUserInterface? UserInterface =>
|
||||||
@@ -70,7 +72,7 @@ namespace Content.Server.Cloning.Components
|
|||||||
|
|
||||||
private void UpdateAppearance()
|
private void UpdateAppearance()
|
||||||
{
|
{
|
||||||
if (IoCManager.Resolve<IEntityManager>().TryGetComponent(Owner, out AppearanceComponent? appearance))
|
if (_entities.TryGetComponent(Owner, out AppearanceComponent? appearance))
|
||||||
{
|
{
|
||||||
appearance.SetData(CloningPodVisuals.Status, Status);
|
appearance.SetData(CloningPodVisuals.Status, Status);
|
||||||
}
|
}
|
||||||
@@ -105,12 +107,12 @@ namespace Content.Server.Cloning.Components
|
|||||||
|
|
||||||
var mind = dna.Mind;
|
var mind = dna.Mind;
|
||||||
|
|
||||||
if (cloningSystem.ClonesWaitingForMind.TryGetValue(mind, out var cloneUid))
|
if (cloningSystem.ClonesWaitingForMind.TryGetValue(mind, out var clone))
|
||||||
{
|
{
|
||||||
if (IoCManager.Resolve<IEntityManager>().EntityExists(cloneUid) &&
|
if (_entities.EntityExists(clone) &&
|
||||||
IoCManager.Resolve<IEntityManager>().TryGetComponent<MobStateComponent?>(clone, out var cloneState) &&
|
_entities.TryGetComponent<MobStateComponent?>(clone, out var cloneState) &&
|
||||||
!cloneState.IsDead() &&
|
!cloneState.IsDead() &&
|
||||||
IoCManager.Resolve<IEntityManager>().TryGetComponent(clone, out MindComponent? cloneMindComp) &&
|
_entities.TryGetComponent(clone, out MindComponent? cloneMindComp) &&
|
||||||
(cloneMindComp.Mind == null || cloneMindComp.Mind == mind))
|
(cloneMindComp.Mind == null || cloneMindComp.Mind == mind))
|
||||||
{
|
{
|
||||||
obj.Session.AttachedEntity?.PopupMessageCursor(Loc.GetString("cloning-pod-component-msg-already-cloning"));
|
obj.Session.AttachedEntity?.PopupMessageCursor(Loc.GetString("cloning-pod-component-msg-already-cloning"));
|
||||||
@@ -121,7 +123,7 @@ namespace Content.Server.Cloning.Components
|
|||||||
}
|
}
|
||||||
|
|
||||||
if (mind.OwnedEntity != null &&
|
if (mind.OwnedEntity != null &&
|
||||||
IoCManager.Resolve<IEntityManager>().TryGetComponent<MobStateComponent?>(mind.OwnedEntity, out var state) &&
|
_entities.TryGetComponent<MobStateComponent?>(mind.OwnedEntity.Value, out var state) &&
|
||||||
!state.IsDead())
|
!state.IsDead())
|
||||||
{
|
{
|
||||||
obj.Session.AttachedEntity?.PopupMessageCursor(Loc.GetString("cloning-pod-component-msg-already-alive"));
|
obj.Session.AttachedEntity?.PopupMessageCursor(Loc.GetString("cloning-pod-component-msg-already-alive"));
|
||||||
@@ -135,13 +137,13 @@ namespace Content.Server.Cloning.Components
|
|||||||
return; // If we can't track down the client, we can't offer transfer. That'd be quite bad.
|
return; // If we can't track down the client, we can't offer transfer. That'd be quite bad.
|
||||||
}
|
}
|
||||||
|
|
||||||
var mob = IoCManager.Resolve<IEntityManager>().SpawnEntity("MobHuman", IoCManager.Resolve<IEntityManager>().GetComponent<TransformComponent>(Owner).MapPosition);
|
var mob = _entities.SpawnEntity("MobHuman", _entities.GetComponent<TransformComponent>(Owner).MapPosition);
|
||||||
|
|
||||||
|
|
||||||
EntitySystem.Get<SharedHumanoidAppearanceSystem>().UpdateFromProfile(mob, dna.Profile);
|
EntitySystem.Get<SharedHumanoidAppearanceSystem>().UpdateFromProfile(mob, dna.Profile);
|
||||||
IoCManager.Resolve<IEntityManager>().GetComponent<MetaDataComponent>(mob).EntityName = dna.Profile.Name;
|
_entities.GetComponent<MetaDataComponent>(mob).EntityName = dna.Profile.Name;
|
||||||
|
|
||||||
var cloneMindReturn = IoCManager.Resolve<IEntityManager>().AddComponent<BeingClonedComponent>(mob);
|
var cloneMindReturn = _entities.AddComponent<BeingClonedComponent>(mob);
|
||||||
cloneMindReturn.Mind = mind;
|
cloneMindReturn.Mind = mind;
|
||||||
cloneMindReturn.Parent = Owner;
|
cloneMindReturn.Parent = Owner;
|
||||||
|
|
||||||
@@ -167,12 +169,11 @@ namespace Content.Server.Cloning.Components
|
|||||||
|
|
||||||
public void Eject()
|
public void Eject()
|
||||||
{
|
{
|
||||||
var entity = BodyContainer.ContainedEntity;
|
if (BodyContainer.ContainedEntity is not {Valid: true} entity || CloningProgress < CloningTime)
|
||||||
if (entity == null || CloningProgress < CloningTime)
|
|
||||||
return;
|
return;
|
||||||
|
|
||||||
IoCManager.Resolve<IEntityManager>().RemoveComponent<BeingClonedComponent>(entity);
|
_entities.RemoveComponent<BeingClonedComponent>(entity);
|
||||||
BodyContainer.Remove(entity!);
|
BodyContainer.Remove(entity);
|
||||||
CapturedMind = null;
|
CapturedMind = null;
|
||||||
CloningProgress = 0f;
|
CloningProgress = 0f;
|
||||||
UpdateStatus(CloningPodStatus.Idle);
|
UpdateStatus(CloningPodStatus.Idle);
|
||||||
|
|||||||
@@ -21,6 +21,8 @@ namespace Content.Server.Clothing.Components
|
|||||||
[NetworkedComponent()]
|
[NetworkedComponent()]
|
||||||
public class ClothingComponent : ItemComponent, IUse
|
public class ClothingComponent : ItemComponent, IUse
|
||||||
{
|
{
|
||||||
|
[Dependency] private readonly IEntityManager _entities = default!;
|
||||||
|
|
||||||
public override string Name => "Clothing";
|
public override string Name => "Clothing";
|
||||||
|
|
||||||
[ViewVariables]
|
[ViewVariables]
|
||||||
@@ -60,8 +62,8 @@ namespace Content.Server.Clothing.Components
|
|||||||
bool IUse.UseEntity(UseEntityEventArgs eventArgs)
|
bool IUse.UseEntity(UseEntityEventArgs eventArgs)
|
||||||
{
|
{
|
||||||
if (!_quickEquipEnabled) return false;
|
if (!_quickEquipEnabled) return false;
|
||||||
if (!IoCManager.Resolve<IEntityManager>().TryGetComponent(eventArgs.User, out InventoryComponent? inv)
|
if (!_entities.TryGetComponent(eventArgs.User, out InventoryComponent? inv)
|
||||||
|| !IoCManager.Resolve<IEntityManager>().TryGetComponent(eventArgs.User, out HandsComponent? hands)) return false;
|
|| !_entities.TryGetComponent(eventArgs.User, out HandsComponent? hands)) return false;
|
||||||
|
|
||||||
foreach (var (slot, flag) in SlotMasks)
|
foreach (var (slot, flag) in SlotMasks)
|
||||||
{
|
{
|
||||||
@@ -79,14 +81,14 @@ namespace Content.Server.Clothing.Components
|
|||||||
{
|
{
|
||||||
hands.Drop(item.Owner);
|
hands.Drop(item.Owner);
|
||||||
inv.Equip(slot, item);
|
inv.Equip(slot, item);
|
||||||
hands.PutInHand(IoCManager.Resolve<IEntityManager>().GetComponent<ItemComponent>(Owner));
|
hands.PutInHand(_entities.GetComponent<ItemComponent>(Owner));
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
else
|
else
|
||||||
{
|
{
|
||||||
hands.Drop(Owner);
|
hands.Drop(Owner);
|
||||||
if (!TryEquip(inv, slot, eventArgs.User))
|
if (!TryEquip(inv, slot, eventArgs.User))
|
||||||
hands.PutInHand(IoCManager.Resolve<IEntityManager>().GetComponent<ItemComponent>(Owner));
|
hands.PutInHand(_entities.GetComponent<ItemComponent>(Owner));
|
||||||
}
|
}
|
||||||
|
|
||||||
return true;
|
return true;
|
||||||
|
|||||||
@@ -1,8 +1,8 @@
|
|||||||
using Content.Server.Construction.Components;
|
using Content.Server.Construction.Components;
|
||||||
|
using Content.Shared.Containers.ItemSlots;
|
||||||
using JetBrains.Annotations;
|
using JetBrains.Annotations;
|
||||||
using Robust.Shared.Containers;
|
using Robust.Shared.Containers;
|
||||||
using Robust.Shared.GameObjects;
|
using Robust.Shared.GameObjects;
|
||||||
using Content.Shared.Containers.ItemSlots;
|
|
||||||
using Robust.Shared.IoC;
|
using Robust.Shared.IoC;
|
||||||
|
|
||||||
namespace Content.Server.Containers
|
namespace Content.Server.Containers
|
||||||
@@ -27,7 +27,7 @@ namespace Content.Server.Containers
|
|||||||
foreach (var slot in component.Slots.Values)
|
foreach (var slot in component.Slots.Values)
|
||||||
{
|
{
|
||||||
if (slot.EjectOnDeconstruct && slot.Item != null)
|
if (slot.EjectOnDeconstruct && slot.Item != null)
|
||||||
slot.ContainerSlot.Remove(slot.Item);
|
slot.ContainerSlot.Remove(slot.Item.Value);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|||||||
@@ -24,6 +24,8 @@ namespace Content.Server.Cuffs.Components
|
|||||||
[ComponentReference(typeof(SharedHandcuffComponent))]
|
[ComponentReference(typeof(SharedHandcuffComponent))]
|
||||||
public class HandcuffComponent : SharedHandcuffComponent, IAfterInteract
|
public class HandcuffComponent : SharedHandcuffComponent, IAfterInteract
|
||||||
{
|
{
|
||||||
|
[Dependency] private readonly IEntityManager _entities = default!;
|
||||||
|
|
||||||
/// <summary>
|
/// <summary>
|
||||||
/// The time it takes to apply a <see cref="CuffedComponent"/> to an entity.
|
/// The time it takes to apply a <see cref="CuffedComponent"/> to an entity.
|
||||||
/// </summary>
|
/// </summary>
|
||||||
@@ -146,7 +148,9 @@ namespace Content.Server.Cuffs.Components
|
|||||||
{
|
{
|
||||||
if (_cuffing) return true;
|
if (_cuffing) return true;
|
||||||
|
|
||||||
if (eventArgs.Target == null || !EntitySystem.Get<ActionBlockerSystem>().CanUse(eventArgs.User) || !IoCManager.Resolve<IEntityManager>().TryGetComponent<CuffableComponent?>(eventArgs.Target, out var cuffed))
|
if (eventArgs.Target is not {Valid: true} target ||
|
||||||
|
!EntitySystem.Get<ActionBlockerSystem>().CanUse(eventArgs.User) ||
|
||||||
|
!_entities.TryGetComponent<CuffableComponent?>(eventArgs.Target.Value, out var cuffed))
|
||||||
{
|
{
|
||||||
return false;
|
return false;
|
||||||
}
|
}
|
||||||
@@ -163,7 +167,7 @@ namespace Content.Server.Cuffs.Components
|
|||||||
return true;
|
return true;
|
||||||
}
|
}
|
||||||
|
|
||||||
if (!IoCManager.Resolve<IEntityManager>().TryGetComponent<HandsComponent?>(eventArgs.Target, out var hands))
|
if (!_entities.TryGetComponent<HandsComponent?>(target, out var hands))
|
||||||
{
|
{
|
||||||
eventArgs.User.PopupMessage(Loc.GetString("handcuff-component-target-has-no-hands-error",("targetName", eventArgs.Target)));
|
eventArgs.User.PopupMessage(Loc.GetString("handcuff-component-target-has-no-hands-error",("targetName", eventArgs.Target)));
|
||||||
return true;
|
return true;
|
||||||
@@ -182,11 +186,11 @@ namespace Content.Server.Cuffs.Components
|
|||||||
}
|
}
|
||||||
|
|
||||||
eventArgs.User.PopupMessage(Loc.GetString("handcuff-component-start-cuffing-target-message",("targetName", eventArgs.Target)));
|
eventArgs.User.PopupMessage(Loc.GetString("handcuff-component-start-cuffing-target-message",("targetName", eventArgs.Target)));
|
||||||
eventArgs.User.PopupMessage(eventArgs.Target, Loc.GetString("handcuff-component-start-cuffing-by-other-message",("otherName", eventArgs.User)));
|
eventArgs.User.PopupMessage(target, Loc.GetString("handcuff-component-start-cuffing-by-other-message",("otherName", eventArgs.User)));
|
||||||
|
|
||||||
SoundSystem.Play(Filter.Pvs(Owner), StartCuffSound.GetSound(), Owner);
|
SoundSystem.Play(Filter.Pvs(Owner), StartCuffSound.GetSound(), Owner);
|
||||||
|
|
||||||
TryUpdateCuff(eventArgs.User, eventArgs.Target, cuffed);
|
TryUpdateCuff(eventArgs.User, target, cuffed);
|
||||||
return true;
|
return true;
|
||||||
}
|
}
|
||||||
|
|
||||||
@@ -197,7 +201,7 @@ namespace Content.Server.Cuffs.Components
|
|||||||
{
|
{
|
||||||
var cuffTime = CuffTime;
|
var cuffTime = CuffTime;
|
||||||
|
|
||||||
if (IoCManager.Resolve<IEntityManager>().HasComponent<StunnedComponent>(target))
|
if (_entities.HasComponent<StunnedComponent>(target))
|
||||||
{
|
{
|
||||||
cuffTime = MathF.Max(0.1f, cuffTime - StunBonus);
|
cuffTime = MathF.Max(0.1f, cuffTime - StunBonus);
|
||||||
}
|
}
|
||||||
|
|||||||
@@ -55,7 +55,7 @@ namespace Content.Server.Cuffs
|
|||||||
{
|
{
|
||||||
return;
|
return;
|
||||||
}
|
}
|
||||||
if (!EntityManager.EntityExists(args.User)
|
if (!EntityManager.EntityExists(args.User))
|
||||||
{
|
{
|
||||||
// Should this even be possible?
|
// Should this even be possible?
|
||||||
args.Cancel();
|
args.Cancel();
|
||||||
@@ -66,7 +66,7 @@ namespace Content.Server.Cuffs
|
|||||||
if (args.User == args.Target)
|
if (args.User == args.Target)
|
||||||
{
|
{
|
||||||
// This UncuffAttemptEvent check should probably be In MobStateSystem, not here?
|
// This UncuffAttemptEvent check should probably be In MobStateSystem, not here?
|
||||||
if (IoCManager.Resolve<IEntityManager>().TryGetComponent<MobStateComponent?>(userEntity, out var state))
|
if (IoCManager.Resolve<IEntityManager>().TryGetComponent<MobStateComponent?>(args.User, out var state))
|
||||||
{
|
{
|
||||||
// Manually check this.
|
// Manually check this.
|
||||||
if (state.IsIncapacitated())
|
if (state.IsIncapacitated())
|
||||||
@@ -83,14 +83,14 @@ namespace Content.Server.Cuffs
|
|||||||
else
|
else
|
||||||
{
|
{
|
||||||
// Check if the user can interact.
|
// Check if the user can interact.
|
||||||
if (!_actionBlockerSystem.CanInteract(userEntity))
|
if (!_actionBlockerSystem.CanInteract(args.User))
|
||||||
{
|
{
|
||||||
args.Cancel();
|
args.Cancel();
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
if (args.Cancelled)
|
if (args.Cancelled)
|
||||||
{
|
{
|
||||||
_popupSystem.PopupEntity(Loc.GetString("cuffable-component-cannot-interact-message"), args.Target, Filter.Entities(userEntity));
|
_popupSystem.PopupEntity(Loc.GetString("cuffable-component-cannot-interact-message"), args.Target, Filter.Entities(args.User));
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|||||||
@@ -43,16 +43,13 @@ namespace Content.Server.Damage.Commands
|
|||||||
|
|
||||||
private delegate void Damage(EntityUid entity, bool ignoreResistances);
|
private delegate void Damage(EntityUid entity, bool ignoreResistances);
|
||||||
|
|
||||||
private bool TryParseEntity(IConsoleShell shell, IPlayerSession? player, string arg,
|
private bool TryParseEntity(IConsoleShell shell, IPlayerSession? player, string arg, out EntityUid entity)
|
||||||
[NotNullWhen(true)] out EntityUid entity)
|
|
||||||
{
|
{
|
||||||
entity = null;
|
entity = default;
|
||||||
|
|
||||||
if (arg == "_")
|
if (arg == "_")
|
||||||
{
|
{
|
||||||
var playerEntity = player?.AttachedEntity;
|
if (player?.AttachedEntity is not {Valid: true} playerEntity)
|
||||||
|
|
||||||
if (playerEntity == null)
|
|
||||||
{
|
{
|
||||||
shell.WriteLine($"You must have a player entity to use this command without specifying an entity.\n{Help}");
|
shell.WriteLine($"You must have a player entity to use this command without specifying an entity.\n{Help}");
|
||||||
return false;
|
return false;
|
||||||
@@ -62,23 +59,20 @@ namespace Content.Server.Damage.Commands
|
|||||||
return true;
|
return true;
|
||||||
}
|
}
|
||||||
|
|
||||||
if (!EntityUid.TryParse(arg, out var entityUid))
|
if (!EntityUid.TryParse(arg, out entity))
|
||||||
{
|
{
|
||||||
shell.WriteLine($"{arg} is not a valid entity uid.\n{Help}");
|
shell.WriteLine($"{arg} is not a valid entity uid.\n{Help}");
|
||||||
|
|
||||||
return false;
|
return false;
|
||||||
}
|
}
|
||||||
|
|
||||||
var entityManager = IoCManager.Resolve<IEntityManager>();
|
var entityManager = IoCManager.Resolve<IEntityManager>();
|
||||||
|
|
||||||
if (!entityManager.EntityExists(entityUid)
|
if (!entityManager.EntityExists(entity))
|
||||||
{
|
{
|
||||||
shell.WriteLine($"No entity found with uid {entityUid}");
|
shell.WriteLine($"No entity found with uid {entity}");
|
||||||
|
|
||||||
return false;
|
return false;
|
||||||
}
|
}
|
||||||
|
|
||||||
entity = parsedEntity;
|
|
||||||
return true;
|
return true;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|||||||
@@ -1,7 +1,6 @@
|
|||||||
using Content.Server.DeviceNetwork.Components;
|
using Content.Server.DeviceNetwork.Components;
|
||||||
using JetBrains.Annotations;
|
using JetBrains.Annotations;
|
||||||
using Robust.Shared.GameObjects;
|
using Robust.Shared.GameObjects;
|
||||||
using Robust.Shared.IoC;
|
|
||||||
|
|
||||||
namespace Content.Server.DeviceNetwork.Systems
|
namespace Content.Server.DeviceNetwork.Systems
|
||||||
{
|
{
|
||||||
@@ -19,10 +18,7 @@ namespace Content.Server.DeviceNetwork.Systems
|
|||||||
/// </summary>
|
/// </summary>
|
||||||
private void OnBeforePacketSent(EntityUid uid, WiredNetworkComponent component, BeforePacketSentEvent args)
|
private void OnBeforePacketSent(EntityUid uid, WiredNetworkComponent component, BeforePacketSentEvent args)
|
||||||
{
|
{
|
||||||
args.Sender
|
if (EntityManager.GetComponent<TransformComponent>(uid).GridID != EntityManager.GetComponent<TransformComponent>(args.Sender).GridID)
|
||||||
uid
|
|
||||||
|
|
||||||
if (IoCManager.Resolve<IEntityManager>().GetComponent<TransformComponent>(receiver).GridID != IoCManager.Resolve<IEntityManager>().GetComponent<TransformComponent>(sender).GridID)
|
|
||||||
{
|
{
|
||||||
args.Cancel();
|
args.Cancel();
|
||||||
}
|
}
|
||||||
|
|||||||
@@ -1,7 +1,6 @@
|
|||||||
using Content.Server.DeviceNetwork.Components;
|
using Content.Server.DeviceNetwork.Components;
|
||||||
using JetBrains.Annotations;
|
using JetBrains.Annotations;
|
||||||
using Robust.Shared.GameObjects;
|
using Robust.Shared.GameObjects;
|
||||||
using Robust.Shared.IoC;
|
|
||||||
|
|
||||||
namespace Content.Server.DeviceNetwork.Systems
|
namespace Content.Server.DeviceNetwork.Systems
|
||||||
{
|
{
|
||||||
@@ -19,13 +18,11 @@ namespace Content.Server.DeviceNetwork.Systems
|
|||||||
/// </summary>
|
/// </summary>
|
||||||
private void OnBeforePacketSent(EntityUid uid, WirelessNetworkComponent component, BeforePacketSentEvent args)
|
private void OnBeforePacketSent(EntityUid uid, WirelessNetworkComponent component, BeforePacketSentEvent args)
|
||||||
{
|
{
|
||||||
var sender = args.Sender
|
var ownPosition = EntityManager.GetComponent<TransformComponent>(component.Owner).WorldPosition;
|
||||||
|
var position = EntityManager.GetComponent<TransformComponent>(args.Sender).WorldPosition;
|
||||||
var ownPosition = IoCManager.Resolve<IEntityManager>().GetComponent<TransformComponent>(component.Owner).WorldPosition;
|
|
||||||
var position = IoCManager.Resolve<IEntityManager>().GetComponent<TransformComponent>(sender).WorldPosition;
|
|
||||||
var distance = (ownPosition - position).Length;
|
var distance = (ownPosition - position).Length;
|
||||||
|
|
||||||
if(IoCManager.Resolve<IEntityManager>().TryGetComponent<WirelessNetworkComponent?>(sender, out var sendingComponent) && distance > sendingComponent.Range)
|
if (EntityManager.TryGetComponent<WirelessNetworkComponent?>(args.Sender, out var sendingComponent) && distance > sendingComponent.Range)
|
||||||
{
|
{
|
||||||
args.Cancel();
|
args.Cancel();
|
||||||
}
|
}
|
||||||
|
|||||||
@@ -68,9 +68,8 @@ namespace Content.Server.Disposal.Tube
|
|||||||
return;
|
return;
|
||||||
}
|
}
|
||||||
|
|
||||||
var uid
|
|
||||||
component.LastClang = _gameTiming.CurTime;
|
component.LastClang = _gameTiming.CurTime;
|
||||||
SoundSystem.Play(Filter.Pvs(entity), component.ClangSound.GetSound(), entity);
|
SoundSystem.Play(Filter.Pvs(uid), component.ClangSound.GetSound(), uid);
|
||||||
}
|
}
|
||||||
|
|
||||||
private static void BodyTypeChanged(
|
private static void BodyTypeChanged(
|
||||||
|
|||||||
@@ -38,13 +38,13 @@ namespace Content.Server.Disposal
|
|||||||
}
|
}
|
||||||
|
|
||||||
var entityManager = IoCManager.Resolve<IEntityManager>();
|
var entityManager = IoCManager.Resolve<IEntityManager>();
|
||||||
if (!entityManager.EntityExists(id)
|
if (!entityManager.EntityExists(id))
|
||||||
{
|
{
|
||||||
shell.WriteLine(Loc.GetString("shell-could-not-find-entity-with-uid",("uid", id)));
|
shell.WriteLine(Loc.GetString("shell-could-not-find-entity-with-uid",("uid", id)));
|
||||||
return;
|
return;
|
||||||
}
|
}
|
||||||
|
|
||||||
if (!IoCManager.Resolve<IEntityManager>().TryGetComponent(entity, out IDisposalTubeComponent? tube))
|
if (!entityManager.TryGetComponent(id, out IDisposalTubeComponent? tube))
|
||||||
{
|
{
|
||||||
shell.WriteLine(Loc.GetString("shell-entity-with-uid-lacks-component",
|
shell.WriteLine(Loc.GetString("shell-entity-with-uid-lacks-component",
|
||||||
("uid", id),
|
("uid", id),
|
||||||
@@ -52,7 +52,7 @@ namespace Content.Server.Disposal
|
|||||||
return;
|
return;
|
||||||
}
|
}
|
||||||
|
|
||||||
tube.PopupDirections(player.AttachedEntity);
|
tube.PopupDirections(player.AttachedEntity.Value);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|||||||
@@ -108,12 +108,12 @@ namespace Content.Server.Disposal.Unit.Components
|
|||||||
|
|
||||||
public void OnUiReceiveMessage(ServerBoundUserInterfaceMessage obj)
|
public void OnUiReceiveMessage(ServerBoundUserInterfaceMessage obj)
|
||||||
{
|
{
|
||||||
if (obj.Session.AttachedEntity == null)
|
if (obj.Session.AttachedEntity is not {Valid: true} player)
|
||||||
{
|
{
|
||||||
return;
|
return;
|
||||||
}
|
}
|
||||||
|
|
||||||
if (!PlayerCanUse(obj.Session.AttachedEntity))
|
if (!PlayerCanUse(player))
|
||||||
{
|
{
|
||||||
return;
|
return;
|
||||||
}
|
}
|
||||||
|
|||||||
@@ -116,7 +116,7 @@ namespace Content.Server.Disposal.Unit.EntitySystems
|
|||||||
|
|
||||||
private void DoInsertDisposalUnit(DoInsertDisposalUnitEvent ev)
|
private void DoInsertDisposalUnit(DoInsertDisposalUnitEvent ev)
|
||||||
{
|
{
|
||||||
var toInsert = ev.ToInsert
|
var toInsert = ev.ToInsert;
|
||||||
|
|
||||||
if (!EntityManager.TryGetComponent(ev.Unit, out DisposalUnitComponent? unit))
|
if (!EntityManager.TryGetComponent(ev.Unit, out DisposalUnitComponent? unit))
|
||||||
{
|
{
|
||||||
|
|||||||
@@ -392,17 +392,17 @@ namespace Content.Server.Electrocution
|
|||||||
visited.Add(entity);
|
visited.Add(entity);
|
||||||
|
|
||||||
if (EntityManager.TryGetComponent(entity, out SharedPullableComponent? pullable)
|
if (EntityManager.TryGetComponent(entity, out SharedPullableComponent? pullable)
|
||||||
&& pullable.Puller != default
|
&& pullable.Puller is {Valid: true} pullerId
|
||||||
&& !visited.Contains(pullable.Puller))
|
&& !visited.Contains(pullerId))
|
||||||
{
|
{
|
||||||
GetChainedElectrocutionTargetsRecurse(pullable.Puller, depth + 1, visited, all);
|
GetChainedElectrocutionTargetsRecurse(pullerId, depth + 1, visited, all);
|
||||||
}
|
}
|
||||||
|
|
||||||
if (EntityManager.TryGetComponent(entity, out SharedPullerComponent? puller)
|
if (EntityManager.TryGetComponent(entity, out SharedPullerComponent? puller)
|
||||||
&& puller.Pulling != default
|
&& puller.Pulling is {Valid: true} pullingId
|
||||||
&& !visited.Contains(puller.Pulling))
|
&& !visited.Contains(pullingId))
|
||||||
{
|
{
|
||||||
GetChainedElectrocutionTargetsRecurse(puller.Pulling, depth + 1, visited, all);
|
GetChainedElectrocutionTargetsRecurse(pullingId, depth + 1, visited, all);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|||||||
@@ -49,7 +49,7 @@ namespace Content.Server.EntityList
|
|||||||
|
|
||||||
foreach (var entity in prototype.Entities(prototypeManager))
|
foreach (var entity in prototype.Entities(prototypeManager))
|
||||||
{
|
{
|
||||||
entityManager.SpawnEntity(entity.ID, IoCManager.Resolve<IEntityManager>().GetComponent<TransformComponent>(player.AttachedEntity).Coordinates);
|
entityManager.SpawnEntity(entity.ID, entityManager.GetComponent<TransformComponent>(player.AttachedEntity.Value).Coordinates);
|
||||||
i++;
|
i++;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|||||||
@@ -32,10 +32,9 @@ namespace Content.Server.Examine
|
|||||||
{
|
{
|
||||||
var player = (IPlayerSession) eventArgs.SenderSession;
|
var player = (IPlayerSession) eventArgs.SenderSession;
|
||||||
var session = eventArgs.SenderSession;
|
var session = eventArgs.SenderSession;
|
||||||
var playerEnt = session.AttachedEntity;
|
|
||||||
var channel = player.ConnectedClient;
|
var channel = player.ConnectedClient;
|
||||||
|
|
||||||
if (playerEnt == default
|
if (session.AttachedEntity is not {Valid: true} playerEnt
|
||||||
|| !EntityManager.EntityExists(request.EntityUid)
|
|| !EntityManager.EntityExists(request.EntityUid)
|
||||||
|| !CanExamine(playerEnt, request.EntityUid))
|
|| !CanExamine(playerEnt, request.EntityUid))
|
||||||
{
|
{
|
||||||
|
|||||||
@@ -81,12 +81,13 @@ namespace Content.Server.Explosion.EntitySystems
|
|||||||
|
|
||||||
foreach (var player in players)
|
foreach (var player in players)
|
||||||
{
|
{
|
||||||
if (!player.AttachedEntity.Valid || !EntityManager.TryGetComponent(player.AttachedEntity, out CameraRecoilComponent? recoil))
|
if (player.AttachedEntity is not {Valid: true} playerEntity ||
|
||||||
|
!EntityManager.TryGetComponent(playerEntity, out CameraRecoilComponent? recoil))
|
||||||
{
|
{
|
||||||
continue;
|
continue;
|
||||||
}
|
}
|
||||||
|
|
||||||
var playerPos = EntityManager.GetComponent<TransformComponent>(player.AttachedEntity).WorldPosition;
|
var playerPos = EntityManager.GetComponent<TransformComponent>(playerEntity).WorldPosition;
|
||||||
var delta = epicenter.ToMapPos(EntityManager) - playerPos;
|
var delta = epicenter.ToMapPos(EntityManager) - playerPos;
|
||||||
|
|
||||||
//Change if zero. Will result in a NaN later breaking camera shake if not changed
|
//Change if zero. Will result in a NaN later breaking camera shake if not changed
|
||||||
|
|||||||
@@ -48,7 +48,7 @@ namespace Content.Server.Flash
|
|||||||
}
|
}
|
||||||
|
|
||||||
args.Handled = true;
|
args.Handled = true;
|
||||||
foreach (EntityUide in args.HitEntities)
|
foreach (var e in args.HitEntities)
|
||||||
{
|
{
|
||||||
Flash(e, args.User, uid, comp.FlashDuration, comp.SlowTo);
|
Flash(e, args.User, uid, comp.FlashDuration, comp.SlowTo);
|
||||||
}
|
}
|
||||||
@@ -135,15 +135,11 @@ namespace Content.Server.Flash
|
|||||||
if (displayPopup && user != null && target != user)
|
if (displayPopup && user != null && target != user)
|
||||||
{
|
{
|
||||||
// TODO Resolving the EntityUidhere bad.
|
// TODO Resolving the EntityUidhere bad.
|
||||||
if(EntityManager.EntityExists(user.Value)
|
if (EntityManager.EntityExists(user.Value) && EntityManager.EntityExists(target))
|
||||||
&& EntityManager.EntityExists(target)
|
{
|
||||||
|
user.Value.PopupMessage(target, Loc.GetString("flash-component-user-blinds-you",
|
||||||
userEntity.PopupMessage(targetEntity,
|
("user", user.Value)));
|
||||||
Loc.GetString(
|
}
|
||||||
"flash-component-user-blinds-you",
|
|
||||||
("user", userEntity)
|
|
||||||
)
|
|
||||||
);
|
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|||||||
@@ -23,6 +23,8 @@ namespace Content.Server.Fluids.Components
|
|||||||
[RegisterComponent]
|
[RegisterComponent]
|
||||||
public class MopComponent : Component, IAfterInteract
|
public class MopComponent : Component, IAfterInteract
|
||||||
{
|
{
|
||||||
|
[Dependency] private readonly IEntityManager _entities = default!;
|
||||||
|
|
||||||
public override string Name => "Mop";
|
public override string Name => "Mop";
|
||||||
public const string SolutionName = "mop";
|
public const string SolutionName = "mop";
|
||||||
|
|
||||||
@@ -101,7 +103,7 @@ namespace Content.Server.Fluids.Components
|
|||||||
return false;
|
return false;
|
||||||
}
|
}
|
||||||
|
|
||||||
if (eventArgs.Target == null)
|
if (eventArgs.Target is not {Valid: true} target)
|
||||||
{
|
{
|
||||||
// Drop the liquid on the mop on to the ground
|
// Drop the liquid on the mop on to the ground
|
||||||
solutionSystem.SplitSolution(Owner, contents, FixedPoint2.Min(ResidueAmount, CurrentVolume))
|
solutionSystem.SplitSolution(Owner, contents, FixedPoint2.Min(ResidueAmount, CurrentVolume))
|
||||||
@@ -109,13 +111,13 @@ namespace Content.Server.Fluids.Components
|
|||||||
return true;
|
return true;
|
||||||
}
|
}
|
||||||
|
|
||||||
if (!IoCManager.Resolve<IEntityManager>().TryGetComponent(eventArgs.Target, out PuddleComponent? puddleComponent) ||
|
if (!_entities.TryGetComponent(target, out PuddleComponent? puddleComponent) ||
|
||||||
!solutionSystem.TryGetSolution(((IComponent) puddleComponent).Owner, puddleComponent.SolutionName, out var puddleSolution))
|
!solutionSystem.TryGetSolution(((IComponent) puddleComponent).Owner, puddleComponent.SolutionName, out var puddleSolution))
|
||||||
return false;
|
return false;
|
||||||
|
|
||||||
// So if the puddle has 20 units we mop in 2 seconds. Don't just store CurrentVolume given it can change so need to re-calc it anyway.
|
// So if the puddle has 20 units we mop in 2 seconds. Don't just store CurrentVolume given it can change so need to re-calc it anyway.
|
||||||
var doAfterArgs = new DoAfterEventArgs(eventArgs.User, _mopSpeed * puddleSolution.CurrentVolume.Float() / 10.0f,
|
var doAfterArgs = new DoAfterEventArgs(eventArgs.User, _mopSpeed * puddleSolution.CurrentVolume.Float() / 10.0f,
|
||||||
target: eventArgs.Target)
|
target: target)
|
||||||
{
|
{
|
||||||
BreakOnUserMove = true,
|
BreakOnUserMove = true,
|
||||||
BreakOnStun = true,
|
BreakOnStun = true,
|
||||||
@@ -152,7 +154,7 @@ namespace Content.Server.Fluids.Components
|
|||||||
else
|
else
|
||||||
{
|
{
|
||||||
// remove solution from the puddle
|
// remove solution from the puddle
|
||||||
solutionSystem.SplitSolution(eventArgs.Target, puddleSolution, transferAmount);
|
solutionSystem.SplitSolution(target, puddleSolution, transferAmount);
|
||||||
|
|
||||||
// and from the mop
|
// and from the mop
|
||||||
solutionSystem.SplitSolution(Owner, contents, transferAmount);
|
solutionSystem.SplitSolution(Owner, contents, transferAmount);
|
||||||
|
|||||||
@@ -18,6 +18,8 @@ namespace Content.Server.GameTicking.Commands
|
|||||||
[AdminCommand(AdminFlags.Server | AdminFlags.Mapping)]
|
[AdminCommand(AdminFlags.Server | AdminFlags.Mapping)]
|
||||||
class MappingCommand : IConsoleCommand
|
class MappingCommand : IConsoleCommand
|
||||||
{
|
{
|
||||||
|
[Dependency] private readonly IEntityManager _entities = default!;
|
||||||
|
|
||||||
public string Command => "mapping";
|
public string Command => "mapping";
|
||||||
public string Description => "Creates and teleports you to a new uninitialized map for mapping.";
|
public string Description => "Creates and teleports you to a new uninitialized map for mapping.";
|
||||||
public string Help => $"Usage: {Command} <mapname> / {Command} <id> <mapname>";
|
public string Help => $"Usage: {Command} <mapname> / {Command} <id> <mapname>";
|
||||||
@@ -76,9 +78,11 @@ namespace Content.Server.GameTicking.Commands
|
|||||||
shell.ExecuteCommand($"addmap {mapId} false");
|
shell.ExecuteCommand($"addmap {mapId} false");
|
||||||
shell.ExecuteCommand($"loadbp {mapId} \"{CommandParsing.Escape(mapName)}\" true");
|
shell.ExecuteCommand($"loadbp {mapId} \"{CommandParsing.Escape(mapName)}\" true");
|
||||||
|
|
||||||
EntityUid tempQualifier = player.AttachedEntity;
|
if (player.AttachedEntity is {Valid: true} playerEntity &&
|
||||||
if ((tempQualifier != null ? IoCManager.Resolve<IEntityManager>().GetComponent<MetaDataComponent>(tempQualifier).EntityPrototype : null)?.ID != "AdminObserver")
|
_entities.GetComponent<MetaDataComponent>(playerEntity).EntityPrototype?.ID != "AdminObserver")
|
||||||
|
{
|
||||||
shell.ExecuteCommand("aghost");
|
shell.ExecuteCommand("aghost");
|
||||||
|
}
|
||||||
|
|
||||||
shell.ExecuteCommand($"tp 0 0 {mapId}");
|
shell.ExecuteCommand($"tp 0 0 {mapId}");
|
||||||
shell.RemoteExecuteCommand("showmarkers");
|
shell.RemoteExecuteCommand("showmarkers");
|
||||||
|
|||||||
@@ -278,7 +278,7 @@ namespace Content.Server.GameTicking
|
|||||||
if (mind.CharacterName != null)
|
if (mind.CharacterName != null)
|
||||||
playerIcName = mind.CharacterName;
|
playerIcName = mind.CharacterName;
|
||||||
else if (mind.CurrentEntity != null)
|
else if (mind.CurrentEntity != null)
|
||||||
playerIcName = IoCManager.Resolve<IEntityManager>().GetComponent<MetaDataComponent>(mind.CurrentEntity).EntityName;
|
playerIcName = IoCManager.Resolve<IEntityManager>().GetComponent<MetaDataComponent>(mind.CurrentEntity.Value).EntityName;
|
||||||
|
|
||||||
var playerEndRoundInfo = new RoundEndMessageEvent.RoundEndPlayerInfo()
|
var playerEndRoundInfo = new RoundEndMessageEvent.RoundEndPlayerInfo()
|
||||||
{
|
{
|
||||||
|
|||||||
@@ -19,6 +19,8 @@ namespace Content.Server.GameTicking.Presets
|
|||||||
/// </summary>
|
/// </summary>
|
||||||
public abstract class GamePreset
|
public abstract class GamePreset
|
||||||
{
|
{
|
||||||
|
[Dependency] private readonly IEntityManager _entities = default!;
|
||||||
|
|
||||||
public abstract bool Start(IReadOnlyList<IPlayerSession> readyPlayers, bool force = false);
|
public abstract bool Start(IReadOnlyList<IPlayerSession> readyPlayers, bool force = false);
|
||||||
public virtual string ModeTitle => "Sandbox";
|
public virtual string ModeTitle => "Sandbox";
|
||||||
public virtual string Description => "Secret!";
|
public virtual string Description => "Secret!";
|
||||||
@@ -39,7 +41,7 @@ namespace Content.Server.GameTicking.Presets
|
|||||||
{
|
{
|
||||||
var playerEntity = mind.OwnedEntity;
|
var playerEntity = mind.OwnedEntity;
|
||||||
|
|
||||||
if (playerEntity != default && IoCManager.Resolve<IEntityManager>().HasComponent<GhostComponent>(playerEntity))
|
if (playerEntity != default && IoCManager.Resolve<IEntityManager>().HasComponent<GhostComponent>(playerEntity.Value))
|
||||||
return false;
|
return false;
|
||||||
|
|
||||||
if (mind.VisitingEntity != default)
|
if (mind.VisitingEntity != default)
|
||||||
@@ -47,7 +49,9 @@ namespace Content.Server.GameTicking.Presets
|
|||||||
mind.UnVisit();
|
mind.UnVisit();
|
||||||
}
|
}
|
||||||
|
|
||||||
var position = (playerEntity != null ? IoCManager.Resolve<IEntityManager>().GetComponent<TransformComponent>(playerEntity) : null).Coordinates ?? EntitySystem.Get<GameTicker>().GetObserverSpawnPoint();
|
var position = playerEntity is {Valid: true}
|
||||||
|
? _entities.GetComponent<TransformComponent>(playerEntity.Value).Coordinates
|
||||||
|
: EntitySystem.Get<GameTicker>().GetObserverSpawnPoint();
|
||||||
// Ok, so, this is the master place for the logic for if ghosting is "too cheaty" to allow returning.
|
// Ok, so, this is the master place for the logic for if ghosting is "too cheaty" to allow returning.
|
||||||
// There's no reason at this time to move it to any other place, especially given that the 'side effects required' situations would also have to be moved.
|
// There's no reason at this time to move it to any other place, especially given that the 'side effects required' situations would also have to be moved.
|
||||||
// + If CharacterDeadPhysically applies, we're physically dead. Therefore, ghosting OK, and we can return (this is critical for gibbing)
|
// + If CharacterDeadPhysically applies, we're physically dead. Therefore, ghosting OK, and we can return (this is critical for gibbing)
|
||||||
@@ -58,7 +62,7 @@ namespace Content.Server.GameTicking.Presets
|
|||||||
// (If the mob survives, that's a bug. Ghosting is kept regardless.)
|
// (If the mob survives, that's a bug. Ghosting is kept regardless.)
|
||||||
var canReturn = canReturnGlobal && mind.CharacterDeadPhysically;
|
var canReturn = canReturnGlobal && mind.CharacterDeadPhysically;
|
||||||
|
|
||||||
if (playerEntity != null && canReturnGlobal && IoCManager.Resolve<IEntityManager>().TryGetComponent(playerEntity, out MobStateComponent? mobState))
|
if (playerEntity != default && canReturnGlobal && IoCManager.Resolve<IEntityManager>().TryGetComponent(playerEntity.Value, out MobStateComponent? mobState))
|
||||||
{
|
{
|
||||||
if (mobState.IsCritical())
|
if (mobState.IsCritical())
|
||||||
{
|
{
|
||||||
@@ -67,7 +71,7 @@ namespace Content.Server.GameTicking.Presets
|
|||||||
//todo: what if they dont breathe lol
|
//todo: what if they dont breathe lol
|
||||||
//cry deeply
|
//cry deeply
|
||||||
DamageSpecifier damage = new(IoCManager.Resolve<IPrototypeManager>().Index<DamageTypePrototype>("Asphyxiation"), 200);
|
DamageSpecifier damage = new(IoCManager.Resolve<IPrototypeManager>().Index<DamageTypePrototype>("Asphyxiation"), 200);
|
||||||
EntitySystem.Get<DamageableSystem>().TryChangeDamage(playerEntity, damage, true);
|
EntitySystem.Get<DamageableSystem>().TryChangeDamage(playerEntity.Value, damage, true);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|||||||
@@ -1,16 +1,12 @@
|
|||||||
using System.Collections.Generic;
|
using System.Collections.Generic;
|
||||||
using Content.Server.Chat.Managers;
|
using Content.Server.Chat.Managers;
|
||||||
using Content.Server.GameTicking.Rules;
|
using Content.Server.GameTicking.Rules;
|
||||||
using Content.Server.Inventory.Components;
|
|
||||||
using Content.Server.Items;
|
|
||||||
using Content.Server.Players;
|
using Content.Server.Players;
|
||||||
using Content.Server.Suspicion;
|
using Content.Server.Suspicion;
|
||||||
using Content.Server.Suspicion.Roles;
|
using Content.Server.Suspicion.Roles;
|
||||||
using Content.Server.Traitor.Uplink;
|
using Content.Server.Traitor.Uplink;
|
||||||
using Content.Server.Traitor.Uplink.Account;
|
using Content.Server.Traitor.Uplink.Account;
|
||||||
using Content.Server.Traitor.Uplink.Components;
|
|
||||||
using Content.Shared.CCVar;
|
using Content.Shared.CCVar;
|
||||||
using Content.Shared.Inventory;
|
|
||||||
using Content.Shared.Roles;
|
using Content.Shared.Roles;
|
||||||
using Content.Shared.Traitor.Uplink;
|
using Content.Shared.Traitor.Uplink;
|
||||||
using Robust.Server.Player;
|
using Robust.Server.Player;
|
||||||
@@ -121,7 +117,7 @@ namespace Content.Server.GameTicking.Presets
|
|||||||
|
|
||||||
// try to place uplink
|
// try to place uplink
|
||||||
if (!EntityManager.EntitySysManager.GetEntitySystem<UplinkSystem>()
|
if (!EntityManager.EntitySysManager.GetEntitySystem<UplinkSystem>()
|
||||||
.AddUplink(mind.OwnedEntity, uplinkAccount))
|
.AddUplink(mind.OwnedEntity!.Value, uplinkAccount))
|
||||||
continue;
|
continue;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|||||||
@@ -3,19 +3,14 @@ using System.Collections.Generic;
|
|||||||
using System.Linq;
|
using System.Linq;
|
||||||
using Content.Server.Chat.Managers;
|
using Content.Server.Chat.Managers;
|
||||||
using Content.Server.GameTicking.Rules;
|
using Content.Server.GameTicking.Rules;
|
||||||
using Content.Server.Inventory.Components;
|
|
||||||
using Content.Server.Items;
|
|
||||||
using Content.Server.Objectives.Interfaces;
|
using Content.Server.Objectives.Interfaces;
|
||||||
using Content.Server.PDA;
|
|
||||||
using Content.Server.Players;
|
using Content.Server.Players;
|
||||||
using Content.Server.Roles;
|
using Content.Server.Roles;
|
||||||
using Content.Server.Traitor;
|
using Content.Server.Traitor;
|
||||||
using Content.Server.Traitor.Uplink;
|
using Content.Server.Traitor.Uplink;
|
||||||
using Content.Server.Traitor.Uplink.Account;
|
using Content.Server.Traitor.Uplink.Account;
|
||||||
using Content.Server.Traitor.Uplink.Components;
|
|
||||||
using Content.Shared.CCVar;
|
using Content.Shared.CCVar;
|
||||||
using Content.Shared.Dataset;
|
using Content.Shared.Dataset;
|
||||||
using Content.Shared.Inventory;
|
|
||||||
using Content.Shared.Traitor.Uplink;
|
using Content.Shared.Traitor.Uplink;
|
||||||
using Robust.Server.Player;
|
using Robust.Server.Player;
|
||||||
using Robust.Shared.Configuration;
|
using Robust.Shared.Configuration;
|
||||||
@@ -131,7 +126,7 @@ namespace Content.Server.GameTicking.Presets
|
|||||||
accounts.AddNewAccount(uplinkAccount);
|
accounts.AddNewAccount(uplinkAccount);
|
||||||
|
|
||||||
if (!EntityManager.EntitySysManager.GetEntitySystem<UplinkSystem>()
|
if (!EntityManager.EntitySysManager.GetEntitySystem<UplinkSystem>()
|
||||||
.AddUplink(mind.OwnedEntity, uplinkAccount))
|
.AddUplink(mind.OwnedEntity!.Value, uplinkAccount))
|
||||||
continue;
|
continue;
|
||||||
|
|
||||||
var traitorRole = new TraitorRole(mind);
|
var traitorRole = new TraitorRole(mind);
|
||||||
|
|||||||
@@ -80,50 +80,50 @@ namespace Content.Server.GameTicking.Presets
|
|||||||
|
|
||||||
// Delete anything that may contain "dangerous" role-specific items.
|
// Delete anything that may contain "dangerous" role-specific items.
|
||||||
// (This includes the PDA, as everybody gets the captain PDA in this mode for true-all-access reasons.)
|
// (This includes the PDA, as everybody gets the captain PDA in this mode for true-all-access reasons.)
|
||||||
if (mind.OwnedEntity != null && IoCManager.Resolve<IEntityManager>().TryGetComponent(mind.OwnedEntity, out InventoryComponent? inventory))
|
if (mind.OwnedEntity is {Valid: true} owned && _entityManager.TryGetComponent(owned, out InventoryComponent? inventory))
|
||||||
{
|
{
|
||||||
var victimSlots = new[] {EquipmentSlotDefines.Slots.IDCARD, EquipmentSlotDefines.Slots.BELT, EquipmentSlotDefines.Slots.BACKPACK};
|
var victimSlots = new[] {EquipmentSlotDefines.Slots.IDCARD, EquipmentSlotDefines.Slots.BELT, EquipmentSlotDefines.Slots.BACKPACK};
|
||||||
foreach (var slot in victimSlots)
|
foreach (var slot in victimSlots)
|
||||||
{
|
{
|
||||||
if (inventory.TryGetSlotItem(slot, out ItemComponent? vItem))
|
if (inventory.TryGetSlotItem(slot, out ItemComponent? vItem))
|
||||||
IoCManager.Resolve<IEntityManager>().DeleteEntity(vItem.Owner);
|
_entityManager.DeleteEntity(vItem.Owner);
|
||||||
}
|
}
|
||||||
|
|
||||||
// Replace their items:
|
// Replace their items:
|
||||||
|
|
||||||
// pda
|
// pda
|
||||||
var newPDA = _entityManager.SpawnEntity(PDAPrototypeName, IoCManager.Resolve<IEntityManager>().GetComponent<TransformComponent>(mind.OwnedEntity).Coordinates);
|
var newPDA = _entityManager.SpawnEntity(PDAPrototypeName, _entityManager.GetComponent<TransformComponent>(owned).Coordinates);
|
||||||
inventory.Equip(EquipmentSlotDefines.Slots.IDCARD, IoCManager.Resolve<IEntityManager>().GetComponent<ItemComponent>(newPDA));
|
inventory.Equip(EquipmentSlotDefines.Slots.IDCARD, _entityManager.GetComponent<ItemComponent>(newPDA));
|
||||||
|
|
||||||
// belt
|
// belt
|
||||||
var newTmp = _entityManager.SpawnEntity(BeltPrototypeName, IoCManager.Resolve<IEntityManager>().GetComponent<TransformComponent>(mind.OwnedEntity).Coordinates);
|
var newTmp = _entityManager.SpawnEntity(BeltPrototypeName, _entityManager.GetComponent<TransformComponent>(owned).Coordinates);
|
||||||
inventory.Equip(EquipmentSlotDefines.Slots.BELT, IoCManager.Resolve<IEntityManager>().GetComponent<ItemComponent>(newTmp));
|
inventory.Equip(EquipmentSlotDefines.Slots.BELT, _entityManager.GetComponent<ItemComponent>(newTmp));
|
||||||
|
|
||||||
// backpack
|
// backpack
|
||||||
newTmp = _entityManager.SpawnEntity(BackpackPrototypeName, IoCManager.Resolve<IEntityManager>().GetComponent<TransformComponent>(mind.OwnedEntity).Coordinates);
|
newTmp = _entityManager.SpawnEntity(BackpackPrototypeName, _entityManager.GetComponent<TransformComponent>(owned).Coordinates);
|
||||||
inventory.Equip(EquipmentSlotDefines.Slots.BACKPACK, IoCManager.Resolve<IEntityManager>().GetComponent<ItemComponent>(newTmp));
|
inventory.Equip(EquipmentSlotDefines.Slots.BACKPACK, _entityManager.GetComponent<ItemComponent>(newTmp));
|
||||||
|
|
||||||
// Like normal traitors, they need access to a traitor account.
|
// Like normal traitors, they need access to a traitor account.
|
||||||
var uplinkAccount = new UplinkAccount(startingBalance, mind.OwnedEntity);
|
var uplinkAccount = new UplinkAccount(startingBalance, owned);
|
||||||
var accounts = _entityManager.EntitySysManager.GetEntitySystem<UplinkAccountsSystem>();
|
var accounts = _entityManager.EntitySysManager.GetEntitySystem<UplinkAccountsSystem>();
|
||||||
accounts.AddNewAccount(uplinkAccount);
|
accounts.AddNewAccount(uplinkAccount);
|
||||||
|
|
||||||
_entityManager.EntitySysManager.GetEntitySystem<UplinkSystem>()
|
_entityManager.EntitySysManager.GetEntitySystem<UplinkSystem>()
|
||||||
.AddUplink(mind.OwnedEntity, uplinkAccount, newPDA);
|
.AddUplink(owned, uplinkAccount, newPDA);
|
||||||
|
|
||||||
_allOriginalNames[uplinkAccount] = IoCManager.Resolve<IEntityManager>().GetComponent<MetaDataComponent>(mind.OwnedEntity).EntityName;
|
_allOriginalNames[uplinkAccount] = _entityManager.GetComponent<MetaDataComponent>(owned).EntityName;
|
||||||
|
|
||||||
// The PDA needs to be marked with the correct owner.
|
// The PDA needs to be marked with the correct owner.
|
||||||
var pda = IoCManager.Resolve<IEntityManager>().GetComponent<PDAComponent>(newPDA);
|
var pda = _entityManager.GetComponent<PDAComponent>(newPDA);
|
||||||
_entityManager.EntitySysManager.GetEntitySystem<PDASystem>()
|
_entityManager.EntitySysManager.GetEntitySystem<PDASystem>()
|
||||||
.SetOwner(pda, IoCManager.Resolve<IEntityManager>().GetComponent<MetaDataComponent>(mind.OwnedEntity).EntityName);
|
.SetOwner(pda, _entityManager.GetComponent<MetaDataComponent>(owned).EntityName);
|
||||||
IoCManager.Resolve<IEntityManager>().AddComponent<TraitorDeathMatchReliableOwnerTagComponent>(newPDA).UserId = mind.UserId;
|
_entityManager.AddComponent<TraitorDeathMatchReliableOwnerTagComponent>(newPDA).UserId = mind.UserId;
|
||||||
}
|
}
|
||||||
|
|
||||||
// Finally, it would be preferrable if they spawned as far away from other players as reasonably possible.
|
// Finally, it would be preferrable if they spawned as far away from other players as reasonably possible.
|
||||||
if (mind.OwnedEntity != null && FindAnyIsolatedSpawnLocation(mind, out var bestTarget))
|
if (mind.OwnedEntity != default && FindAnyIsolatedSpawnLocation(mind, out var bestTarget))
|
||||||
{
|
{
|
||||||
IoCManager.Resolve<IEntityManager>().GetComponent<TransformComponent>(mind.OwnedEntity).Coordinates = bestTarget;
|
_entityManager.GetComponent<TransformComponent>(mind.OwnedEntity.Value).Coordinates = bestTarget;
|
||||||
}
|
}
|
||||||
else
|
else
|
||||||
{
|
{
|
||||||
@@ -151,7 +151,7 @@ namespace Content.Server.GameTicking.Presets
|
|||||||
var avoidMeEntity = avoidMeMind.OwnedEntity;
|
var avoidMeEntity = avoidMeMind.OwnedEntity;
|
||||||
if (avoidMeEntity == null)
|
if (avoidMeEntity == null)
|
||||||
continue;
|
continue;
|
||||||
if (IoCManager.Resolve<IEntityManager>().TryGetComponent(avoidMeEntity, out MobStateComponent? mobState))
|
if (_entityManager.TryGetComponent(avoidMeEntity.Value, out MobStateComponent? mobState))
|
||||||
{
|
{
|
||||||
// Does have mob state component; if critical or dead, they don't really matter for spawn checks
|
// Does have mob state component; if critical or dead, they don't really matter for spawn checks
|
||||||
if (mobState.IsCritical() || mobState.IsDead())
|
if (mobState.IsCritical() || mobState.IsDead())
|
||||||
@@ -162,7 +162,7 @@ namespace Content.Server.GameTicking.Presets
|
|||||||
// Doesn't have mob state component. Assume something interesting is going on and don't count this as someone to avoid.
|
// Doesn't have mob state component. Assume something interesting is going on and don't count this as someone to avoid.
|
||||||
continue;
|
continue;
|
||||||
}
|
}
|
||||||
existingPlayerPoints.Add(IoCManager.Resolve<IEntityManager>().GetComponent<TransformComponent>(avoidMeEntity).Coordinates);
|
existingPlayerPoints.Add(_entityManager.GetComponent<TransformComponent>(avoidMeEntity.Value).Coordinates);
|
||||||
}
|
}
|
||||||
|
|
||||||
// Iterate over each possible spawn point, comparing to the existing player points.
|
// Iterate over each possible spawn point, comparing to the existing player points.
|
||||||
@@ -176,18 +176,18 @@ namespace Content.Server.GameTicking.Presets
|
|||||||
var atmosphereSystem = EntitySystem.Get<AtmosphereSystem>();
|
var atmosphereSystem = EntitySystem.Get<AtmosphereSystem>();
|
||||||
foreach (var entity in ents)
|
foreach (var entity in ents)
|
||||||
{
|
{
|
||||||
if (!atmosphereSystem.IsTileMixtureProbablySafe(IoCManager.Resolve<IEntityManager>().GetComponent<TransformComponent>(entity).Coordinates))
|
if (!atmosphereSystem.IsTileMixtureProbablySafe(_entityManager.GetComponent<TransformComponent>(entity).Coordinates))
|
||||||
continue;
|
continue;
|
||||||
|
|
||||||
var distanceFromNearest = float.PositiveInfinity;
|
var distanceFromNearest = float.PositiveInfinity;
|
||||||
foreach (var existing in existingPlayerPoints)
|
foreach (var existing in existingPlayerPoints)
|
||||||
{
|
{
|
||||||
if (IoCManager.Resolve<IEntityManager>().GetComponent<TransformComponent>(entity).Coordinates.TryDistance(_entityManager, existing, out var dist))
|
if (_entityManager.GetComponent<TransformComponent>(entity).Coordinates.TryDistance(_entityManager, existing, out var dist))
|
||||||
distanceFromNearest = Math.Min(distanceFromNearest, dist);
|
distanceFromNearest = Math.Min(distanceFromNearest, dist);
|
||||||
}
|
}
|
||||||
if (bestTargetDistanceFromNearest < distanceFromNearest)
|
if (bestTargetDistanceFromNearest < distanceFromNearest)
|
||||||
{
|
{
|
||||||
bestTarget = IoCManager.Resolve<IEntityManager>().GetComponent<TransformComponent>(entity).Coordinates;
|
bestTarget = _entityManager.GetComponent<TransformComponent>(entity).Coordinates;
|
||||||
bestTargetDistanceFromNearest = distanceFromNearest;
|
bestTargetDistanceFromNearest = distanceFromNearest;
|
||||||
foundATarget = true;
|
foundATarget = true;
|
||||||
}
|
}
|
||||||
@@ -197,8 +197,7 @@ namespace Content.Server.GameTicking.Presets
|
|||||||
|
|
||||||
public override bool OnGhostAttempt(Mind.Mind mind, bool canReturnGlobal)
|
public override bool OnGhostAttempt(Mind.Mind mind, bool canReturnGlobal)
|
||||||
{
|
{
|
||||||
var entity = mind.OwnedEntity;
|
if (mind.OwnedEntity is {Valid: true} entity && _entityManager.TryGetComponent(entity, out MobStateComponent? mobState))
|
||||||
if ((entity != null) && IoCManager.Resolve<IEntityManager>().TryGetComponent(entity, out MobStateComponent? mobState))
|
|
||||||
{
|
{
|
||||||
if (mobState.IsCritical())
|
if (mobState.IsCritical())
|
||||||
{
|
{
|
||||||
@@ -208,7 +207,7 @@ namespace Content.Server.GameTicking.Presets
|
|||||||
}
|
}
|
||||||
else if (!mobState.IsDead())
|
else if (!mobState.IsDead())
|
||||||
{
|
{
|
||||||
if (IoCManager.Resolve<IEntityManager>().HasComponent<HandsComponent>(entity))
|
if (_entityManager.HasComponent<HandsComponent>(entity))
|
||||||
{
|
{
|
||||||
return false;
|
return false;
|
||||||
}
|
}
|
||||||
|
|||||||
@@ -1,6 +1,4 @@
|
|||||||
using System;
|
using System;
|
||||||
using System.Collections.Generic;
|
|
||||||
using System.Linq;
|
|
||||||
using System.Threading;
|
using System.Threading;
|
||||||
using Content.Server.Chat.Managers;
|
using Content.Server.Chat.Managers;
|
||||||
using Content.Shared.CCVar;
|
using Content.Shared.CCVar;
|
||||||
@@ -62,9 +60,8 @@ namespace Content.Server.GameTicking.Rules
|
|||||||
IPlayerSession? winner = null;
|
IPlayerSession? winner = null;
|
||||||
foreach (var playerSession in _playerManager.ServerSessions)
|
foreach (var playerSession in _playerManager.ServerSessions)
|
||||||
{
|
{
|
||||||
var playerEntity = playerSession.AttachedEntity;
|
if (playerSession.AttachedEntity is not {Valid: true} playerEntity
|
||||||
if (playerEntity == null
|
|| !_entityManager.TryGetComponent(playerEntity, out MobStateComponent? state))
|
||||||
|| !IoCManager.Resolve<IEntityManager>().TryGetComponent(playerEntity, out MobStateComponent? state))
|
|
||||||
{
|
{
|
||||||
continue;
|
continue;
|
||||||
}
|
}
|
||||||
|
|||||||
@@ -1,6 +1,4 @@
|
|||||||
using System;
|
using System;
|
||||||
using System.Collections.Generic;
|
|
||||||
using System.Linq;
|
|
||||||
using System.Threading;
|
using System.Threading;
|
||||||
using Content.Server.Chat.Managers;
|
using Content.Server.Chat.Managers;
|
||||||
using Content.Server.Doors;
|
using Content.Server.Doors;
|
||||||
@@ -35,6 +33,7 @@ namespace Content.Server.GameTicking.Rules
|
|||||||
[Dependency] private readonly IChatManager _chatManager = default!;
|
[Dependency] private readonly IChatManager _chatManager = default!;
|
||||||
[Dependency] private readonly IConfigurationManager _cfg = default!;
|
[Dependency] private readonly IConfigurationManager _cfg = default!;
|
||||||
[Dependency] private readonly IGameTiming _timing = default!;
|
[Dependency] private readonly IGameTiming _timing = default!;
|
||||||
|
[Dependency] private readonly IEntityManager _entities = default!;
|
||||||
|
|
||||||
[DataField("addedSound")] private SoundSpecifier _addedSound = new SoundPathSpecifier("/Audio/Misc/tatoralert.ogg");
|
[DataField("addedSound")] private SoundSpecifier _addedSound = new SoundPathSpecifier("/Audio/Misc/tatoralert.ogg");
|
||||||
|
|
||||||
@@ -90,9 +89,9 @@ namespace Content.Server.GameTicking.Rules
|
|||||||
|
|
||||||
foreach (var playerSession in _playerManager.ServerSessions)
|
foreach (var playerSession in _playerManager.ServerSessions)
|
||||||
{
|
{
|
||||||
if (playerSession.AttachedEntity == null
|
if (playerSession.AttachedEntity is not {Valid: true} playerEntity
|
||||||
|| !IoCManager.Resolve<IEntityManager>().TryGetComponent(playerSession.AttachedEntity, out MobStateComponent? mobState)
|
|| !_entities.TryGetComponent(playerEntity, out MobStateComponent? mobState)
|
||||||
|| !IoCManager.Resolve<IEntityManager>().HasComponent<SuspicionRoleComponent>(playerSession.AttachedEntity))
|
|| !_entities.HasComponent<SuspicionRoleComponent>(playerEntity))
|
||||||
{
|
{
|
||||||
continue;
|
continue;
|
||||||
}
|
}
|
||||||
|
|||||||
@@ -64,7 +64,7 @@ namespace Content.Server.Ghost
|
|||||||
visibility.Layer |= (int) VisibilityFlags.Ghost;
|
visibility.Layer |= (int) VisibilityFlags.Ghost;
|
||||||
visibility.Layer &= ~(int) VisibilityFlags.Normal;
|
visibility.Layer &= ~(int) VisibilityFlags.Normal;
|
||||||
|
|
||||||
if (IoCManager.Resolve<IEntityManager>().TryGetComponent(component.Owner, out EyeComponent? eye))
|
if (EntityManager.TryGetComponent(component.Owner, out EyeComponent? eye))
|
||||||
{
|
{
|
||||||
eye.VisibilityMask |= (uint) VisibilityFlags.Ghost;
|
eye.VisibilityMask |= (uint) VisibilityFlags.Ghost;
|
||||||
}
|
}
|
||||||
@@ -75,17 +75,17 @@ namespace Content.Server.Ghost
|
|||||||
private void OnGhostShutdown(EntityUid uid, GhostComponent component, ComponentShutdown args)
|
private void OnGhostShutdown(EntityUid uid, GhostComponent component, ComponentShutdown args)
|
||||||
{
|
{
|
||||||
// Perf: If the entity is deleting itself, no reason to change these back.
|
// Perf: If the entity is deleting itself, no reason to change these back.
|
||||||
if ((!IoCManager.Resolve<IEntityManager>().EntityExists(component.Owner) ? EntityLifeStage.Deleted : IoCManager.Resolve<IEntityManager>().GetComponent<MetaDataComponent>(component.Owner).EntityLifeStage) < EntityLifeStage.Terminating)
|
if ((!EntityManager.EntityExists(component.Owner) ? EntityLifeStage.Deleted : EntityManager.GetComponent<MetaDataComponent>(component.Owner).EntityLifeStage) < EntityLifeStage.Terminating)
|
||||||
{
|
{
|
||||||
// Entity can't be seen by ghosts anymore.
|
// Entity can't be seen by ghosts anymore.
|
||||||
if (IoCManager.Resolve<IEntityManager>().TryGetComponent(component.Owner, out VisibilityComponent? visibility))
|
if (EntityManager.TryGetComponent(component.Owner, out VisibilityComponent? visibility))
|
||||||
{
|
{
|
||||||
visibility.Layer &= ~(int) VisibilityFlags.Ghost;
|
visibility.Layer &= ~(int) VisibilityFlags.Ghost;
|
||||||
visibility.Layer |= (int) VisibilityFlags.Normal;
|
visibility.Layer |= (int) VisibilityFlags.Normal;
|
||||||
}
|
}
|
||||||
|
|
||||||
// Entity can't see ghosts anymore.
|
// Entity can't see ghosts anymore.
|
||||||
if (IoCManager.Resolve<IEntityManager>().TryGetComponent(component.Owner, out EyeComponent? eye))
|
if (EntityManager.TryGetComponent(component.Owner, out EyeComponent? eye))
|
||||||
{
|
{
|
||||||
eye.VisibilityMask &= ~(uint) VisibilityFlags.Ghost;
|
eye.VisibilityMask &= ~(uint) VisibilityFlags.Ghost;
|
||||||
}
|
}
|
||||||
@@ -114,10 +114,8 @@ namespace Content.Server.Ghost
|
|||||||
|
|
||||||
private void OnGhostWarpsRequest(GhostWarpsRequestEvent msg, EntitySessionEventArgs args)
|
private void OnGhostWarpsRequest(GhostWarpsRequestEvent msg, EntitySessionEventArgs args)
|
||||||
{
|
{
|
||||||
var entity = args.SenderSession.AttachedEntity;
|
if (args.SenderSession.AttachedEntity is not {Valid: true} entity ||
|
||||||
|
!EntityManager.HasComponent<GhostComponent>(entity))
|
||||||
if (entity == null ||
|
|
||||||
!IoCManager.Resolve<IEntityManager>().HasComponent<GhostComponent>(entity))
|
|
||||||
{
|
{
|
||||||
Logger.Warning($"User {args.SenderSession.Name} sent a {nameof(GhostWarpsRequestEvent)} without being a ghost.");
|
Logger.Warning($"User {args.SenderSession.Name} sent a {nameof(GhostWarpsRequestEvent)} without being a ghost.");
|
||||||
return;
|
return;
|
||||||
@@ -129,12 +127,10 @@ namespace Content.Server.Ghost
|
|||||||
|
|
||||||
private void OnGhostReturnToBodyRequest(GhostReturnToBodyRequest msg, EntitySessionEventArgs args)
|
private void OnGhostReturnToBodyRequest(GhostReturnToBodyRequest msg, EntitySessionEventArgs args)
|
||||||
{
|
{
|
||||||
var entity = args.SenderSession.AttachedEntity;
|
if (args.SenderSession.AttachedEntity is not {Valid: true} attached ||
|
||||||
|
!EntityManager.TryGetComponent(attached, out GhostComponent? ghost) ||
|
||||||
if (entity == null ||
|
|
||||||
!IoCManager.Resolve<IEntityManager>().TryGetComponent(entity, out GhostComponent? ghost) ||
|
|
||||||
!ghost.CanReturnToBody ||
|
!ghost.CanReturnToBody ||
|
||||||
!IoCManager.Resolve<IEntityManager>().TryGetComponent(entity, out ActorComponent? actor))
|
!EntityManager.TryGetComponent(attached, out ActorComponent? actor))
|
||||||
{
|
{
|
||||||
Logger.Warning($"User {args.SenderSession.Name} sent an invalid {nameof(GhostReturnToBodyRequest)}");
|
Logger.Warning($"User {args.SenderSession.Name} sent an invalid {nameof(GhostReturnToBodyRequest)}");
|
||||||
return;
|
return;
|
||||||
@@ -145,8 +141,8 @@ namespace Content.Server.Ghost
|
|||||||
|
|
||||||
private void OnGhostWarpToLocationRequest(GhostWarpToLocationRequestEvent msg, EntitySessionEventArgs args)
|
private void OnGhostWarpToLocationRequest(GhostWarpToLocationRequestEvent msg, EntitySessionEventArgs args)
|
||||||
{
|
{
|
||||||
if (args.SenderSession.AttachedEntity == null ||
|
if (args.SenderSession.AttachedEntity is not {Valid: true} attached ||
|
||||||
!IoCManager.Resolve<IEntityManager>().TryGetComponent(args.SenderSession.AttachedEntity, out GhostComponent? ghost))
|
!EntityManager.TryGetComponent(attached, out GhostComponent? ghost))
|
||||||
{
|
{
|
||||||
Logger.Warning($"User {args.SenderSession.Name} tried to warp to {msg.Name} without being a ghost.");
|
Logger.Warning($"User {args.SenderSession.Name} tried to warp to {msg.Name} without being a ghost.");
|
||||||
return;
|
return;
|
||||||
@@ -154,7 +150,7 @@ namespace Content.Server.Ghost
|
|||||||
|
|
||||||
if (FindLocation(msg.Name) is { } warp)
|
if (FindLocation(msg.Name) is { } warp)
|
||||||
{
|
{
|
||||||
IoCManager.Resolve<IEntityManager>().GetComponent<TransformComponent>(ghost.Owner).Coordinates = IoCManager.Resolve<IEntityManager>().GetComponent<TransformComponent>(warp.Owner).Coordinates;
|
EntityManager.GetComponent<TransformComponent>(ghost.Owner).Coordinates = EntityManager.GetComponent<TransformComponent>(warp.Owner).Coordinates;
|
||||||
}
|
}
|
||||||
|
|
||||||
Logger.Warning($"User {args.SenderSession.Name} tried to warp to an invalid warp: {msg.Name}");
|
Logger.Warning($"User {args.SenderSession.Name} tried to warp to an invalid warp: {msg.Name}");
|
||||||
@@ -162,32 +158,32 @@ namespace Content.Server.Ghost
|
|||||||
|
|
||||||
private void OnGhostWarpToTargetRequest(GhostWarpToTargetRequestEvent msg, EntitySessionEventArgs args)
|
private void OnGhostWarpToTargetRequest(GhostWarpToTargetRequestEvent msg, EntitySessionEventArgs args)
|
||||||
{
|
{
|
||||||
if (args.SenderSession.AttachedEntity == null ||
|
if (args.SenderSession.AttachedEntity is not {Valid: true} attached ||
|
||||||
!IoCManager.Resolve<IEntityManager>().TryGetComponent(args.SenderSession.AttachedEntity, out GhostComponent? ghost))
|
!EntityManager.TryGetComponent(attached, out GhostComponent? ghost))
|
||||||
{
|
{
|
||||||
Logger.Warning($"User {args.SenderSession.Name} tried to warp to {msg.Target} without being a ghost.");
|
Logger.Warning($"User {args.SenderSession.Name} tried to warp to {msg.Target} without being a ghost.");
|
||||||
return;
|
return;
|
||||||
}
|
}
|
||||||
|
|
||||||
if (!EntityManager.EntityExists(msg.Target)
|
if (!EntityManager.EntityExists(msg.Target))
|
||||||
{
|
{
|
||||||
Logger.Warning($"User {args.SenderSession.Name} tried to warp to an invalid entity id: {msg.Target}");
|
Logger.Warning($"User {args.SenderSession.Name} tried to warp to an invalid entity id: {msg.Target}");
|
||||||
return;
|
return;
|
||||||
}
|
}
|
||||||
|
|
||||||
IoCManager.Resolve<IEntityManager>().GetComponent<TransformComponent>(ghost.Owner).Coordinates = IoCManager.Resolve<IEntityManager>().GetComponent<TransformComponent>(entity).Coordinates;
|
EntityManager.GetComponent<TransformComponent>(ghost.Owner).Coordinates = EntityManager.GetComponent<TransformComponent>(msg.Target).Coordinates;
|
||||||
}
|
}
|
||||||
|
|
||||||
private void DeleteEntity(EntityUid uid)
|
private void DeleteEntity(EntityUid uid)
|
||||||
{
|
{
|
||||||
if (!EntityManager.EntityExists(uid)
|
if (!EntityManager.EntityExists(uid)
|
||||||
|| (!IoCManager.Resolve<IEntityManager>().EntityExists(entity) ? EntityLifeStage.Deleted : IoCManager.Resolve<IEntityManager>().GetComponent<MetaDataComponent>(entity).EntityLifeStage) >= EntityLifeStage.Deleted
|
|| (!EntityManager.EntityExists(uid) ? EntityLifeStage.Deleted : EntityManager.GetComponent<MetaDataComponent>(uid).EntityLifeStage) >= EntityLifeStage.Deleted
|
||||||
|| (!IoCManager.Resolve<IEntityManager>().EntityExists(entity) ? EntityLifeStage.Deleted : IoCManager.Resolve<IEntityManager>().GetComponent<MetaDataComponent>(entity).EntityLifeStage) == EntityLifeStage.Terminating)
|
|| (!EntityManager.EntityExists(uid) ? EntityLifeStage.Deleted : EntityManager.GetComponent<MetaDataComponent>(uid).EntityLifeStage) == EntityLifeStage.Terminating)
|
||||||
return;
|
return;
|
||||||
|
|
||||||
if (IoCManager.Resolve<IEntityManager>().TryGetComponent<MindComponent?>(entity, out var mind))
|
if (EntityManager.TryGetComponent<MindComponent?>(uid, out var mind))
|
||||||
mind.GhostOnShutdown = false;
|
mind.GhostOnShutdown = false;
|
||||||
IoCManager.Resolve<IEntityManager>().DeleteEntity((EntityUid) entity);
|
EntityManager.DeleteEntity(uid);
|
||||||
}
|
}
|
||||||
|
|
||||||
private IEnumerable<string> GetLocationNames()
|
private IEnumerable<string> GetLocationNames()
|
||||||
@@ -220,9 +216,9 @@ namespace Content.Server.Ghost
|
|||||||
|
|
||||||
foreach (var player in _playerManager.Sessions)
|
foreach (var player in _playerManager.Sessions)
|
||||||
{
|
{
|
||||||
if (player.AttachedEntity != null)
|
if (player.AttachedEntity is {Valid: true} attached)
|
||||||
{
|
{
|
||||||
players.Add(player.AttachedEntity, IoCManager.Resolve<IEntityManager>().GetComponent<MetaDataComponent>(player.AttachedEntity).EntityName);
|
players.Add(attached, EntityManager.GetComponent<MetaDataComponent>(attached).EntityName);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|||||||
@@ -6,17 +6,17 @@ using Content.Server.Ghost.Roles.Components;
|
|||||||
using Content.Server.Ghost.Roles.UI;
|
using Content.Server.Ghost.Roles.UI;
|
||||||
using Content.Server.Players;
|
using Content.Server.Players;
|
||||||
using Content.Shared.GameTicking;
|
using Content.Shared.GameTicking;
|
||||||
using Content.Shared.Ghost.Roles;
|
|
||||||
using Content.Shared.Ghost;
|
using Content.Shared.Ghost;
|
||||||
|
using Content.Shared.Ghost.Roles;
|
||||||
using JetBrains.Annotations;
|
using JetBrains.Annotations;
|
||||||
using Robust.Server.GameObjects;
|
using Robust.Server.GameObjects;
|
||||||
using Robust.Server.Player;
|
using Robust.Server.Player;
|
||||||
using Robust.Shared.Console;
|
using Robust.Shared.Console;
|
||||||
|
using Robust.Shared.Enums;
|
||||||
using Robust.Shared.GameObjects;
|
using Robust.Shared.GameObjects;
|
||||||
using Robust.Shared.IoC;
|
using Robust.Shared.IoC;
|
||||||
using Robust.Shared.ViewVariables;
|
|
||||||
using Robust.Shared.Utility;
|
using Robust.Shared.Utility;
|
||||||
using Robust.Shared.Enums;
|
using Robust.Shared.ViewVariables;
|
||||||
|
|
||||||
namespace Content.Server.Ghost.Roles
|
namespace Content.Server.Ghost.Roles
|
||||||
{
|
{
|
||||||
@@ -59,7 +59,8 @@ namespace Content.Server.Ghost.Roles
|
|||||||
|
|
||||||
public void OpenEui(IPlayerSession session)
|
public void OpenEui(IPlayerSession session)
|
||||||
{
|
{
|
||||||
if (session.AttachedEntity == null || !IoCManager.Resolve<IEntityManager>().HasComponent<GhostComponent>(session.AttachedEntity))
|
if (session.AttachedEntity is not {Valid: true} attached ||
|
||||||
|
!EntityManager.HasComponent<GhostComponent>(attached))
|
||||||
return;
|
return;
|
||||||
|
|
||||||
if(_openUis.ContainsKey(session))
|
if(_openUis.ContainsKey(session))
|
||||||
@@ -194,7 +195,7 @@ namespace Content.Server.Ghost.Roles
|
|||||||
{
|
{
|
||||||
// Close the session of any player that has a ghost roles window open and isn't a ghost anymore.
|
// Close the session of any player that has a ghost roles window open and isn't a ghost anymore.
|
||||||
if (!_openUis.ContainsKey(message.Player)) return;
|
if (!_openUis.ContainsKey(message.Player)) return;
|
||||||
if (IoCManager.Resolve<IEntityManager>().HasComponent<GhostComponent>(message.Entity)) return;
|
if (EntityManager.HasComponent<GhostComponent>(message.Entity)) return;
|
||||||
CloseEui(message.Player);
|
CloseEui(message.Player);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|||||||
@@ -79,9 +79,9 @@ namespace Content.Server.Gravity.EntitySystems
|
|||||||
{
|
{
|
||||||
foreach (var player in _playerManager.Sessions)
|
foreach (var player in _playerManager.Sessions)
|
||||||
{
|
{
|
||||||
if (player.AttachedEntity == null
|
if (player.AttachedEntity is not {Valid: true} attached
|
||||||
|| IoCManager.Resolve<IEntityManager>().GetComponent<TransformComponent>(player.AttachedEntity).GridID != gridId
|
|| EntityManager.GetComponent<TransformComponent>(attached).GridID != gridId
|
||||||
|| !IoCManager.Resolve<IEntityManager>().TryGetComponent(player.AttachedEntity, out CameraRecoilComponent? recoil))
|
|| !EntityManager.TryGetComponent(attached, out CameraRecoilComponent? recoil))
|
||||||
{
|
{
|
||||||
continue;
|
continue;
|
||||||
}
|
}
|
||||||
|
|||||||
@@ -34,15 +34,14 @@ namespace Content.Server.Gravity.EntitySystems
|
|||||||
|
|
||||||
public void AddAlert(ServerAlertsComponent status)
|
public void AddAlert(ServerAlertsComponent status)
|
||||||
{
|
{
|
||||||
var gridId = IoCManager.Resolve<IEntityManager>().GetComponent<TransformComponent>(status.Owner).GridID;
|
var gridId = EntityManager.GetComponent<TransformComponent>(status.Owner).GridID;
|
||||||
var alerts = _alerts.GetOrNew(gridId);
|
var alerts = _alerts.GetOrNew(gridId);
|
||||||
|
|
||||||
alerts.Add(status);
|
alerts.Add(status);
|
||||||
|
|
||||||
if (_mapManager.TryGetGrid(IoCManager.Resolve<IEntityManager>().GetComponent<TransformComponent>(status.Owner).GridID, out var grid))
|
if (_mapManager.TryGetGrid(EntityManager.GetComponent<TransformComponent>(status.Owner).GridID, out var grid))
|
||||||
{
|
{
|
||||||
var gridgrid.GridEntityId
|
if (EntityManager.GetComponent<GravityComponent>(grid.GridEntityId).Enabled)
|
||||||
if (IoCManager.Resolve<IEntityManager>().GetComponent<GravityComponent>(gridEntity).Enabled)
|
|
||||||
{
|
{
|
||||||
RemoveWeightless(status);
|
RemoveWeightless(status);
|
||||||
}
|
}
|
||||||
@@ -55,7 +54,7 @@ namespace Content.Server.Gravity.EntitySystems
|
|||||||
|
|
||||||
public void RemoveAlert(ServerAlertsComponent status)
|
public void RemoveAlert(ServerAlertsComponent status)
|
||||||
{
|
{
|
||||||
var grid = IoCManager.Resolve<IEntityManager>().GetComponent<TransformComponent>(status.Owner).GridID;
|
var grid = EntityManager.GetComponent<TransformComponent>(status.Owner).GridID;
|
||||||
if (!_alerts.TryGetValue(grid, out var statuses))
|
if (!_alerts.TryGetValue(grid, out var statuses))
|
||||||
{
|
{
|
||||||
return;
|
return;
|
||||||
@@ -99,13 +98,13 @@ namespace Content.Server.Gravity.EntitySystems
|
|||||||
|
|
||||||
private void EntParentChanged(ref EntParentChangedMessage ev)
|
private void EntParentChanged(ref EntParentChangedMessage ev)
|
||||||
{
|
{
|
||||||
if (!IoCManager.Resolve<IEntityManager>().TryGetComponent(ev.Entity, out ServerAlertsComponent? status))
|
if (!EntityManager.TryGetComponent(ev.Entity, out ServerAlertsComponent? status))
|
||||||
{
|
{
|
||||||
return;
|
return;
|
||||||
}
|
}
|
||||||
|
|
||||||
if (ev.OldParent != null &&
|
if (ev.OldParent is {Valid: true} old &&
|
||||||
IoCManager.Resolve<IEntityManager>().TryGetComponent(ev.OldParent, out IMapGridComponent? mapGrid))
|
EntityManager.TryGetComponent(old, out IMapGridComponent? mapGrid))
|
||||||
{
|
{
|
||||||
var oldGrid = mapGrid.GridIndex;
|
var oldGrid = mapGrid.GridIndex;
|
||||||
|
|
||||||
@@ -115,7 +114,7 @@ namespace Content.Server.Gravity.EntitySystems
|
|||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
var newGrid = IoCManager.Resolve<IEntityManager>().GetComponent<TransformComponent>(ev.Entity).GridID;
|
var newGrid = EntityManager.GetComponent<TransformComponent>(ev.Entity).GridID;
|
||||||
var newStatuses = _alerts.GetOrNew(newGrid);
|
var newStatuses = _alerts.GetOrNew(newGrid);
|
||||||
|
|
||||||
newStatuses.Add(status);
|
newStatuses.Add(status);
|
||||||
|
|||||||
@@ -31,6 +31,7 @@ namespace Content.Server.Hands.Components
|
|||||||
#pragma warning restore 618
|
#pragma warning restore 618
|
||||||
{
|
{
|
||||||
[Dependency] private readonly IEntitySystemManager _entitySystemManager = default!;
|
[Dependency] private readonly IEntitySystemManager _entitySystemManager = default!;
|
||||||
|
[Dependency] private readonly IEntityManager _entities = default!;
|
||||||
|
|
||||||
[DataField("disarmedSound")] SoundSpecifier _disarmedSound = new SoundPathSpecifier("/Audio/Effects/thudswoosh.ogg");
|
[DataField("disarmedSound")] SoundSpecifier _disarmedSound = new SoundPathSpecifier("/Audio/Effects/thudswoosh.ogg");
|
||||||
|
|
||||||
@@ -38,27 +39,27 @@ namespace Content.Server.Hands.Components
|
|||||||
|
|
||||||
protected override void OnHeldEntityRemovedFromHand(EntityUid heldEntity, HandState handState)
|
protected override void OnHeldEntityRemovedFromHand(EntityUid heldEntity, HandState handState)
|
||||||
{
|
{
|
||||||
if (IoCManager.Resolve<IEntityManager>().TryGetComponent(heldEntity, out ItemComponent? item))
|
if (_entities.TryGetComponent(heldEntity, out ItemComponent? item))
|
||||||
{
|
{
|
||||||
item.RemovedFromSlot();
|
item.RemovedFromSlot();
|
||||||
_entitySystemManager.GetEntitySystem<InteractionSystem>().UnequippedHandInteraction(Owner, heldEntity, handState);
|
_entitySystemManager.GetEntitySystem<InteractionSystem>().UnequippedHandInteraction(Owner, heldEntity, handState);
|
||||||
}
|
}
|
||||||
if (IoCManager.Resolve<IEntityManager>().TryGetComponent(heldEntity, out SpriteComponent? sprite))
|
if (_entities.TryGetComponent(heldEntity, out SpriteComponent? sprite))
|
||||||
{
|
{
|
||||||
sprite.RenderOrder = IoCManager.Resolve<IEntityManager>().CurrentTick.Value;
|
sprite.RenderOrder = _entities.CurrentTick.Value;
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
protected override void HandlePickupAnimation(EntityUid entity)
|
protected override void HandlePickupAnimation(EntityUid entity)
|
||||||
{
|
{
|
||||||
var initialPosition = EntityCoordinates.FromMap(IoCManager.Resolve<IEntityManager>().GetComponent<TransformComponent>(Owner).Parent?.Owner ?? Owner, IoCManager.Resolve<IEntityManager>().GetComponent<TransformComponent>(entity).MapPosition);
|
var initialPosition = EntityCoordinates.FromMap(_entities.GetComponent<TransformComponent>(Owner).Parent?.Owner ?? Owner, _entities.GetComponent<TransformComponent>(entity).MapPosition);
|
||||||
|
|
||||||
var finalPosition = IoCManager.Resolve<IEntityManager>().GetComponent<TransformComponent>(Owner).LocalPosition;
|
var finalPosition = _entities.GetComponent<TransformComponent>(Owner).LocalPosition;
|
||||||
|
|
||||||
if (finalPosition.EqualsApprox(initialPosition.Position))
|
if (finalPosition.EqualsApprox(initialPosition.Position))
|
||||||
return;
|
return;
|
||||||
|
|
||||||
IoCManager.Resolve<IEntityManager>().EntityNetManager!.SendSystemNetworkMessage(
|
_entities.EntityNetManager!.SendSystemNetworkMessage(
|
||||||
new PickupAnimationMessage(entity, finalPosition, initialPosition));
|
new PickupAnimationMessage(entity, finalPosition, initialPosition));
|
||||||
}
|
}
|
||||||
|
|
||||||
@@ -106,13 +107,13 @@ namespace Content.Server.Hands.Components
|
|||||||
{
|
{
|
||||||
if (ActiveHand != null && Drop(ActiveHand, false))
|
if (ActiveHand != null && Drop(ActiveHand, false))
|
||||||
{
|
{
|
||||||
source.PopupMessageOtherClients(Loc.GetString("hands-component-disarm-success-others-message", ("disarmer", Name: IoCManager.Resolve<IEntityManager>().GetComponent<MetaDataComponent>(source).EntityName), ("disarmed", Name: IoCManager.Resolve<IEntityManager>().GetComponent<MetaDataComponent>(target).EntityName)));
|
source.PopupMessageOtherClients(Loc.GetString("hands-component-disarm-success-others-message", ("disarmer", Name: _entities.GetComponent<MetaDataComponent>(source).EntityName), ("disarmed", Name: _entities.GetComponent<MetaDataComponent>(target).EntityName)));
|
||||||
source.PopupMessageCursor(Loc.GetString("hands-component-disarm-success-message", ("disarmed", Name: IoCManager.Resolve<IEntityManager>().GetComponent<MetaDataComponent>(target).EntityName)));
|
source.PopupMessageCursor(Loc.GetString("hands-component-disarm-success-message", ("disarmed", Name: _entities.GetComponent<MetaDataComponent>(target).EntityName)));
|
||||||
}
|
}
|
||||||
else
|
else
|
||||||
{
|
{
|
||||||
source.PopupMessageOtherClients(Loc.GetString("hands-component-shove-success-others-message", ("shover", Name: IoCManager.Resolve<IEntityManager>().GetComponent<MetaDataComponent>(source).EntityName), ("shoved", Name: IoCManager.Resolve<IEntityManager>().GetComponent<MetaDataComponent>(target).EntityName)));
|
source.PopupMessageOtherClients(Loc.GetString("hands-component-shove-success-others-message", ("shover", Name: _entities.GetComponent<MetaDataComponent>(source).EntityName), ("shoved", Name: _entities.GetComponent<MetaDataComponent>(target).EntityName)));
|
||||||
source.PopupMessageCursor(Loc.GetString("hands-component-shove-success-message", ("shoved", Name: IoCManager.Resolve<IEntityManager>().GetComponent<MetaDataComponent>(target).EntityName)));
|
source.PopupMessageCursor(Loc.GetString("hands-component-shove-success-message", ("shoved", Name: _entities.GetComponent<MetaDataComponent>(target).EntityName)));
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
@@ -123,8 +124,8 @@ namespace Content.Server.Hands.Components
|
|||||||
private bool BreakPulls()
|
private bool BreakPulls()
|
||||||
{
|
{
|
||||||
// What is this API??
|
// What is this API??
|
||||||
if (!IoCManager.Resolve<IEntityManager>().TryGetComponent(Owner, out SharedPullerComponent? puller)
|
if (!_entities.TryGetComponent(Owner, out SharedPullerComponent? puller)
|
||||||
|| puller.Pulling == null || !IoCManager.Resolve<IEntityManager>().TryGetComponent(puller.Pulling, out SharedPullableComponent? pullable))
|
|| puller.Pulling is not {Valid: true} pulling || !_entities.TryGetComponent(puller.Pulling.Value, out SharedPullableComponent? pullable))
|
||||||
return false;
|
return false;
|
||||||
|
|
||||||
return _entitySystemManager.GetEntitySystem<PullingSystem>().TryStopPull(pullable);
|
return _entitySystemManager.GetEntitySystem<PullingSystem>().TryStopPull(pullable);
|
||||||
@@ -163,7 +164,7 @@ namespace Content.Server.Hands.Components
|
|||||||
if (!TryGetHeldEntity(handName, out var heldEntity))
|
if (!TryGetHeldEntity(handName, out var heldEntity))
|
||||||
return null;
|
return null;
|
||||||
|
|
||||||
IoCManager.Resolve<IEntityManager>().TryGetComponent(heldEntity, out ItemComponent? item);
|
_entities.TryGetComponent(heldEntity, out ItemComponent? item);
|
||||||
return item;
|
return item;
|
||||||
}
|
}
|
||||||
|
|
||||||
@@ -177,7 +178,7 @@ namespace Content.Server.Hands.Components
|
|||||||
if (!TryGetHeldEntity(handName, out var heldEntity))
|
if (!TryGetHeldEntity(handName, out var heldEntity))
|
||||||
return false;
|
return false;
|
||||||
|
|
||||||
return IoCManager.Resolve<IEntityManager>().TryGetComponent(heldEntity, out item);
|
return _entities.TryGetComponent(heldEntity, out item);
|
||||||
}
|
}
|
||||||
|
|
||||||
/// <summary>
|
/// <summary>
|
||||||
@@ -190,7 +191,7 @@ namespace Content.Server.Hands.Components
|
|||||||
if (!TryGetActiveHeldEntity(out var heldEntity))
|
if (!TryGetActiveHeldEntity(out var heldEntity))
|
||||||
return null;
|
return null;
|
||||||
|
|
||||||
IoCManager.Resolve<IEntityManager>().TryGetComponent(heldEntity, out ItemComponent? item);
|
_entities.TryGetComponent(heldEntity, out ItemComponent? item);
|
||||||
return item;
|
return item;
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
@@ -199,7 +200,7 @@ namespace Content.Server.Hands.Components
|
|||||||
{
|
{
|
||||||
foreach (var entity in GetAllHeldEntities())
|
foreach (var entity in GetAllHeldEntities())
|
||||||
{
|
{
|
||||||
if (IoCManager.Resolve<IEntityManager>().TryGetComponent(entity, out ItemComponent? item))
|
if (_entities.TryGetComponent(entity, out ItemComponent? item))
|
||||||
yield return item;
|
yield return item;
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|||||||
@@ -14,8 +14,10 @@ using Content.Shared.Hands;
|
|||||||
using Content.Shared.Hands.Components;
|
using Content.Shared.Hands.Components;
|
||||||
using Content.Shared.Input;
|
using Content.Shared.Input;
|
||||||
using Content.Shared.Physics.Pull;
|
using Content.Shared.Physics.Pull;
|
||||||
|
using Content.Shared.Popups;
|
||||||
using JetBrains.Annotations;
|
using JetBrains.Annotations;
|
||||||
using Robust.Server.Player;
|
using Robust.Server.Player;
|
||||||
|
using Robust.Shared.Containers;
|
||||||
using Robust.Shared.GameObjects;
|
using Robust.Shared.GameObjects;
|
||||||
using Robust.Shared.Input.Binding;
|
using Robust.Shared.Input.Binding;
|
||||||
using Robust.Shared.IoC;
|
using Robust.Shared.IoC;
|
||||||
@@ -187,9 +189,7 @@ namespace Content.Server.Hands.Systems
|
|||||||
if (session is not IPlayerSession playerSession)
|
if (session is not IPlayerSession playerSession)
|
||||||
return false;
|
return false;
|
||||||
|
|
||||||
var playerEnt = playerSession.AttachedEntity;
|
if (playerSession.AttachedEntity is not {Valid: true} playerEnt || !EntityManager.EntityExists(playerEnt))
|
||||||
|
|
||||||
if (playerEnt == default || !EntityManager.EntityExists(playerEnt))
|
|
||||||
return false;
|
return false;
|
||||||
|
|
||||||
return EntityManager.TryGetComponent(playerEnt, out hands);
|
return EntityManager.TryGetComponent(playerEnt, out hands);
|
||||||
@@ -216,9 +216,7 @@ namespace Content.Server.Hands.Systems
|
|||||||
if (session is not IPlayerSession playerSession)
|
if (session is not IPlayerSession playerSession)
|
||||||
return false;
|
return false;
|
||||||
|
|
||||||
var playerEnt = playerSession.AttachedEntity;
|
if (playerSession.AttachedEntity is not {Valid: true} playerEnt ||
|
||||||
|
|
||||||
if (playerEnt == default ||
|
|
||||||
!EntityManager.EntityExists(playerEnt) ||
|
!EntityManager.EntityExists(playerEnt) ||
|
||||||
playerEnt.IsInContainer() ||
|
playerEnt.IsInContainer() ||
|
||||||
!EntityManager.TryGetComponent(playerEnt, out SharedHandsComponent? hands) ||
|
!EntityManager.TryGetComponent(playerEnt, out SharedHandsComponent? hands) ||
|
||||||
@@ -230,10 +228,10 @@ namespace Content.Server.Hands.Systems
|
|||||||
{
|
{
|
||||||
var splitStack = _stackSystem.Split(throwEnt, 1, EntityManager.GetComponent<TransformComponent>(playerEnt).Coordinates, stack);
|
var splitStack = _stackSystem.Split(throwEnt, 1, EntityManager.GetComponent<TransformComponent>(playerEnt).Coordinates, stack);
|
||||||
|
|
||||||
if (!splitStack.Valid)
|
if (splitStack is not {Valid: true})
|
||||||
return false;
|
return false;
|
||||||
|
|
||||||
throwEnt = splitStack;
|
throwEnt = splitStack.Value;
|
||||||
}
|
}
|
||||||
else if (!hands.Drop(throwEnt))
|
else if (!hands.Drop(throwEnt))
|
||||||
return false;
|
return false;
|
||||||
@@ -265,9 +263,7 @@ namespace Content.Server.Hands.Systems
|
|||||||
if (session is not IPlayerSession playerSession)
|
if (session is not IPlayerSession playerSession)
|
||||||
return;
|
return;
|
||||||
|
|
||||||
var plyEnt = playerSession.AttachedEntity;
|
if (playerSession.AttachedEntity is not {Valid: true} plyEnt || !EntityManager.EntityExists(plyEnt))
|
||||||
|
|
||||||
if (plyEnt == default || !EntityManager.EntityExists(plyEnt))
|
|
||||||
return;
|
return;
|
||||||
|
|
||||||
if (!EntityManager.TryGetComponent(plyEnt, out SharedHandsComponent? hands) ||
|
if (!EntityManager.TryGetComponent(plyEnt, out SharedHandsComponent? hands) ||
|
||||||
|
|||||||
@@ -150,13 +150,11 @@ public sealed partial class InstrumentSystem : SharedInstrumentSystem
|
|||||||
|| instrument.LaggedBatches >= MaxMidiLaggedBatches)
|
|| instrument.LaggedBatches >= MaxMidiLaggedBatches)
|
||||||
&& instrument.InstrumentPlayer != null && instrument.RespectMidiLimits)
|
&& instrument.InstrumentPlayer != null && instrument.RespectMidiLimits)
|
||||||
{
|
{
|
||||||
var mob = instrument.InstrumentPlayer.AttachedEntity;
|
|
||||||
|
|
||||||
// Just in case
|
// Just in case
|
||||||
Clean(((IComponent) instrument).Owner);
|
Clean(((IComponent) instrument).Owner);
|
||||||
instrument.UserInterface?.CloseAll();
|
instrument.UserInterface?.CloseAll();
|
||||||
|
|
||||||
if (mob != null)
|
if (instrument.InstrumentPlayer.AttachedEntity is {Valid: true} mob)
|
||||||
{
|
{
|
||||||
_stunSystem.TryParalyze(mob, TimeSpan.FromSeconds(1));
|
_stunSystem.TryParalyze(mob, TimeSpan.FromSeconds(1));
|
||||||
|
|
||||||
|
|||||||
@@ -5,7 +5,6 @@ using System.Threading.Tasks;
|
|||||||
using Content.Server.Administration.Logs;
|
using Content.Server.Administration.Logs;
|
||||||
using Content.Server.CombatMode;
|
using Content.Server.CombatMode;
|
||||||
using Content.Server.Hands.Components;
|
using Content.Server.Hands.Components;
|
||||||
using Content.Server.Items;
|
|
||||||
using Content.Server.Pulling;
|
using Content.Server.Pulling;
|
||||||
using Content.Server.Storage.Components;
|
using Content.Server.Storage.Components;
|
||||||
using Content.Shared.ActionBlocker;
|
using Content.Shared.ActionBlocker;
|
||||||
@@ -70,7 +69,7 @@ namespace Content.Server.Interaction
|
|||||||
}
|
}
|
||||||
|
|
||||||
#region Client Input Validation
|
#region Client Input Validation
|
||||||
private bool ValidateClientInput(ICommonSession? session, EntityCoordinates coords, EntityUid uid, [NotNullWhen(true)] out EntityUid userEntity)
|
private bool ValidateClientInput(ICommonSession? session, EntityCoordinates coords, EntityUid uid, [NotNullWhen(true)] out EntityUid? userEntity)
|
||||||
{
|
{
|
||||||
userEntity = null;
|
userEntity = null;
|
||||||
|
|
||||||
@@ -89,7 +88,7 @@ namespace Content.Server.Interaction
|
|||||||
|
|
||||||
userEntity = ((IPlayerSession?) session)?.AttachedEntity;
|
userEntity = ((IPlayerSession?) session)?.AttachedEntity;
|
||||||
|
|
||||||
if (userEntity == null || !IoCManager.Resolve<IEntityManager>().EntityExists(userEntity))
|
if (userEntity == null || !EntityManager.EntityExists(userEntity.Value))
|
||||||
{
|
{
|
||||||
Logger.WarningS("system.interaction",
|
Logger.WarningS("system.interaction",
|
||||||
$"Client sent interaction with no attached entity. Session={session}");
|
$"Client sent interaction with no attached entity. Session={session}");
|
||||||
@@ -101,10 +100,10 @@ namespace Content.Server.Interaction
|
|||||||
|
|
||||||
public override bool CanAccessViaStorage(EntityUid user, EntityUid target)
|
public override bool CanAccessViaStorage(EntityUid user, EntityUid target)
|
||||||
{
|
{
|
||||||
if (!EntityManager.EntityExists(target)
|
if (!EntityManager.EntityExists(target))
|
||||||
return false;
|
return false;
|
||||||
|
|
||||||
if (!entity.TryGetContainer(out var container))
|
if (!target.TryGetContainer(out var container))
|
||||||
return false;
|
return false;
|
||||||
|
|
||||||
if (!EntityManager.TryGetComponent(container.Owner, out ServerStorageComponent storage))
|
if (!EntityManager.TryGetComponent(container.Owner, out ServerStorageComponent storage))
|
||||||
@@ -127,7 +126,7 @@ namespace Content.Server.Interaction
|
|||||||
/// </summary>
|
/// </summary>
|
||||||
private void HandleInteractInventorySlotEvent(InteractInventorySlotEvent msg, EntitySessionEventArgs args)
|
private void HandleInteractInventorySlotEvent(InteractInventorySlotEvent msg, EntitySessionEventArgs args)
|
||||||
{
|
{
|
||||||
if (!EntityManager.EntityExists(msg.ItemUid)
|
if (!EntityManager.EntityExists(msg.ItemUid))
|
||||||
{
|
{
|
||||||
Logger.WarningS("system.interaction",
|
Logger.WarningS("system.interaction",
|
||||||
$"Client sent inventory interaction with an invalid target item. Session={args.SenderSession}");
|
$"Client sent inventory interaction with an invalid target item. Session={args.SenderSession}");
|
||||||
@@ -135,7 +134,7 @@ namespace Content.Server.Interaction
|
|||||||
}
|
}
|
||||||
|
|
||||||
// client sanitization
|
// client sanitization
|
||||||
if (!ValidateClientInput(args.SenderSession, IoCManager.Resolve<IEntityManager>().GetComponent<TransformComponent>(item).Coordinates, msg.ItemUid, out var userEntity))
|
if (!ValidateClientInput(args.SenderSession, EntityManager.GetComponent<TransformComponent>(msg.ItemUid).Coordinates, msg.ItemUid, out var userEntity))
|
||||||
{
|
{
|
||||||
Logger.InfoS("system.interaction", $"Inventory interaction validation failed. Session={args.SenderSession}");
|
Logger.InfoS("system.interaction", $"Inventory interaction validation failed. Session={args.SenderSession}");
|
||||||
return;
|
return;
|
||||||
@@ -143,10 +142,10 @@ namespace Content.Server.Interaction
|
|||||||
|
|
||||||
if (msg.AltInteract)
|
if (msg.AltInteract)
|
||||||
// Use 'UserInteraction' function - behaves as if the user alt-clicked the item in the world.
|
// Use 'UserInteraction' function - behaves as if the user alt-clicked the item in the world.
|
||||||
UserInteraction(userEntity, IoCManager.Resolve<IEntityManager>().GetComponent<TransformComponent>(item).Coordinates, msg.ItemUid, msg.AltInteract);
|
UserInteraction(userEntity.Value, EntityManager.GetComponent<TransformComponent>(msg.ItemUid).Coordinates, msg.ItemUid, msg.AltInteract);
|
||||||
else
|
else
|
||||||
// User used 'E'. We want to activate it, not simulate clicking on the item
|
// User used 'E'. We want to activate it, not simulate clicking on the item
|
||||||
InteractionActivate(userEntity, item);
|
InteractionActivate(userEntity.Value, msg.ItemUid);
|
||||||
}
|
}
|
||||||
|
|
||||||
#region Drag drop
|
#region Drag drop
|
||||||
@@ -158,15 +157,15 @@ namespace Content.Server.Interaction
|
|||||||
return;
|
return;
|
||||||
}
|
}
|
||||||
|
|
||||||
if (!_actionBlockerSystem.CanInteract(userEntity))
|
if (!_actionBlockerSystem.CanInteract(userEntity.Value))
|
||||||
return;
|
return;
|
||||||
|
|
||||||
if (!EntityManager.EntityExists(msg.Dropped)
|
if (!EntityManager.EntityExists(msg.Dropped))
|
||||||
return;
|
return;
|
||||||
if (!EntityManager.EntityExists(msg.Target)
|
if (!EntityManager.EntityExists(msg.Target))
|
||||||
return;
|
return;
|
||||||
|
|
||||||
var interactionArgs = new DragDropEvent(userEntity, msg.DropLocation, dropped, target);
|
var interactionArgs = new DragDropEvent(userEntity.Value, msg.DropLocation, msg.Dropped, msg.Target);
|
||||||
|
|
||||||
// must be in range of both the target and the object they are drag / dropping
|
// must be in range of both the target and the object they are drag / dropping
|
||||||
// Client also does this check but ya know we gotta validate it.
|
// Client also does this check but ya know we gotta validate it.
|
||||||
@@ -174,8 +173,8 @@ namespace Content.Server.Interaction
|
|||||||
return;
|
return;
|
||||||
|
|
||||||
// trigger dragdrops on the dropped entity
|
// trigger dragdrops on the dropped entity
|
||||||
RaiseLocalEvent(dropped, interactionArgs);
|
RaiseLocalEvent(msg.Dropped, interactionArgs);
|
||||||
foreach (var dragDrop in IoCManager.Resolve<IEntityManager>().GetComponents<IDraggable>(dropped))
|
foreach (var dragDrop in EntityManager.GetComponents<IDraggable>(msg.Dropped))
|
||||||
{
|
{
|
||||||
if (dragDrop.CanDrop(interactionArgs) &&
|
if (dragDrop.CanDrop(interactionArgs) &&
|
||||||
dragDrop.Drop(interactionArgs))
|
dragDrop.Drop(interactionArgs))
|
||||||
@@ -185,8 +184,8 @@ namespace Content.Server.Interaction
|
|||||||
}
|
}
|
||||||
|
|
||||||
// trigger dragdropons on the targeted entity
|
// trigger dragdropons on the targeted entity
|
||||||
RaiseLocalEvent(target, interactionArgs, false);
|
RaiseLocalEvent(msg.Target, interactionArgs, false);
|
||||||
foreach (var dragDropOn in IoCManager.Resolve<IEntityManager>().GetComponents<IDragDropOn>(target))
|
foreach (var dragDropOn in EntityManager.GetComponents<IDragDropOn>(msg.Target))
|
||||||
{
|
{
|
||||||
if (dragDropOn.CanDragDropOn(interactionArgs) &&
|
if (dragDropOn.CanDragDropOn(interactionArgs) &&
|
||||||
dragDropOn.DragDropOn(interactionArgs))
|
dragDropOn.DragDropOn(interactionArgs))
|
||||||
@@ -206,10 +205,10 @@ namespace Content.Server.Interaction
|
|||||||
return false;
|
return false;
|
||||||
}
|
}
|
||||||
|
|
||||||
if (!EntityManager.EntityExists(uid)
|
if (!EntityManager.EntityExists(uid))
|
||||||
return false;
|
return false;
|
||||||
|
|
||||||
InteractionActivate(user, used);
|
InteractionActivate(user.Value, uid);
|
||||||
return true;
|
return true;
|
||||||
}
|
}
|
||||||
#endregion
|
#endregion
|
||||||
@@ -223,8 +222,8 @@ namespace Content.Server.Interaction
|
|||||||
return true;
|
return true;
|
||||||
}
|
}
|
||||||
|
|
||||||
if (IoCManager.Resolve<IEntityManager>().TryGetComponent(userEntity, out CombatModeComponent? combatMode) && combatMode.IsInCombatMode)
|
if (EntityManager.TryGetComponent(userEntity.Value, out CombatModeComponent? combatMode) && combatMode.IsInCombatMode)
|
||||||
DoAttack(userEntity, coords, true);
|
DoAttack(userEntity.Value, coords, true);
|
||||||
|
|
||||||
return true;
|
return true;
|
||||||
}
|
}
|
||||||
@@ -238,7 +237,7 @@ namespace Content.Server.Interaction
|
|||||||
/// <param name="uid"></param>
|
/// <param name="uid"></param>
|
||||||
internal void AiUseInteraction(EntityUid entity, EntityCoordinates coords, EntityUid uid)
|
internal void AiUseInteraction(EntityUid entity, EntityCoordinates coords, EntityUid uid)
|
||||||
{
|
{
|
||||||
if (IoCManager.Resolve<IEntityManager>().HasComponent<ActorComponent>(entity))
|
if (EntityManager.HasComponent<ActorComponent>(entity))
|
||||||
throw new InvalidOperationException();
|
throw new InvalidOperationException();
|
||||||
|
|
||||||
UserInteraction(entity, coords, uid);
|
UserInteraction(entity, coords, uid);
|
||||||
@@ -253,7 +252,7 @@ namespace Content.Server.Interaction
|
|||||||
return true;
|
return true;
|
||||||
}
|
}
|
||||||
|
|
||||||
UserInteraction(userEntity, coords, uid);
|
UserInteraction(userEntity.Value, coords, uid);
|
||||||
|
|
||||||
return true;
|
return true;
|
||||||
}
|
}
|
||||||
@@ -267,7 +266,7 @@ namespace Content.Server.Interaction
|
|||||||
return true;
|
return true;
|
||||||
}
|
}
|
||||||
|
|
||||||
UserInteraction(userEntity, coords, uid, altInteract : true );
|
UserInteraction(userEntity.Value, coords, uid, altInteract : true );
|
||||||
|
|
||||||
return true;
|
return true;
|
||||||
}
|
}
|
||||||
@@ -283,16 +282,16 @@ namespace Content.Server.Interaction
|
|||||||
if (userEntity == uid)
|
if (userEntity == uid)
|
||||||
return false;
|
return false;
|
||||||
|
|
||||||
if (!EntityManager.EntityExists(uid)
|
if (!EntityManager.EntityExists(uid))
|
||||||
return false;
|
return false;
|
||||||
|
|
||||||
if (!InRangeUnobstructed(userEntity, pulledObject, popup: true))
|
if (!InRangeUnobstructed(userEntity.Value, uid, popup: true))
|
||||||
return false;
|
return false;
|
||||||
|
|
||||||
if (!IoCManager.Resolve<IEntityManager>().TryGetComponent(pulledObject, out SharedPullableComponent? pull))
|
if (!EntityManager.TryGetComponent(uid, out SharedPullableComponent? pull))
|
||||||
return false;
|
return false;
|
||||||
|
|
||||||
return _pullSystem.TogglePull(userEntity, pull);
|
return _pullSystem.TogglePull(userEntity.Value, pull);
|
||||||
}
|
}
|
||||||
|
|
||||||
/// <summary>
|
/// <summary>
|
||||||
@@ -304,12 +303,12 @@ namespace Content.Server.Interaction
|
|||||||
/// <param name="altInteract">Whether to use default or alternative interactions (usually as a result of
|
/// <param name="altInteract">Whether to use default or alternative interactions (usually as a result of
|
||||||
/// alt+clicking). If combat mode is enabled, the alternative action is to perform the default non-combat
|
/// alt+clicking). If combat mode is enabled, the alternative action is to perform the default non-combat
|
||||||
/// interaction. Having an item in the active hand also disables alternative interactions.</param>
|
/// interaction. Having an item in the active hand also disables alternative interactions.</param>
|
||||||
public async void UserInteraction(EntityUid user, EntityCoordinates coordinates, EntityUid clickedUid, bool altInteract = false)
|
public async void UserInteraction(EntityUid user, EntityCoordinates coordinates, EntityUid target, bool altInteract = false)
|
||||||
{
|
{
|
||||||
// TODO COMBAT Consider using alt-interact for advanced combat? maybe alt-interact disarms?
|
// TODO COMBAT Consider using alt-interact for advanced combat? maybe alt-interact disarms?
|
||||||
if (!altInteract && IoCManager.Resolve<IEntityManager>().TryGetComponent(user, out CombatModeComponent? combatMode) && combatMode.IsInCombatMode)
|
if (!altInteract && EntityManager.TryGetComponent(user, out CombatModeComponent? combatMode) && combatMode.IsInCombatMode)
|
||||||
{
|
{
|
||||||
DoAttack(user, coordinates, false, clickedUid);
|
DoAttack(user, coordinates, false, target);
|
||||||
return;
|
return;
|
||||||
}
|
}
|
||||||
|
|
||||||
@@ -319,32 +318,29 @@ namespace Content.Server.Interaction
|
|||||||
if (!_actionBlockerSystem.CanInteract(user))
|
if (!_actionBlockerSystem.CanInteract(user))
|
||||||
return;
|
return;
|
||||||
|
|
||||||
// Get entity clicked upon from UID if valid UID, if not assume no entity clicked upon and null
|
|
||||||
EntityManager.EntityExists(clickedUid);
|
|
||||||
|
|
||||||
// Check if interacted entity is in the same container, the direct child, or direct parent of the user.
|
// Check if interacted entity is in the same container, the direct child, or direct parent of the user.
|
||||||
// This is bypassed IF the interaction happened through an item slot (e.g., backpack UI)
|
// This is bypassed IF the interaction happened through an item slot (e.g., backpack UI)
|
||||||
if (target != null && !user.IsInSameOrParentContainer(target) && !CanAccessViaStorage(user, target))
|
if (target != default && !user.IsInSameOrParentContainer(target) && !CanAccessViaStorage(user, target))
|
||||||
{
|
{
|
||||||
Logger.WarningS("system.interaction",
|
Logger.WarningS("system.interaction",
|
||||||
$"User entity named {IoCManager.Resolve<IEntityManager>().GetComponent<MetaDataComponent>(user).EntityName} clicked on object {IoCManager.Resolve<IEntityManager>().GetComponent<MetaDataComponent>(target).EntityName} that isn't the parent, child, or in the same container");
|
$"User entity named {EntityManager.GetComponent<MetaDataComponent>(user).EntityName} clicked on object {EntityManager.GetComponent<MetaDataComponent>(target).EntityName} that isn't the parent, child, or in the same container");
|
||||||
return;
|
return;
|
||||||
}
|
}
|
||||||
|
|
||||||
// Verify user has a hand, and find what object they are currently holding in their active hand
|
// Verify user has a hand, and find what object they are currently holding in their active hand
|
||||||
if (!IoCManager.Resolve<IEntityManager>().TryGetComponent<HandsComponent?>(user, out var hands))
|
if (!EntityManager.TryGetComponent<HandsComponent?>(user, out var hands))
|
||||||
return;
|
return;
|
||||||
|
|
||||||
var item = hands.GetActiveHand?.Owner;
|
var item = hands.GetActiveHand?.Owner;
|
||||||
|
|
||||||
// TODO: Replace with body interaction range when we get something like arm length or telekinesis or something.
|
// TODO: Replace with body interaction range when we get something like arm length or telekinesis or something.
|
||||||
var inRangeUnobstructed = user.InRangeUnobstructed(coordinates, ignoreInsideBlocker: true);
|
var inRangeUnobstructed = user.InRangeUnobstructed(coordinates, ignoreInsideBlocker: true);
|
||||||
if (target == null || !inRangeUnobstructed)
|
if (target == default || !inRangeUnobstructed)
|
||||||
{
|
{
|
||||||
if (item == null)
|
if (item == null)
|
||||||
return;
|
return;
|
||||||
|
|
||||||
if (!await InteractUsingRanged(user, item, target, coordinates, inRangeUnobstructed) &&
|
if (!await InteractUsingRanged(user, item.Value, target, coordinates, inRangeUnobstructed) &&
|
||||||
!inRangeUnobstructed)
|
!inRangeUnobstructed)
|
||||||
{
|
{
|
||||||
var message = Loc.GetString("interaction-system-user-interaction-cannot-reach");
|
var message = Loc.GetString("interaction-system-user-interaction-cannot-reach");
|
||||||
@@ -362,7 +358,7 @@ namespace Content.Server.Interaction
|
|||||||
else if (item != null && item != target)
|
else if (item != null && item != target)
|
||||||
// We are performing a standard interaction with an item, and the target isn't the same as the item
|
// We are performing a standard interaction with an item, and the target isn't the same as the item
|
||||||
// currently in our hand. We will use the item in our hand on the nearby object via InteractUsing
|
// currently in our hand. We will use the item in our hand on the nearby object via InteractUsing
|
||||||
await InteractUsing(user, item, target, coordinates);
|
await InteractUsing(user, item.Value, target, coordinates);
|
||||||
else if (item == null)
|
else if (item == null)
|
||||||
// Since our hand is empty we will use InteractHand/Activate
|
// Since our hand is empty we will use InteractHand/Activate
|
||||||
InteractHand(user, target);
|
InteractHand(user, target);
|
||||||
@@ -372,10 +368,10 @@ namespace Content.Server.Interaction
|
|||||||
private bool ValidateInteractAndFace(EntityUid user, EntityCoordinates coordinates)
|
private bool ValidateInteractAndFace(EntityUid user, EntityCoordinates coordinates)
|
||||||
{
|
{
|
||||||
// Verify user is on the same map as the entity they clicked on
|
// Verify user is on the same map as the entity they clicked on
|
||||||
if (coordinates.GetMapId(_entityManager) != IoCManager.Resolve<IEntityManager>().GetComponent<TransformComponent>(user).MapID)
|
if (coordinates.GetMapId(_entityManager) != EntityManager.GetComponent<TransformComponent>(user).MapID)
|
||||||
{
|
{
|
||||||
Logger.WarningS("system.interaction",
|
Logger.WarningS("system.interaction",
|
||||||
$"User entity named {IoCManager.Resolve<IEntityManager>().GetComponent<MetaDataComponent>(user).EntityName} clicked on a map they aren't located on");
|
$"User entity named {EntityManager.GetComponent<MetaDataComponent>(user).EntityName} clicked on a map they aren't located on");
|
||||||
return false;
|
return false;
|
||||||
}
|
}
|
||||||
|
|
||||||
@@ -403,7 +399,7 @@ namespace Content.Server.Interaction
|
|||||||
|
|
||||||
var interactHandEventArgs = new InteractHandEventArgs(user, target);
|
var interactHandEventArgs = new InteractHandEventArgs(user, target);
|
||||||
|
|
||||||
var interactHandComps = IoCManager.Resolve<IEntityManager>().GetComponents<IInteractHand>(target).ToList();
|
var interactHandComps = EntityManager.GetComponents<IInteractHand>(target).ToList();
|
||||||
foreach (var interactHandComp in interactHandComps)
|
foreach (var interactHandComp in interactHandComps)
|
||||||
{
|
{
|
||||||
// If an InteractHand returns a status completion we finish our interaction
|
// If an InteractHand returns a status completion we finish our interaction
|
||||||
@@ -433,7 +429,7 @@ namespace Content.Server.Interaction
|
|||||||
if (rangedMsg.Handled)
|
if (rangedMsg.Handled)
|
||||||
return true;
|
return true;
|
||||||
|
|
||||||
var rangedInteractions = IoCManager.Resolve<IEntityManager>().GetComponents<IRangedInteract>(target).ToList();
|
var rangedInteractions = EntityManager.GetComponents<IRangedInteract>(target).ToList();
|
||||||
var rangedInteractionEventArgs = new RangedInteractEventArgs(user, used, clickLocation);
|
var rangedInteractionEventArgs = new RangedInteractEventArgs(user, used, clickLocation);
|
||||||
|
|
||||||
// See if we have a ranged interaction
|
// See if we have a ranged interaction
|
||||||
@@ -458,18 +454,13 @@ namespace Content.Server.Interaction
|
|||||||
if (!_actionBlockerSystem.CanAttack(user))
|
if (!_actionBlockerSystem.CanAttack(user))
|
||||||
return;
|
return;
|
||||||
|
|
||||||
EntityUid targetEnt = null;
|
|
||||||
|
|
||||||
if (!wideAttack)
|
if (!wideAttack)
|
||||||
{
|
{
|
||||||
// Get entity clicked upon from UID if valid UID, if not assume no entity clicked upon and null
|
|
||||||
EntityManager.EntityExists(targetUid);
|
|
||||||
|
|
||||||
// Check if interacted entity is in the same container, the direct child, or direct parent of the user.
|
// Check if interacted entity is in the same container, the direct child, or direct parent of the user.
|
||||||
if (targetEnt != null && !user.IsInSameOrParentContainer(targetEnt) && !CanAccessViaStorage(user, targetEnt))
|
if (targetUid != default && !user.IsInSameOrParentContainer(targetUid) && !CanAccessViaStorage(user, targetUid))
|
||||||
{
|
{
|
||||||
Logger.WarningS("system.interaction",
|
Logger.WarningS("system.interaction",
|
||||||
$"User entity named {IoCManager.Resolve<IEntityManager>().GetComponent<MetaDataComponent>(user).EntityName} clicked on object {IoCManager.Resolve<IEntityManager>().GetComponent<MetaDataComponent>(targetEnt).EntityName} that isn't the parent, child, or in the same container");
|
$"User entity named {EntityManager.GetComponent<MetaDataComponent>(user).EntityName} clicked on object {EntityManager.GetComponent<MetaDataComponent>(targetUid).EntityName} that isn't the parent, child, or in the same container");
|
||||||
return;
|
return;
|
||||||
}
|
}
|
||||||
|
|
||||||
@@ -479,11 +470,9 @@ namespace Content.Server.Interaction
|
|||||||
}
|
}
|
||||||
|
|
||||||
// Verify user has a hand, and find what object they are currently holding in their active hand
|
// Verify user has a hand, and find what object they are currently holding in their active hand
|
||||||
if (IoCManager.Resolve<IEntityManager>().TryGetComponent<HandsComponent?>(user, out var hands))
|
if (EntityManager.TryGetComponent<HandsComponent?>(user, out var hands))
|
||||||
{
|
{
|
||||||
var item = hands.GetActiveHand?.Owner;
|
if (hands.GetActiveHand?.Owner is {Valid: true} item)
|
||||||
|
|
||||||
if (item != null)
|
|
||||||
{
|
{
|
||||||
if (wideAttack)
|
if (wideAttack)
|
||||||
{
|
{
|
||||||
@@ -503,10 +492,10 @@ namespace Content.Server.Interaction
|
|||||||
|
|
||||||
if (ev.Handled)
|
if (ev.Handled)
|
||||||
{
|
{
|
||||||
if (targetEnt != null)
|
if (targetUid != default)
|
||||||
{
|
{
|
||||||
_adminLogSystem.Add(LogType.AttackArmedClick, LogImpact.Medium,
|
_adminLogSystem.Add(LogType.AttackArmedClick, LogImpact.Medium,
|
||||||
$"{user} attacked {targetEnt} with {item} at {coordinates}");
|
$"{user} attacked {targetUid} with {item} at {coordinates}");
|
||||||
}
|
}
|
||||||
else
|
else
|
||||||
{
|
{
|
||||||
@@ -518,12 +507,10 @@ namespace Content.Server.Interaction
|
|||||||
}
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
else if (!wideAttack &&
|
else if (!wideAttack && targetUid != default)
|
||||||
(targetEnt != null || EntityManager.EntityExists(targetUid) &&
|
|
||||||
IoCManager.Resolve<IEntityManager>().HasComponent<ItemComponent>(targetEnt))
|
|
||||||
{
|
{
|
||||||
// We pick up items if our hand is empty, even if we're in combat mode.
|
// We pick up items if our hand is empty, even if we're in combat mode.
|
||||||
InteractHand(user, targetEnt);
|
InteractHand(user, targetUid);
|
||||||
return;
|
return;
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
@@ -543,10 +530,10 @@ namespace Content.Server.Interaction
|
|||||||
RaiseLocalEvent(user, ev, false);
|
RaiseLocalEvent(user, ev, false);
|
||||||
if (ev.Handled)
|
if (ev.Handled)
|
||||||
{
|
{
|
||||||
if (targetEnt != null)
|
if (targetUid != default)
|
||||||
{
|
{
|
||||||
_adminLogSystem.Add(LogType.AttackUnarmedClick, LogImpact.Medium,
|
_adminLogSystem.Add(LogType.AttackUnarmedClick, LogImpact.Medium,
|
||||||
$"{user} attacked {targetEnt} at {coordinates}");
|
$"{user} attacked {targetUid} at {coordinates}");
|
||||||
}
|
}
|
||||||
else
|
else
|
||||||
{
|
{
|
||||||
|
|||||||
@@ -16,6 +16,8 @@ namespace Content.Server.Interaction
|
|||||||
[AdminCommand(AdminFlags.Debug)]
|
[AdminCommand(AdminFlags.Debug)]
|
||||||
class TilePryCommand : IConsoleCommand
|
class TilePryCommand : IConsoleCommand
|
||||||
{
|
{
|
||||||
|
[Dependency] private readonly IEntityManager _entities = default!;
|
||||||
|
|
||||||
public string Command => "tilepry";
|
public string Command => "tilepry";
|
||||||
public string Description => "Pries up all tiles in a radius around the user.";
|
public string Description => "Pries up all tiles in a radius around the user.";
|
||||||
public string Help => $"Usage: {Command} <radius>";
|
public string Help => $"Usage: {Command} <radius>";
|
||||||
@@ -47,9 +49,9 @@ namespace Content.Server.Interaction
|
|||||||
}
|
}
|
||||||
|
|
||||||
var mapManager = IoCManager.Resolve<IMapManager>();
|
var mapManager = IoCManager.Resolve<IMapManager>();
|
||||||
var playerGrid = IoCManager.Resolve<IEntityManager>().GetComponent<TransformComponent>(player.AttachedEntity).GridID;
|
var playerGrid = _entities.GetComponent<TransformComponent>(player.AttachedEntity.Value).GridID;
|
||||||
var mapGrid = mapManager.GetGrid(playerGrid);
|
var mapGrid = mapManager.GetGrid(playerGrid);
|
||||||
var playerPosition = IoCManager.Resolve<IEntityManager>().GetComponent<TransformComponent>(player.AttachedEntity).Coordinates;
|
var playerPosition = _entities.GetComponent<TransformComponent>(player.AttachedEntity.Value).Coordinates;
|
||||||
var tileDefinitionManager = IoCManager.Resolve<ITileDefinitionManager>();
|
var tileDefinitionManager = IoCManager.Resolve<ITileDefinitionManager>();
|
||||||
|
|
||||||
for (var i = -radius; i <= radius; i++)
|
for (var i = -radius; i <= radius; i++)
|
||||||
|
|||||||
@@ -32,6 +32,7 @@ namespace Content.Server.Inventory.Components
|
|||||||
public class InventoryComponent : SharedInventoryComponent, IExAct
|
public class InventoryComponent : SharedInventoryComponent, IExAct
|
||||||
{
|
{
|
||||||
[Dependency] private readonly IEntitySystemManager _entitySystemManager = default!;
|
[Dependency] private readonly IEntitySystemManager _entitySystemManager = default!;
|
||||||
|
[Dependency] private readonly IEntityManager _entities = default!;
|
||||||
|
|
||||||
[ViewVariables] private readonly Dictionary<Slots, ContainerSlot> _slotContainers = new();
|
[ViewVariables] private readonly Dictionary<Slots, ContainerSlot> _slotContainers = new();
|
||||||
|
|
||||||
@@ -62,7 +63,7 @@ namespace Content.Server.Inventory.Components
|
|||||||
{
|
{
|
||||||
if (TryGetSlotItem(slot, out ItemComponent? item))
|
if (TryGetSlotItem(slot, out ItemComponent? item))
|
||||||
{
|
{
|
||||||
IoCManager.Resolve<IEntityManager>().DeleteEntity(item.Owner);
|
_entities.DeleteEntity(item.Owner);
|
||||||
}
|
}
|
||||||
|
|
||||||
RemoveSlot(slot);
|
RemoveSlot(slot);
|
||||||
@@ -105,7 +106,7 @@ namespace Content.Server.Inventory.Components
|
|||||||
public IEnumerable<T?> LookupItems<T>() where T : Component
|
public IEnumerable<T?> LookupItems<T>() where T : Component
|
||||||
{
|
{
|
||||||
return _slotContainers.Values
|
return _slotContainers.Values
|
||||||
.SelectMany(x => x.ContainedEntities.Select(e => IoCManager.Resolve<IEntityManager>().GetComponentOrNull<T>(e)))
|
.SelectMany(x => x.ContainedEntities.Select(e => _entities.GetComponentOrNull<T>(e)))
|
||||||
.Where(x => x != null);
|
.Where(x => x != null);
|
||||||
}
|
}
|
||||||
|
|
||||||
@@ -117,14 +118,14 @@ namespace Content.Server.Inventory.Components
|
|||||||
}
|
}
|
||||||
|
|
||||||
var containedEntity = _slotContainers[slot].ContainedEntity;
|
var containedEntity = _slotContainers[slot].ContainedEntity;
|
||||||
if ((containedEntity != null ? (!IoCManager.Resolve<IEntityManager>().EntityExists(containedEntity) ? EntityLifeStage.Deleted : IoCManager.Resolve<IEntityManager>().GetComponent<MetaDataComponent>(containedEntity).EntityLifeStage) >= EntityLifeStage.Deleted : null) == true)
|
if (containedEntity != null && _entities.GetComponent<MetaDataComponent>(containedEntity.Value).EntityDeleted)
|
||||||
{
|
{
|
||||||
_slotContainers.Remove(slot);
|
_slotContainers.Remove(slot);
|
||||||
containedEntity = null;
|
containedEntity = null;
|
||||||
Dirty();
|
Dirty();
|
||||||
}
|
}
|
||||||
|
|
||||||
return (containedEntity != null ? IoCManager.Resolve<IEntityManager>().GetComponent<T>(containedEntity) : null);
|
return containedEntity.HasValue ? _entities.GetComponent<T>(containedEntity.Value) : null;
|
||||||
}
|
}
|
||||||
|
|
||||||
public bool TryGetSlotItem<T>(Slots slot, [NotNullWhen(true)] out T? itemComponent) where T : ItemComponent
|
public bool TryGetSlotItem<T>(Slots slot, [NotNullWhen(true)] out T? itemComponent) where T : ItemComponent
|
||||||
@@ -186,7 +187,7 @@ namespace Content.Server.Inventory.Components
|
|||||||
Equip(slot, item, mobCheck, out var _);
|
Equip(slot, item, mobCheck, out var _);
|
||||||
|
|
||||||
public bool Equip(Slots slot, EntityUid entity, bool mobCheck = true) =>
|
public bool Equip(Slots slot, EntityUid entity, bool mobCheck = true) =>
|
||||||
Equip(slot, IoCManager.Resolve<IEntityManager>().GetComponent<ItemComponent>(entity), mobCheck);
|
Equip(slot, _entities.GetComponent<ItemComponent>(entity), mobCheck);
|
||||||
|
|
||||||
/// <summary>
|
/// <summary>
|
||||||
/// Checks whether an item can be put in the specified slot.
|
/// Checks whether an item can be put in the specified slot.
|
||||||
@@ -218,7 +219,7 @@ namespace Content.Server.Inventory.Components
|
|||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
if (IoCManager.Resolve<IEntityManager>().TryGetComponent(Owner, out IInventoryController? controller))
|
if (_entities.TryGetComponent(Owner, out IInventoryController? controller))
|
||||||
{
|
{
|
||||||
pass = controller.CanEquip(slot, item.Owner, pass, out var controllerReason);
|
pass = controller.CanEquip(slot, item.Owner, pass, out var controllerReason);
|
||||||
reason = controllerReason ?? reason;
|
reason = controllerReason ?? reason;
|
||||||
@@ -244,7 +245,7 @@ namespace Content.Server.Inventory.Components
|
|||||||
CanEquip(slot, item, mobCheck, out var _);
|
CanEquip(slot, item, mobCheck, out var _);
|
||||||
|
|
||||||
public bool CanEquip(Slots slot, EntityUid entity, bool mobCheck = true) =>
|
public bool CanEquip(Slots slot, EntityUid entity, bool mobCheck = true) =>
|
||||||
CanEquip(slot, IoCManager.Resolve<IEntityManager>().GetComponent<ItemComponent>(entity), mobCheck);
|
CanEquip(slot, _entities.GetComponent<ItemComponent>(entity), mobCheck);
|
||||||
|
|
||||||
/// <summary>
|
/// <summary>
|
||||||
/// Drops the item in a slot.
|
/// Drops the item in a slot.
|
||||||
@@ -260,9 +261,8 @@ namespace Content.Server.Inventory.Components
|
|||||||
}
|
}
|
||||||
|
|
||||||
var inventorySlot = _slotContainers[slot];
|
var inventorySlot = _slotContainers[slot];
|
||||||
var entity = inventorySlot.ContainedEntity;
|
|
||||||
|
|
||||||
if (entity == null)
|
if (inventorySlot.ContainedEntity is not {Valid: true} entity)
|
||||||
{
|
{
|
||||||
return false;
|
return false;
|
||||||
}
|
}
|
||||||
@@ -273,7 +273,7 @@ namespace Content.Server.Inventory.Components
|
|||||||
}
|
}
|
||||||
|
|
||||||
// TODO: The item should be dropped to the container our owner is in, if any.
|
// TODO: The item should be dropped to the container our owner is in, if any.
|
||||||
IoCManager.Resolve<IEntityManager>().GetComponent<TransformComponent>(entity).AttachParentToContainerOrGrid();
|
_entities.GetComponent<TransformComponent>(entity).AttachParentToContainerOrGrid();
|
||||||
|
|
||||||
_entitySystemManager.GetEntitySystem<InteractionSystem>().UnequippedInteraction(Owner, entity, slot);
|
_entitySystemManager.GetEntitySystem<InteractionSystem>().UnequippedInteraction(Owner, entity, slot);
|
||||||
|
|
||||||
@@ -294,16 +294,15 @@ namespace Content.Server.Inventory.Components
|
|||||||
public void ForceUnequip(Slots slot)
|
public void ForceUnequip(Slots slot)
|
||||||
{
|
{
|
||||||
var inventorySlot = _slotContainers[slot];
|
var inventorySlot = _slotContainers[slot];
|
||||||
var entity = inventorySlot.ContainedEntity;
|
if (inventorySlot.ContainedEntity is not {Valid: true} entity)
|
||||||
if (entity == null)
|
|
||||||
{
|
{
|
||||||
return;
|
return;
|
||||||
}
|
}
|
||||||
|
|
||||||
var item = IoCManager.Resolve<IEntityManager>().GetComponent<ItemComponent>(entity);
|
var item = _entities.GetComponent<ItemComponent>(entity);
|
||||||
inventorySlot.ForceRemove(entity);
|
inventorySlot.ForceRemove(entity);
|
||||||
|
|
||||||
var itemTransform = IoCManager.Resolve<IEntityManager>().GetComponent<TransformComponent>(entity);
|
var itemTransform = _entities.GetComponent<TransformComponent>(entity);
|
||||||
|
|
||||||
itemTransform.AttachParentToContainerOrGrid();
|
itemTransform.AttachParentToContainerOrGrid();
|
||||||
|
|
||||||
@@ -328,7 +327,7 @@ namespace Content.Server.Inventory.Components
|
|||||||
return false;
|
return false;
|
||||||
|
|
||||||
var inventorySlot = _slotContainers[slot];
|
var inventorySlot = _slotContainers[slot];
|
||||||
return inventorySlot.ContainedEntity != null && inventorySlot.CanRemove(inventorySlot.ContainedEntity);
|
return inventorySlot.ContainedEntity != null && inventorySlot.CanRemove(inventorySlot.ContainedEntity.Value);
|
||||||
}
|
}
|
||||||
|
|
||||||
/// <summary>
|
/// <summary>
|
||||||
@@ -404,7 +403,7 @@ namespace Content.Server.Inventory.Components
|
|||||||
if (container is not ContainerSlot slot || !_slotContainers.ContainsValue(slot))
|
if (container is not ContainerSlot slot || !_slotContainers.ContainsValue(slot))
|
||||||
return;
|
return;
|
||||||
|
|
||||||
if (IoCManager.Resolve<IEntityManager>().TryGetComponent(entity, out ItemComponent? itemComp))
|
if (_entities.TryGetComponent(entity, out ItemComponent? itemComp))
|
||||||
{
|
{
|
||||||
itemComp.RemovedFromSlot();
|
itemComp.RemovedFromSlot();
|
||||||
}
|
}
|
||||||
@@ -424,10 +423,10 @@ namespace Content.Server.Inventory.Components
|
|||||||
{
|
{
|
||||||
case ClientInventoryUpdate.Equip:
|
case ClientInventoryUpdate.Equip:
|
||||||
{
|
{
|
||||||
var hands = IoCManager.Resolve<IEntityManager>().GetComponent<HandsComponent>(Owner);
|
var hands = _entities.GetComponent<HandsComponent>(Owner);
|
||||||
var activeHand = hands.ActiveHand;
|
var activeHand = hands.ActiveHand;
|
||||||
var activeItem = hands.GetActiveHand;
|
var activeItem = hands.GetActiveHand;
|
||||||
if (activeHand != null && activeItem != null && IoCManager.Resolve<IEntityManager>().TryGetComponent(activeItem.Owner, out ItemComponent? item))
|
if (activeHand != null && activeItem != null && _entities.TryGetComponent(activeItem.Owner, out ItemComponent? item))
|
||||||
{
|
{
|
||||||
hands.TryDropNoInteraction();
|
hands.TryDropNoInteraction();
|
||||||
if (!Equip(msg.Inventoryslot, item, true, out var reason))
|
if (!Equip(msg.Inventoryslot, item, true, out var reason))
|
||||||
@@ -442,7 +441,7 @@ namespace Content.Server.Inventory.Components
|
|||||||
case ClientInventoryUpdate.Use:
|
case ClientInventoryUpdate.Use:
|
||||||
{
|
{
|
||||||
var interactionSystem = _entitySystemManager.GetEntitySystem<InteractionSystem>();
|
var interactionSystem = _entitySystemManager.GetEntitySystem<InteractionSystem>();
|
||||||
var hands = IoCManager.Resolve<IEntityManager>().GetComponent<HandsComponent>(Owner);
|
var hands = _entities.GetComponent<HandsComponent>(Owner);
|
||||||
var activeHand = hands.GetActiveHand;
|
var activeHand = hands.GetActiveHand;
|
||||||
var itemContainedInSlot = GetSlotItem(msg.Inventoryslot);
|
var itemContainedInSlot = GetSlotItem(msg.Inventoryslot);
|
||||||
if (itemContainedInSlot != null)
|
if (itemContainedInSlot != null)
|
||||||
@@ -462,7 +461,7 @@ namespace Content.Server.Inventory.Components
|
|||||||
}
|
}
|
||||||
case ClientInventoryUpdate.Hover:
|
case ClientInventoryUpdate.Hover:
|
||||||
{
|
{
|
||||||
var hands = IoCManager.Resolve<IEntityManager>().GetComponent<HandsComponent>(Owner);
|
var hands = _entities.GetComponent<HandsComponent>(Owner);
|
||||||
var activeHand = hands.GetActiveHand;
|
var activeHand = hands.GetActiveHand;
|
||||||
if (activeHand != null && GetSlotItem(msg.Inventoryslot) == null)
|
if (activeHand != null && GetSlotItem(msg.Inventoryslot) == null)
|
||||||
{
|
{
|
||||||
@@ -504,7 +503,7 @@ namespace Content.Server.Inventory.Components
|
|||||||
if (!HasSlot(msg.Slot)) // client input sanitization
|
if (!HasSlot(msg.Slot)) // client input sanitization
|
||||||
return;
|
return;
|
||||||
var item = GetSlotItem(msg.Slot);
|
var item = GetSlotItem(msg.Slot);
|
||||||
if (item != null && IoCManager.Resolve<IEntityManager>().TryGetComponent(item.Owner, out ServerStorageComponent? storage))
|
if (item != null && _entities.TryGetComponent(item.Owner, out ServerStorageComponent? storage))
|
||||||
storage.OpenStorageUI(Owner);
|
storage.OpenStorageUI(Owner);
|
||||||
break;
|
break;
|
||||||
}
|
}
|
||||||
@@ -515,9 +514,9 @@ namespace Content.Server.Inventory.Components
|
|||||||
var list = new List<KeyValuePair<Slots, EntityUid>>();
|
var list = new List<KeyValuePair<Slots, EntityUid>>();
|
||||||
foreach (var (slot, container) in _slotContainers)
|
foreach (var (slot, container) in _slotContainers)
|
||||||
{
|
{
|
||||||
if (container != null && container.ContainedEntity != null)
|
if (container is {ContainedEntity: { }})
|
||||||
{
|
{
|
||||||
list.Add(new KeyValuePair<Slots, EntityUid>(slot, container.ContainedEntity));
|
list.Add(new KeyValuePair<Slots, EntityUid>(slot, container.ContainedEntity.Value));
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
@@ -538,7 +537,7 @@ namespace Content.Server.Inventory.Components
|
|||||||
{
|
{
|
||||||
foreach (var entity in slot.ContainedEntities)
|
foreach (var entity in slot.ContainedEntities)
|
||||||
{
|
{
|
||||||
var exActs = IoCManager.Resolve<IEntityManager>().GetComponents<IExAct>(entity).ToList();
|
var exActs = _entities.GetComponents<IExAct>(entity).ToList();
|
||||||
foreach (var exAct in exActs)
|
foreach (var exAct in exActs)
|
||||||
{
|
{
|
||||||
exAct.OnExplosion(eventArgs);
|
exAct.OnExplosion(eventArgs);
|
||||||
@@ -549,7 +548,7 @@ namespace Content.Server.Inventory.Components
|
|||||||
|
|
||||||
public override bool IsEquipped(EntityUid item)
|
public override bool IsEquipped(EntityUid item)
|
||||||
{
|
{
|
||||||
if (item == null) return false;
|
if (item == default) return false;
|
||||||
foreach (var containerSlot in _slotContainers.Values)
|
foreach (var containerSlot in _slotContainers.Values)
|
||||||
{
|
{
|
||||||
// we don't want a recursive check here
|
// we don't want a recursive check here
|
||||||
|
|||||||
@@ -37,6 +37,8 @@ namespace Content.Server.Kitchen.Components
|
|||||||
[ComponentReference(typeof(IActivate))]
|
[ComponentReference(typeof(IActivate))]
|
||||||
public class MicrowaveComponent : SharedMicrowaveComponent, IActivate, IInteractUsing, ISuicideAct, IBreakAct
|
public class MicrowaveComponent : SharedMicrowaveComponent, IActivate, IInteractUsing, ISuicideAct, IBreakAct
|
||||||
{
|
{
|
||||||
|
[Dependency] private readonly IEntityManager _entities = default!;
|
||||||
|
|
||||||
[Dependency] private readonly RecipeManager _recipeManager = default!;
|
[Dependency] private readonly RecipeManager _recipeManager = default!;
|
||||||
|
|
||||||
#region YAMLSERIALIZE
|
#region YAMLSERIALIZE
|
||||||
@@ -66,7 +68,7 @@ namespace Content.Server.Kitchen.Components
|
|||||||
/// </summary>
|
/// </summary>
|
||||||
[ViewVariables] private uint _currentCookTimerTime = 1;
|
[ViewVariables] private uint _currentCookTimerTime = 1;
|
||||||
|
|
||||||
private bool Powered => !IoCManager.Resolve<IEntityManager>().TryGetComponent(Owner, out ApcPowerReceiverComponent? receiver) || receiver.Powered;
|
private bool Powered => !_entities.TryGetComponent(Owner, out ApcPowerReceiverComponent? receiver) || receiver.Powered;
|
||||||
|
|
||||||
private bool HasContents => EntitySystem.Get<SolutionContainerSystem>()
|
private bool HasContents => EntitySystem.Get<SolutionContainerSystem>()
|
||||||
.TryGetSolution(Owner, SolutionName, out var solution) &&
|
.TryGetSolution(Owner, SolutionName, out var solution) &&
|
||||||
@@ -204,7 +206,7 @@ namespace Content.Server.Kitchen.Components
|
|||||||
finalState = MicrowaveVisualState.Broken;
|
finalState = MicrowaveVisualState.Broken;
|
||||||
}
|
}
|
||||||
|
|
||||||
if (IoCManager.Resolve<IEntityManager>().TryGetComponent(Owner, out AppearanceComponent? appearance))
|
if (_entities.TryGetComponent(Owner, out AppearanceComponent? appearance))
|
||||||
{
|
{
|
||||||
appearance.SetData(PowerDeviceVisuals.VisualState, finalState);
|
appearance.SetData(PowerDeviceVisuals.VisualState, finalState);
|
||||||
}
|
}
|
||||||
@@ -218,7 +220,7 @@ namespace Content.Server.Kitchen.Components
|
|||||||
|
|
||||||
void IActivate.Activate(ActivateEventArgs eventArgs)
|
void IActivate.Activate(ActivateEventArgs eventArgs)
|
||||||
{
|
{
|
||||||
if (!IoCManager.Resolve<IEntityManager>().TryGetComponent(eventArgs.User, out ActorComponent? actor) || !Powered)
|
if (!_entities.TryGetComponent(eventArgs.User, out ActorComponent? actor) || !Powered)
|
||||||
{
|
{
|
||||||
return;
|
return;
|
||||||
}
|
}
|
||||||
@@ -241,15 +243,13 @@ namespace Content.Server.Kitchen.Components
|
|||||||
return false;
|
return false;
|
||||||
}
|
}
|
||||||
|
|
||||||
var itemEntity = IoCManager.Resolve<IEntityManager>().GetComponent<HandsComponent>(eventArgs.User).GetActiveHand?.Owner;
|
if (_entities.GetComponent<HandsComponent>(eventArgs.User).GetActiveHand?.Owner is not {Valid: true} itemEntity)
|
||||||
|
|
||||||
if (itemEntity == null)
|
|
||||||
{
|
{
|
||||||
eventArgs.User.PopupMessage(Loc.GetString("microwave-component-interact-using-no-active-hand"));
|
eventArgs.User.PopupMessage(Loc.GetString("microwave-component-interact-using-no-active-hand"));
|
||||||
return false;
|
return false;
|
||||||
}
|
}
|
||||||
|
|
||||||
if (IoCManager.Resolve<IEntityManager>().TryGetComponent<SolutionTransferComponent?>(itemEntity, out var attackPourable))
|
if (_entities.TryGetComponent<SolutionTransferComponent?>(itemEntity, out var attackPourable))
|
||||||
{
|
{
|
||||||
var solutionsSystem = EntitySystem.Get<SolutionContainerSystem>();
|
var solutionsSystem = EntitySystem.Get<SolutionContainerSystem>();
|
||||||
if (!solutionsSystem.TryGetDrainableSolution(itemEntity, out var attackSolution))
|
if (!solutionsSystem.TryGetDrainableSolution(itemEntity, out var attackSolution))
|
||||||
@@ -284,7 +284,7 @@ namespace Content.Server.Kitchen.Components
|
|||||||
return true;
|
return true;
|
||||||
}
|
}
|
||||||
|
|
||||||
if (!IoCManager.Resolve<IEntityManager>().TryGetComponent(itemEntity, typeof(ItemComponent), out var food))
|
if (!_entities.TryGetComponent(itemEntity, typeof(ItemComponent), out var food))
|
||||||
{
|
{
|
||||||
Owner.PopupMessage(eventArgs.User, "microwave-component-interact-using-transfer-fail");
|
Owner.PopupMessage(eventArgs.User, "microwave-component-interact-using-transfer-fail");
|
||||||
return false;
|
return false;
|
||||||
@@ -310,18 +310,19 @@ namespace Content.Server.Kitchen.Components
|
|||||||
var solidsDict = new Dictionary<string, int>();
|
var solidsDict = new Dictionary<string, int>();
|
||||||
foreach (var item in _storage.ContainedEntities)
|
foreach (var item in _storage.ContainedEntities)
|
||||||
{
|
{
|
||||||
if (IoCManager.Resolve<IEntityManager>().GetComponent<MetaDataComponent>(item).EntityPrototype == null)
|
var metaData = _entities.GetComponent<MetaDataComponent>(item);
|
||||||
|
if (metaData.EntityPrototype == null)
|
||||||
{
|
{
|
||||||
continue;
|
continue;
|
||||||
}
|
}
|
||||||
|
|
||||||
if (solidsDict.ContainsKey(IoCManager.Resolve<IEntityManager>().GetComponent<MetaDataComponent>(item).EntityPrototype.ID))
|
if (solidsDict.ContainsKey(metaData.EntityPrototype.ID))
|
||||||
{
|
{
|
||||||
solidsDict[IoCManager.Resolve<IEntityManager>().GetComponent<MetaDataComponent>(item).EntityPrototype.ID]++;
|
solidsDict[metaData.EntityPrototype.ID]++;
|
||||||
}
|
}
|
||||||
else
|
else
|
||||||
{
|
{
|
||||||
solidsDict.Add(IoCManager.Resolve<IEntityManager>().GetComponent<MetaDataComponent>(item).EntityPrototype.ID, 1);
|
solidsDict.Add(metaData.EntityPrototype.ID, 1);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
@@ -364,13 +365,13 @@ namespace Content.Server.Kitchen.Components
|
|||||||
if (recipeToCook != null)
|
if (recipeToCook != null)
|
||||||
{
|
{
|
||||||
SubtractContents(recipeToCook);
|
SubtractContents(recipeToCook);
|
||||||
IoCManager.Resolve<IEntityManager>().SpawnEntity(recipeToCook.Result, IoCManager.Resolve<IEntityManager>().GetComponent<TransformComponent>(Owner).Coordinates);
|
_entities.SpawnEntity(recipeToCook.Result, _entities.GetComponent<TransformComponent>(Owner).Coordinates);
|
||||||
}
|
}
|
||||||
else
|
else
|
||||||
{
|
{
|
||||||
VaporizeReagents();
|
VaporizeReagents();
|
||||||
VaporizeSolids();
|
VaporizeSolids();
|
||||||
IoCManager.Resolve<IEntityManager>().SpawnEntity(_badRecipeName, IoCManager.Resolve<IEntityManager>().GetComponent<TransformComponent>(Owner).Coordinates);
|
_entities.SpawnEntity(_badRecipeName, _entities.GetComponent<TransformComponent>(Owner).Coordinates);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
@@ -409,7 +410,7 @@ namespace Content.Server.Kitchen.Components
|
|||||||
{
|
{
|
||||||
var item = _storage.ContainedEntities.ElementAt(i);
|
var item = _storage.ContainedEntities.ElementAt(i);
|
||||||
_storage.Remove(item);
|
_storage.Remove(item);
|
||||||
IoCManager.Resolve<IEntityManager>().DeleteEntity(item);
|
_entities.DeleteEntity(item);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
@@ -423,9 +424,9 @@ namespace Content.Server.Kitchen.Components
|
|||||||
|
|
||||||
private void EjectSolid(EntityUid entityId)
|
private void EjectSolid(EntityUid entityId)
|
||||||
{
|
{
|
||||||
if (IoCManager.Resolve<IEntityManager>().EntityExists(entityId))
|
if (_entities.EntityExists(entityId))
|
||||||
{
|
{
|
||||||
_storage.Remove(IoCManager.Resolve<IEntityManager>().GetEntity(entityId));
|
_storage.Remove(entityId);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
@@ -449,15 +450,16 @@ namespace Content.Server.Kitchen.Components
|
|||||||
{
|
{
|
||||||
foreach (var item in _storage.ContainedEntities)
|
foreach (var item in _storage.ContainedEntities)
|
||||||
{
|
{
|
||||||
if (IoCManager.Resolve<IEntityManager>().GetComponent<MetaDataComponent>(item).EntityPrototype == null)
|
var metaData = _entities.GetComponent<MetaDataComponent>(item);
|
||||||
|
if (metaData.EntityPrototype == null)
|
||||||
{
|
{
|
||||||
continue;
|
continue;
|
||||||
}
|
}
|
||||||
|
|
||||||
if (IoCManager.Resolve<IEntityManager>().GetComponent<MetaDataComponent>(item).EntityPrototype.ID == recipeSolid.Key)
|
if (metaData.EntityPrototype.ID == recipeSolid.Key)
|
||||||
{
|
{
|
||||||
_storage.Remove(item);
|
_storage.Remove(item);
|
||||||
IoCManager.Resolve<IEntityManager>().DeleteEntity(item);
|
_entities.DeleteEntity(item);
|
||||||
break;
|
break;
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
@@ -515,7 +517,7 @@ namespace Content.Server.Kitchen.Components
|
|||||||
{
|
{
|
||||||
var headCount = 0;
|
var headCount = 0;
|
||||||
|
|
||||||
if (IoCManager.Resolve<IEntityManager>().TryGetComponent<SharedBodyComponent?>(victim, out var body))
|
if (_entities.TryGetComponent<SharedBodyComponent?>(victim, out var body))
|
||||||
{
|
{
|
||||||
var headSlots = body.GetSlotsOfType(BodyPartType.Head);
|
var headSlots = body.GetSlotsOfType(BodyPartType.Head);
|
||||||
|
|
||||||
|
|||||||
@@ -21,6 +21,7 @@ using Robust.Shared.IoC;
|
|||||||
using Robust.Shared.Localization;
|
using Robust.Shared.Localization;
|
||||||
using Robust.Shared.Log;
|
using Robust.Shared.Log;
|
||||||
using Robust.Shared.Player;
|
using Robust.Shared.Player;
|
||||||
|
using Robust.Shared.Utility;
|
||||||
|
|
||||||
namespace Content.Server.Kitchen.EntitySystems
|
namespace Content.Server.Kitchen.EntitySystems
|
||||||
{
|
{
|
||||||
@@ -52,7 +53,7 @@ namespace Content.Server.Kitchen.EntitySystems
|
|||||||
{
|
{
|
||||||
if (args.Handled) return;
|
if (args.Handled) return;
|
||||||
|
|
||||||
if (!IoCManager.Resolve<IEntityManager>().HasComponent<HandsComponent>(args.User))
|
if (!EntityManager.HasComponent<HandsComponent>(args.User))
|
||||||
{
|
{
|
||||||
component.Owner.PopupMessage(args.User,
|
component.Owner.PopupMessage(args.User,
|
||||||
Loc.GetString("reagent-grinder-component-interact-using-no-hands"));
|
Loc.GetString("reagent-grinder-component-interact-using-no-hands"));
|
||||||
@@ -60,7 +61,7 @@ namespace Content.Server.Kitchen.EntitySystems
|
|||||||
return;
|
return;
|
||||||
}
|
}
|
||||||
|
|
||||||
EntityUidheldEnt = args.Used;
|
var heldEnt = args.Used;
|
||||||
|
|
||||||
// First, check if user is trying to insert a beaker.
|
// First, check if user is trying to insert a beaker.
|
||||||
// No promise it will be a beaker right now, but whatever.
|
// No promise it will be a beaker right now, but whatever.
|
||||||
@@ -71,7 +72,7 @@ namespace Content.Server.Kitchen.EntitySystems
|
|||||||
component.HeldBeaker = beaker;
|
component.HeldBeaker = beaker;
|
||||||
EnqueueUiUpdate(component);
|
EnqueueUiUpdate(component);
|
||||||
//We are done, return. Insert the beaker and exit!
|
//We are done, return. Insert the beaker and exit!
|
||||||
if (IoCManager.Resolve<IEntityManager>().TryGetComponent(component.Owner, out AppearanceComponent? appearance))
|
if (EntityManager.TryGetComponent(component.Owner, out AppearanceComponent? appearance))
|
||||||
{
|
{
|
||||||
appearance.SetData(SharedReagentGrinderComponent.ReagentGrinderVisualState.BeakerAttached,
|
appearance.SetData(SharedReagentGrinderComponent.ReagentGrinderVisualState.BeakerAttached,
|
||||||
component.BeakerContainer.ContainedEntity != null);
|
component.BeakerContainer.ContainedEntity != null);
|
||||||
@@ -83,7 +84,7 @@ namespace Content.Server.Kitchen.EntitySystems
|
|||||||
}
|
}
|
||||||
|
|
||||||
//Next, see if the user is trying to insert something they want to be ground/juiced.
|
//Next, see if the user is trying to insert something they want to be ground/juiced.
|
||||||
if (!IoCManager.Resolve<IEntityManager>().TryGetComponent(heldEnt, out ExtractableComponent? juice))
|
if (!EntityManager.TryGetComponent(heldEnt, out ExtractableComponent? juice))
|
||||||
{
|
{
|
||||||
//Entity did NOT pass the whitelist for grind/juice.
|
//Entity did NOT pass the whitelist for grind/juice.
|
||||||
//Wouldn't want the clown grinding up the Captain's ID card now would you?
|
//Wouldn't want the clown grinding up the Captain's ID card now would you?
|
||||||
@@ -111,7 +112,7 @@ namespace Content.Server.Kitchen.EntitySystems
|
|||||||
{
|
{
|
||||||
if (args.Handled) return;
|
if (args.Handled) return;
|
||||||
|
|
||||||
if (!IoCManager.Resolve<IEntityManager>().TryGetComponent(args.User, out ActorComponent? actor))
|
if (!EntityManager.TryGetComponent(args.User, out ActorComponent? actor))
|
||||||
{
|
{
|
||||||
return;
|
return;
|
||||||
}
|
}
|
||||||
@@ -159,18 +160,18 @@ namespace Content.Server.Kitchen.EntitySystems
|
|||||||
switch (message.Message)
|
switch (message.Message)
|
||||||
{
|
{
|
||||||
case SharedReagentGrinderComponent.ReagentGrinderGrindStartMessage msg:
|
case SharedReagentGrinderComponent.ReagentGrinderGrindStartMessage msg:
|
||||||
if (!IoCManager.Resolve<IEntityManager>().TryGetComponent(component.Owner, out ApcPowerReceiverComponent? receiver) ||
|
if (!EntityManager.TryGetComponent(component.Owner, out ApcPowerReceiverComponent? receiver) ||
|
||||||
!receiver.Powered) break;
|
!receiver.Powered) break;
|
||||||
ClickSound(component);
|
ClickSound(component);
|
||||||
DoWork(component, message.Session.AttachedEntity!,
|
DoWork(component, message.Session.AttachedEntity!.Value,
|
||||||
SharedReagentGrinderComponent.GrinderProgram.Grind);
|
SharedReagentGrinderComponent.GrinderProgram.Grind);
|
||||||
break;
|
break;
|
||||||
|
|
||||||
case SharedReagentGrinderComponent.ReagentGrinderJuiceStartMessage msg:
|
case SharedReagentGrinderComponent.ReagentGrinderJuiceStartMessage msg:
|
||||||
if (!IoCManager.Resolve<IEntityManager>().TryGetComponent(component.Owner, out ApcPowerReceiverComponent? receiver2) ||
|
if (!EntityManager.TryGetComponent(component.Owner, out ApcPowerReceiverComponent? receiver2) ||
|
||||||
!receiver2.Powered) break;
|
!receiver2.Powered) break;
|
||||||
ClickSound(component);
|
ClickSound(component);
|
||||||
DoWork(component, message.Session.AttachedEntity!,
|
DoWork(component, message.Session.AttachedEntity!.Value,
|
||||||
SharedReagentGrinderComponent.GrinderProgram.Juice);
|
SharedReagentGrinderComponent.GrinderProgram.Juice);
|
||||||
break;
|
break;
|
||||||
|
|
||||||
@@ -191,10 +192,10 @@ namespace Content.Server.Kitchen.EntitySystems
|
|||||||
break;
|
break;
|
||||||
|
|
||||||
case SharedReagentGrinderComponent.ReagentGrinderEjectChamberContentMessage msg:
|
case SharedReagentGrinderComponent.ReagentGrinderEjectChamberContentMessage msg:
|
||||||
if (component.Chamber.ContainedEntities.TryFirstOrDefault(x => x == msg.EntityID, out var ent))
|
if (component.Chamber.ContainedEntities.TryFirstOrNull(x => x == msg.EntityID, out var ent))
|
||||||
{
|
{
|
||||||
component.Chamber.Remove(ent);
|
component.Chamber.Remove(ent.Value);
|
||||||
SharedEntityExtensions.RandomOffset(ent, 0.4f);
|
SharedEntityExtensions.RandomOffset(ent.Value, 0.4f);
|
||||||
EnqueueUiUpdate(component);
|
EnqueueUiUpdate(component);
|
||||||
ClickSound(component);
|
ClickSound(component);
|
||||||
}
|
}
|
||||||
@@ -224,7 +225,7 @@ namespace Content.Server.Kitchen.EntitySystems
|
|||||||
{
|
{
|
||||||
foreach (var entity in comp.Chamber.ContainedEntities)
|
foreach (var entity in comp.Chamber.ContainedEntities)
|
||||||
{
|
{
|
||||||
if (canJuice || !IoCManager.Resolve<IEntityManager>().TryGetComponent(entity, out ExtractableComponent? component)) continue;
|
if (canJuice || !EntityManager.TryGetComponent(entity, out ExtractableComponent? component)) continue;
|
||||||
|
|
||||||
canJuice = component.JuiceSolution != null;
|
canJuice = component.JuiceSolution != null;
|
||||||
canGrind = component.GrindableSolution != null
|
canGrind = component.GrindableSolution != null
|
||||||
@@ -237,7 +238,7 @@ namespace Content.Server.Kitchen.EntitySystems
|
|||||||
(
|
(
|
||||||
comp.Busy,
|
comp.Busy,
|
||||||
comp.BeakerContainer.ContainedEntity != null,
|
comp.BeakerContainer.ContainedEntity != null,
|
||||||
IoCManager.Resolve<IEntityManager>().TryGetComponent(comp.Owner, out ApcPowerReceiverComponent? receiver) && receiver.Powered,
|
EntityManager.TryGetComponent(comp.Owner, out ApcPowerReceiverComponent? receiver) && receiver.Powered,
|
||||||
canJuice,
|
canJuice,
|
||||||
canGrind,
|
canGrind,
|
||||||
comp.Chamber.ContainedEntities.Select(item => item).ToArray(),
|
comp.Chamber.ContainedEntities.Select(item => item).ToArray(),
|
||||||
@@ -251,25 +252,26 @@ namespace Content.Server.Kitchen.EntitySystems
|
|||||||
/// Tries to eject whatever is in the beaker slot. Puts the item in the user's hands or failing that on top
|
/// Tries to eject whatever is in the beaker slot. Puts the item in the user's hands or failing that on top
|
||||||
/// of the grinder.
|
/// of the grinder.
|
||||||
/// </summary>
|
/// </summary>
|
||||||
private void EjectBeaker(ReagentGrinderComponent component, EntityUid user)
|
private void EjectBeaker(ReagentGrinderComponent component, EntityUid? user)
|
||||||
{
|
{
|
||||||
if (component.BeakerContainer.ContainedEntity == null || component.HeldBeaker == null || component.Busy)
|
if (component.BeakerContainer.ContainedEntity == null || component.HeldBeaker == null || component.Busy)
|
||||||
return;
|
return;
|
||||||
|
|
||||||
var beaker = component.BeakerContainer.ContainedEntity;
|
if (component.BeakerContainer.ContainedEntity is not {Valid: true} beaker)
|
||||||
if (beaker is null)
|
|
||||||
return;
|
return;
|
||||||
|
|
||||||
component.BeakerContainer.Remove(beaker);
|
component.BeakerContainer.Remove(beaker);
|
||||||
|
|
||||||
if (user == null || !IoCManager.Resolve<IEntityManager>().TryGetComponent<HandsComponent?>(user, out var hands) ||
|
if (user == null ||
|
||||||
!IoCManager.Resolve<IEntityManager>().TryGetComponent<ItemComponent?>(beaker, out var item))
|
!EntityManager.TryGetComponent<HandsComponent?>(user.Value, out var hands) ||
|
||||||
|
!EntityManager.TryGetComponent<ItemComponent?>(beaker, out var item))
|
||||||
return;
|
return;
|
||||||
|
|
||||||
hands.PutInHandOrDrop(item);
|
hands.PutInHandOrDrop(item);
|
||||||
|
|
||||||
component.HeldBeaker = null;
|
component.HeldBeaker = null;
|
||||||
EnqueueUiUpdate(component);
|
EnqueueUiUpdate(component);
|
||||||
if (IoCManager.Resolve<IEntityManager>().TryGetComponent(component.Owner, out AppearanceComponent? appearance))
|
if (EntityManager.TryGetComponent(component.Owner, out AppearanceComponent? appearance))
|
||||||
{
|
{
|
||||||
appearance.SetData(SharedReagentGrinderComponent.ReagentGrinderVisualState.BeakerAttached,
|
appearance.SetData(SharedReagentGrinderComponent.ReagentGrinderVisualState.BeakerAttached,
|
||||||
component.BeakerContainer.ContainedEntity != null);
|
component.BeakerContainer.ContainedEntity != null);
|
||||||
@@ -284,7 +286,7 @@ namespace Content.Server.Kitchen.EntitySystems
|
|||||||
SharedReagentGrinderComponent.GrinderProgram program)
|
SharedReagentGrinderComponent.GrinderProgram program)
|
||||||
{
|
{
|
||||||
//Have power, are we busy, chamber has anything to grind, a beaker for the grounds to go?
|
//Have power, are we busy, chamber has anything to grind, a beaker for the grounds to go?
|
||||||
if (!IoCManager.Resolve<IEntityManager>().TryGetComponent(component.Owner, out ApcPowerReceiverComponent? receiver) || !receiver.Powered ||
|
if (!EntityManager.TryGetComponent(component.Owner, out ApcPowerReceiverComponent? receiver) || !receiver.Powered ||
|
||||||
component.Busy || component.Chamber.ContainedEntities.Count <= 0 ||
|
component.Busy || component.Chamber.ContainedEntities.Count <= 0 ||
|
||||||
component.BeakerContainer.ContainedEntity == null || component.HeldBeaker == null)
|
component.BeakerContainer.ContainedEntity == null || component.HeldBeaker == null)
|
||||||
{
|
{
|
||||||
@@ -306,7 +308,7 @@ namespace Content.Server.Kitchen.EntitySystems
|
|||||||
{
|
{
|
||||||
foreach (var item in component.Chamber.ContainedEntities.ToList())
|
foreach (var item in component.Chamber.ContainedEntities.ToList())
|
||||||
{
|
{
|
||||||
if (!IoCManager.Resolve<IEntityManager>().TryGetComponent(item, out ExtractableComponent? extract)
|
if (!EntityManager.TryGetComponent(item, out ExtractableComponent? extract)
|
||||||
|| extract.GrindableSolution == null
|
|| extract.GrindableSolution == null
|
||||||
|| !_solutionsSystem.TryGetSolution(item, extract.GrindableSolution, out var solution)) continue;
|
|| !_solutionsSystem.TryGetSolution(item, extract.GrindableSolution, out var solution)) continue;
|
||||||
|
|
||||||
@@ -315,9 +317,9 @@ namespace Content.Server.Kitchen.EntitySystems
|
|||||||
if (component.HeldBeaker.CurrentVolume + solution.CurrentVolume * juiceEvent.Scalar >
|
if (component.HeldBeaker.CurrentVolume + solution.CurrentVolume * juiceEvent.Scalar >
|
||||||
component.HeldBeaker.MaxVolume) continue;
|
component.HeldBeaker.MaxVolume) continue;
|
||||||
solution.ScaleSolution(juiceEvent.Scalar);
|
solution.ScaleSolution(juiceEvent.Scalar);
|
||||||
_solutionsSystem.TryAddSolution(beakerEntity, component.HeldBeaker, solution);
|
_solutionsSystem.TryAddSolution(beakerEntity.Value, component.HeldBeaker, solution);
|
||||||
_solutionsSystem.RemoveAllSolution(beakerEntity, solution);
|
_solutionsSystem.RemoveAllSolution(beakerEntity.Value, solution);
|
||||||
IoCManager.Resolve<IEntityManager>().DeleteEntity(item);
|
EntityManager.DeleteEntity(item);
|
||||||
}
|
}
|
||||||
|
|
||||||
component.Busy = false;
|
component.Busy = false;
|
||||||
@@ -332,14 +334,14 @@ namespace Content.Server.Kitchen.EntitySystems
|
|||||||
{
|
{
|
||||||
foreach (var item in component.Chamber.ContainedEntities.ToList())
|
foreach (var item in component.Chamber.ContainedEntities.ToList())
|
||||||
{
|
{
|
||||||
if (!IoCManager.Resolve<IEntityManager>().TryGetComponent<ExtractableComponent?>(item, out var juiceMe)
|
if (!EntityManager.TryGetComponent<ExtractableComponent?>(item, out var juiceMe)
|
||||||
|| juiceMe.JuiceSolution == null)
|
|| juiceMe.JuiceSolution == null)
|
||||||
{
|
{
|
||||||
Logger.Warning("Couldn't find a juice solution on entityUid:{0}", item);
|
Logger.Warning("Couldn't find a juice solution on entityUid:{0}", item);
|
||||||
continue;
|
continue;
|
||||||
}
|
}
|
||||||
var juiceEvent = new ExtractableScalingEvent(); // default of scalar is always 1.0
|
var juiceEvent = new ExtractableScalingEvent(); // default of scalar is always 1.0
|
||||||
if (IoCManager.Resolve<IEntityManager>().HasComponent<StackComponent>(item))
|
if (EntityManager.HasComponent<StackComponent>(item))
|
||||||
{
|
{
|
||||||
RaiseLocalEvent(item, juiceEvent);
|
RaiseLocalEvent(item, juiceEvent);
|
||||||
}
|
}
|
||||||
@@ -348,8 +350,8 @@ namespace Content.Server.Kitchen.EntitySystems
|
|||||||
juiceMe.JuiceSolution.TotalVolume * juiceEvent.Scalar >
|
juiceMe.JuiceSolution.TotalVolume * juiceEvent.Scalar >
|
||||||
component.HeldBeaker.MaxVolume) continue;
|
component.HeldBeaker.MaxVolume) continue;
|
||||||
juiceMe.JuiceSolution.ScaleSolution(juiceEvent.Scalar);
|
juiceMe.JuiceSolution.ScaleSolution(juiceEvent.Scalar);
|
||||||
_solutionsSystem.TryAddSolution(beakerEntity, component.HeldBeaker, juiceMe.JuiceSolution);
|
_solutionsSystem.TryAddSolution(beakerEntity.Value, component.HeldBeaker, juiceMe.JuiceSolution);
|
||||||
IoCManager.Resolve<IEntityManager>().DeleteEntity(item);
|
EntityManager.DeleteEntity(item);
|
||||||
}
|
}
|
||||||
|
|
||||||
bui?.SendMessage(new SharedReagentGrinderComponent.ReagentGrinderWorkCompleteMessage());
|
bui?.SendMessage(new SharedReagentGrinderComponent.ReagentGrinderWorkCompleteMessage());
|
||||||
|
|||||||
@@ -34,10 +34,10 @@ namespace Content.Server.Labels
|
|||||||
|
|
||||||
private void AfterInteractOn(EntityUid uid, HandLabelerComponent handLabeler, AfterInteractEvent args)
|
private void AfterInteractOn(EntityUid uid, HandLabelerComponent handLabeler, AfterInteractEvent args)
|
||||||
{
|
{
|
||||||
if (args.Target == null || !handLabeler.Whitelist.IsValid(args.Target))
|
if (args.Target is not {Valid: true} target || !handLabeler.Whitelist.IsValid(target))
|
||||||
return;
|
return;
|
||||||
|
|
||||||
AddLabelTo(uid, handLabeler, args.Target, out string? result);
|
AddLabelTo(uid, handLabeler, target, out string? result);
|
||||||
if (result != null)
|
if (result != null)
|
||||||
handLabeler.Owner.PopupMessage(args.User, result);
|
handLabeler.Owner.PopupMessage(args.User, result);
|
||||||
}
|
}
|
||||||
|
|||||||
@@ -62,7 +62,7 @@ namespace Content.Server.Labels
|
|||||||
|
|
||||||
private void OnExamined(EntityUid uid, PaperLabelComponent comp, ExaminedEvent args)
|
private void OnExamined(EntityUid uid, PaperLabelComponent comp, ExaminedEvent args)
|
||||||
{
|
{
|
||||||
if (comp.LabelSlot.Item == null)
|
if (comp.LabelSlot.Item is not {Valid: true} item)
|
||||||
return;
|
return;
|
||||||
|
|
||||||
if (!args.IsInDetailsRange)
|
if (!args.IsInDetailsRange)
|
||||||
@@ -71,7 +71,7 @@ namespace Content.Server.Labels
|
|||||||
return;
|
return;
|
||||||
}
|
}
|
||||||
|
|
||||||
if (!EntityManager.TryGetComponent(comp.LabelSlot.Item, out PaperComponent paper))
|
if (!EntityManager.TryGetComponent(item, out PaperComponent paper))
|
||||||
// Assuming yaml has the correct entity whitelist, this should not happen.
|
// Assuming yaml has the correct entity whitelist, this should not happen.
|
||||||
return;
|
return;
|
||||||
|
|
||||||
|
|||||||
@@ -154,7 +154,7 @@ namespace Content.Server.Light.EntitySystems
|
|||||||
return false;
|
return false;
|
||||||
|
|
||||||
// try to insert bulb in container
|
// try to insert bulb in container
|
||||||
if (!light.LightBulbContainer.Insert(EntityManager.GetEntity(bulbUid)))
|
if (!light.LightBulbContainer.Insert(bulbUid))
|
||||||
return false;
|
return false;
|
||||||
|
|
||||||
UpdateLight(uid, light);
|
UpdateLight(uid, light);
|
||||||
@@ -172,24 +172,22 @@ namespace Content.Server.Light.EntitySystems
|
|||||||
return null;
|
return null;
|
||||||
|
|
||||||
// check if light has bulb
|
// check if light has bulb
|
||||||
var bulbUid = GetBulb(uid, light);
|
if (GetBulb(uid, light) is not {Valid: true} bulb)
|
||||||
if (bulbUid == null)
|
|
||||||
return null;
|
return null;
|
||||||
|
|
||||||
// try to remove bulb from container
|
// try to remove bulb from container
|
||||||
var bulbbulbUid.Value
|
if (!light.LightBulbContainer.Remove(bulb))
|
||||||
if (!light.LightBulbContainer.Remove(bulbEnt))
|
|
||||||
return null;
|
return null;
|
||||||
|
|
||||||
// try to place bulb in hands
|
// try to place bulb in hands
|
||||||
if (userUid != null)
|
if (userUid != null)
|
||||||
{
|
{
|
||||||
if (EntityManager.TryGetComponent(userUid.Value, out SharedHandsComponent? hands))
|
if (EntityManager.TryGetComponent(userUid.Value, out SharedHandsComponent? hands))
|
||||||
hands.TryPutInActiveHandOrAny(bulbEnt);
|
hands.TryPutInActiveHandOrAny(bulb);
|
||||||
}
|
}
|
||||||
|
|
||||||
UpdateLight(uid, light);
|
UpdateLight(uid, light);
|
||||||
return bulbUid;
|
return bulb;
|
||||||
}
|
}
|
||||||
|
|
||||||
/// <summary>
|
/// <summary>
|
||||||
|
|||||||
@@ -5,7 +5,7 @@ namespace Content.Server.MachineLinking.Events
|
|||||||
{
|
{
|
||||||
public class LinkAttemptEvent : CancellableEntityEventArgs
|
public class LinkAttemptEvent : CancellableEntityEventArgs
|
||||||
{
|
{
|
||||||
public readonly EntityUid Attemptee,
|
public readonly EntityUid Attemptee;
|
||||||
public readonly SignalTransmitterComponent TransmitterComponent;
|
public readonly SignalTransmitterComponent TransmitterComponent;
|
||||||
public readonly string TransmitterPort;
|
public readonly string TransmitterPort;
|
||||||
public readonly SignalReceiverComponent ReceiverComponent;
|
public readonly SignalReceiverComponent ReceiverComponent;
|
||||||
|
|||||||
@@ -13,7 +13,6 @@ using Content.Shared.MachineLinking;
|
|||||||
using Content.Shared.Popups;
|
using Content.Shared.Popups;
|
||||||
using Robust.Server.GameObjects;
|
using Robust.Server.GameObjects;
|
||||||
using Robust.Shared.GameObjects;
|
using Robust.Shared.GameObjects;
|
||||||
using Robust.Shared.IoC;
|
|
||||||
using Robust.Shared.Localization;
|
using Robust.Shared.Localization;
|
||||||
using Robust.Shared.Utility;
|
using Robust.Shared.Utility;
|
||||||
|
|
||||||
@@ -81,8 +80,8 @@ namespace Content.Server.MachineLinking.System
|
|||||||
{
|
{
|
||||||
if (args.Handled) return;
|
if (args.Handled) return;
|
||||||
|
|
||||||
if (!IoCManager.Resolve<IEntityManager>().TryGetComponent<SignalLinkerComponent?>(args.Used, out var linker) || !linker.Port.HasValue ||
|
if (!EntityManager.TryGetComponent<SignalLinkerComponent?>(args.Used, out var linker) || !linker.Port.HasValue ||
|
||||||
!IoCManager.Resolve<IEntityManager>().TryGetComponent(args.User, out ActorComponent? actor) ||
|
!EntityManager.TryGetComponent(args.User, out ActorComponent? actor) ||
|
||||||
!linker.Port.Value.transmitter.Outputs.TryGetPort(linker.Port.Value.port, out var port))
|
!linker.Port.Value.transmitter.Outputs.TryGetPort(linker.Port.Value.port, out var port))
|
||||||
{
|
{
|
||||||
return;
|
return;
|
||||||
@@ -121,15 +120,15 @@ namespace Content.Server.MachineLinking.System
|
|||||||
{
|
{
|
||||||
case SignalPortSelected portSelected:
|
case SignalPortSelected portSelected:
|
||||||
if (msg.Session.AttachedEntity == null ||
|
if (msg.Session.AttachedEntity == null ||
|
||||||
!IoCManager.Resolve<IEntityManager>().TryGetComponent(msg.Session.AttachedEntity, out HandsComponent? hands) ||
|
!EntityManager.TryGetComponent(msg.Session.AttachedEntity.Value, out HandsComponent? hands) ||
|
||||||
!hands.TryGetActiveHeldEntity(out var heldEntity) ||
|
!hands.TryGetActiveHeldEntity(out var heldEntity) ||
|
||||||
!IoCManager.Resolve<IEntityManager>().TryGetComponent(heldEntity, out SignalLinkerComponent? signalLinkerComponent) ||
|
!EntityManager.TryGetComponent(heldEntity, out SignalLinkerComponent? signalLinkerComponent) ||
|
||||||
!_interaction.InRangeUnobstructed(msg.Session.AttachedEntity, component.Owner, ignoreInsideBlocker: true) ||
|
!_interaction.InRangeUnobstructed(msg.Session.AttachedEntity.Value, component.Owner, ignoreInsideBlocker: true) ||
|
||||||
!signalLinkerComponent.Port.HasValue ||
|
!signalLinkerComponent.Port.HasValue ||
|
||||||
!signalLinkerComponent.Port.Value.transmitter.Outputs.ContainsPort(signalLinkerComponent.Port
|
!signalLinkerComponent.Port.Value.transmitter.Outputs.ContainsPort(signalLinkerComponent.Port
|
||||||
.Value.port) || !component.Inputs.ContainsPort(portSelected.Port))
|
.Value.port) || !component.Inputs.ContainsPort(portSelected.Port))
|
||||||
return;
|
return;
|
||||||
LinkerInteraction(msg.Session.AttachedEntity, signalLinkerComponent.Port.Value.transmitter,
|
LinkerInteraction(msg.Session.AttachedEntity.Value, signalLinkerComponent.Port.Value.transmitter,
|
||||||
signalLinkerComponent.Port.Value.port, component, portSelected.Port);
|
signalLinkerComponent.Port.Value.port, component, portSelected.Port);
|
||||||
break;
|
break;
|
||||||
}
|
}
|
||||||
@@ -161,12 +160,12 @@ namespace Content.Server.MachineLinking.System
|
|||||||
{
|
{
|
||||||
case SignalPortSelected portSelected:
|
case SignalPortSelected portSelected:
|
||||||
if (msg.Session.AttachedEntity == null ||
|
if (msg.Session.AttachedEntity == null ||
|
||||||
!IoCManager.Resolve<IEntityManager>().TryGetComponent(msg.Session.AttachedEntity, out HandsComponent? hands) ||
|
!EntityManager.TryGetComponent(msg.Session.AttachedEntity.Value, out HandsComponent? hands) ||
|
||||||
!hands.TryGetActiveHeldEntity(out var heldEntity) ||
|
!hands.TryGetActiveHeldEntity(out var heldEntity) ||
|
||||||
!IoCManager.Resolve<IEntityManager>().TryGetComponent(heldEntity, out SignalLinkerComponent? signalLinkerComponent) ||
|
!EntityManager.TryGetComponent(heldEntity, out SignalLinkerComponent? signalLinkerComponent) ||
|
||||||
!_interaction.InRangeUnobstructed(msg.Session.AttachedEntity, component.Owner, ignoreInsideBlocker: true))
|
!_interaction.InRangeUnobstructed(msg.Session.AttachedEntity.Value, component.Owner, ignoreInsideBlocker: true))
|
||||||
return;
|
return;
|
||||||
LinkerSaveInteraction(msg.Session.AttachedEntity, signalLinkerComponent, component,
|
LinkerSaveInteraction(msg.Session.AttachedEntity.Value, signalLinkerComponent, component,
|
||||||
portSelected.Port);
|
portSelected.Port);
|
||||||
break;
|
break;
|
||||||
}
|
}
|
||||||
@@ -177,8 +176,8 @@ namespace Content.Server.MachineLinking.System
|
|||||||
{
|
{
|
||||||
if (args.Handled) return;
|
if (args.Handled) return;
|
||||||
|
|
||||||
if (!IoCManager.Resolve<IEntityManager>().TryGetComponent<SignalLinkerComponent?>(args.Used, out var linker) ||
|
if (!EntityManager.TryGetComponent<SignalLinkerComponent?>(args.Used, out var linker) ||
|
||||||
!IoCManager.Resolve<IEntityManager>().TryGetComponent(args.User, out ActorComponent? actor))
|
!EntityManager.TryGetComponent(args.User, out ActorComponent? actor))
|
||||||
{
|
{
|
||||||
return;
|
return;
|
||||||
}
|
}
|
||||||
@@ -277,15 +276,15 @@ namespace Content.Server.MachineLinking.System
|
|||||||
private bool IsInRange(SignalTransmitterComponent transmitterComponent,
|
private bool IsInRange(SignalTransmitterComponent transmitterComponent,
|
||||||
SignalReceiverComponent receiverComponent)
|
SignalReceiverComponent receiverComponent)
|
||||||
{
|
{
|
||||||
if (IoCManager.Resolve<IEntityManager>().TryGetComponent<ApcPowerReceiverComponent?>(transmitterComponent.Owner, out var transmitterPowerReceiverComponent) &&
|
if (EntityManager.TryGetComponent<ApcPowerReceiverComponent?>(transmitterComponent.Owner, out var transmitterPowerReceiverComponent) &&
|
||||||
IoCManager.Resolve<IEntityManager>().TryGetComponent<ApcPowerReceiverComponent?>(receiverComponent.Owner, out var receiverPowerReceiverComponent)
|
EntityManager.TryGetComponent<ApcPowerReceiverComponent?>(receiverComponent.Owner, out var receiverPowerReceiverComponent)
|
||||||
) //&& todo are they on the same powernet?
|
) //&& todo are they on the same powernet?
|
||||||
{
|
{
|
||||||
return true;
|
return true;
|
||||||
}
|
}
|
||||||
|
|
||||||
return IoCManager.Resolve<IEntityManager>().GetComponent<TransformComponent>(transmitterComponent.Owner).MapPosition.InRange(
|
return EntityManager.GetComponent<TransformComponent>(transmitterComponent.Owner).MapPosition.InRange(
|
||||||
IoCManager.Resolve<IEntityManager>().GetComponent<TransformComponent>(receiverComponent.Owner).MapPosition, 30f);
|
EntityManager.GetComponent<TransformComponent>(receiverComponent.Owner).MapPosition, 30f);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|||||||
@@ -19,7 +19,7 @@ namespace Content.Server.MachineLinking.System
|
|||||||
|
|
||||||
private void OnSignalReceived(EntityUid uid, TriggerOnSignalReceivedComponent component, SignalReceivedEvent args)
|
private void OnSignalReceived(EntityUid uid, TriggerOnSignalReceivedComponent component, SignalReceivedEvent args)
|
||||||
{
|
{
|
||||||
_trigger.Trigger(uid)
|
_trigger.Trigger(uid);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|||||||
@@ -2,7 +2,6 @@ using System.Threading.Tasks;
|
|||||||
using Content.Server.Administration.Logs;
|
using Content.Server.Administration.Logs;
|
||||||
using Content.Server.Stack;
|
using Content.Server.Stack;
|
||||||
using Content.Shared.ActionBlocker;
|
using Content.Shared.ActionBlocker;
|
||||||
using Content.Shared.Administration.Logs;
|
|
||||||
using Content.Shared.Damage;
|
using Content.Shared.Damage;
|
||||||
using Content.Shared.Damage.Prototypes;
|
using Content.Shared.Damage.Prototypes;
|
||||||
using Content.Shared.Database;
|
using Content.Shared.Database;
|
||||||
@@ -41,7 +40,7 @@ namespace Content.Server.Medical.Components
|
|||||||
return false;
|
return false;
|
||||||
}
|
}
|
||||||
|
|
||||||
if (!IoCManager.Resolve<IEntityManager>().TryGetComponent(eventArgs.Target, out DamageableComponent? targetDamage))
|
if (!IoCManager.Resolve<IEntityManager>().TryGetComponent(eventArgs.Target.Value, out DamageableComponent? targetDamage))
|
||||||
{
|
{
|
||||||
return true;
|
return true;
|
||||||
}
|
}
|
||||||
@@ -66,7 +65,7 @@ namespace Content.Server.Medical.Components
|
|||||||
return true;
|
return true;
|
||||||
}
|
}
|
||||||
|
|
||||||
var healed = EntitySystem.Get<DamageableSystem>().TryChangeDamage(eventArgs.Target, Damage, true);
|
var healed = EntitySystem.Get<DamageableSystem>().TryChangeDamage(eventArgs.Target.Value, Damage, true);
|
||||||
|
|
||||||
if (healed == null)
|
if (healed == null)
|
||||||
return true;
|
return true;
|
||||||
|
|||||||
@@ -79,7 +79,7 @@ namespace Content.Server.Medical.Components
|
|||||||
return EmptyUIState;
|
return EmptyUIState;
|
||||||
}
|
}
|
||||||
|
|
||||||
if (!IoCManager.Resolve<IEntityManager>().TryGetComponent(body, out DamageableComponent? damageable))
|
if (!IoCManager.Resolve<IEntityManager>().TryGetComponent(body.Value, out DamageableComponent? damageable))
|
||||||
{
|
{
|
||||||
return EmptyUIState;
|
return EmptyUIState;
|
||||||
}
|
}
|
||||||
@@ -90,7 +90,7 @@ namespace Content.Server.Medical.Components
|
|||||||
}
|
}
|
||||||
|
|
||||||
var cloningSystem = EntitySystem.Get<CloningSystem>();
|
var cloningSystem = EntitySystem.Get<CloningSystem>();
|
||||||
var scanned = IoCManager.Resolve<IEntityManager>().TryGetComponent(_bodyContainer.ContainedEntity, out MindComponent? mindComponent) &&
|
var scanned = IoCManager.Resolve<IEntityManager>().TryGetComponent(_bodyContainer.ContainedEntity.Value, out MindComponent? mindComponent) &&
|
||||||
mindComponent.Mind != null &&
|
mindComponent.Mind != null &&
|
||||||
cloningSystem.HasDnaScan(mindComponent.Mind);
|
cloningSystem.HasDnaScan(mindComponent.Mind);
|
||||||
|
|
||||||
@@ -136,7 +136,7 @@ namespace Content.Server.Medical.Components
|
|||||||
if (body == null)
|
if (body == null)
|
||||||
return MedicalScannerStatus.Open;
|
return MedicalScannerStatus.Open;
|
||||||
|
|
||||||
var state = IoCManager.Resolve<IEntityManager>().GetComponentOrNull<MobStateComponent>(body);
|
var state = IoCManager.Resolve<IEntityManager>().GetComponentOrNull<MobStateComponent>(body.Value);
|
||||||
|
|
||||||
return state == null ? MedicalScannerStatus.Open : GetStatusFromDamageState(state);
|
return state == null ? MedicalScannerStatus.Open : GetStatusFromDamageState(state);
|
||||||
}
|
}
|
||||||
@@ -174,12 +174,11 @@ namespace Content.Server.Medical.Components
|
|||||||
|
|
||||||
public void EjectBody()
|
public void EjectBody()
|
||||||
{
|
{
|
||||||
var containedEntity = _bodyContainer.ContainedEntity;
|
if (_bodyContainer.ContainedEntity is not {Valid: true} contained) return;
|
||||||
if (containedEntity == null) return;
|
_bodyContainer.Remove(contained);
|
||||||
_bodyContainer.Remove(containedEntity);
|
|
||||||
UpdateUserInterface();
|
UpdateUserInterface();
|
||||||
UpdateAppearance();
|
UpdateAppearance();
|
||||||
EntitySystem.Get<ClimbSystem>().ForciblySetClimbing(containedEntity);
|
EntitySystem.Get<ClimbSystem>().ForciblySetClimbing(contained);
|
||||||
}
|
}
|
||||||
|
|
||||||
public void Update(float frameTime)
|
public void Update(float frameTime)
|
||||||
@@ -199,7 +198,7 @@ namespace Content.Server.Medical.Components
|
|||||||
{
|
{
|
||||||
var cloningSystem = EntitySystem.Get<CloningSystem>();
|
var cloningSystem = EntitySystem.Get<CloningSystem>();
|
||||||
|
|
||||||
if (!IoCManager.Resolve<IEntityManager>().TryGetComponent(_bodyContainer.ContainedEntity, out MindComponent? mindComp) || mindComp.Mind == null)
|
if (!IoCManager.Resolve<IEntityManager>().TryGetComponent(_bodyContainer.ContainedEntity.Value, out MindComponent? mindComp) || mindComp.Mind == null)
|
||||||
{
|
{
|
||||||
obj.Session.AttachedEntity?.PopupMessageCursor(Loc.GetString("medical-scanner-component-msg-no-soul"));
|
obj.Session.AttachedEntity?.PopupMessageCursor(Loc.GetString("medical-scanner-component-msg-no-soul"));
|
||||||
break;
|
break;
|
||||||
|
|||||||
@@ -67,7 +67,7 @@ namespace Content.Server.Mind
|
|||||||
[ViewVariables]
|
[ViewVariables]
|
||||||
public EntityUid VisitingEntity { get; private set; }
|
public EntityUid VisitingEntity { get; private set; }
|
||||||
|
|
||||||
[ViewVariables] public EntityUid CurrentEntity => VisitingEntity.IsValid() ? VisitingEntity : OwnedEntity;
|
[ViewVariables] public EntityUid? CurrentEntity => VisitingEntity.IsValid() ? VisitingEntity : OwnedEntity;
|
||||||
|
|
||||||
[ViewVariables(VVAccess.ReadWrite)]
|
[ViewVariables(VVAccess.ReadWrite)]
|
||||||
public string? CharacterName { get; set; }
|
public string? CharacterName { get; set; }
|
||||||
@@ -90,7 +90,7 @@ namespace Content.Server.Mind
|
|||||||
/// Can be null.
|
/// Can be null.
|
||||||
/// </summary>
|
/// </summary>
|
||||||
[ViewVariables]
|
[ViewVariables]
|
||||||
public EntityUid OwnedEntity => OwnedComponent?.Owner ?? default;
|
public EntityUid? OwnedEntity => OwnedComponent?.Owner;
|
||||||
|
|
||||||
/// <summary>
|
/// <summary>
|
||||||
/// An enumerable over all the roles this mind has.
|
/// An enumerable over all the roles this mind has.
|
||||||
@@ -155,7 +155,7 @@ namespace Content.Server.Mind
|
|||||||
// This can be null if they're deleted (spike / brain nom)
|
// This can be null if they're deleted (spike / brain nom)
|
||||||
if (OwnedEntity == default)
|
if (OwnedEntity == default)
|
||||||
return true;
|
return true;
|
||||||
var targetMobState = IoCManager.Resolve<IEntityManager>().GetComponentOrNull<MobStateComponent>(OwnedEntity);
|
var targetMobState = IoCManager.Resolve<IEntityManager>().GetComponentOrNull<MobStateComponent>(OwnedEntity.Value);
|
||||||
// This can be null if it's a brain (this happens very often)
|
// This can be null if it's a brain (this happens very often)
|
||||||
// Brains are the result of gibbing so should definitely count as dead
|
// Brains are the result of gibbing so should definitely count as dead
|
||||||
if (targetMobState == null)
|
if (targetMobState == null)
|
||||||
@@ -184,7 +184,10 @@ namespace Content.Server.Mind
|
|||||||
role.Greet();
|
role.Greet();
|
||||||
|
|
||||||
var message = new RoleAddedEvent(role);
|
var message = new RoleAddedEvent(role);
|
||||||
IoCManager.Resolve<IEntityManager>().EventBus.RaiseLocalEvent(OwnedEntity, message);
|
if (OwnedEntity != default)
|
||||||
|
{
|
||||||
|
IoCManager.Resolve<IEntityManager>().EventBus.RaiseLocalEvent(OwnedEntity.Value, message);
|
||||||
|
}
|
||||||
|
|
||||||
return role;
|
return role;
|
||||||
}
|
}
|
||||||
@@ -206,7 +209,11 @@ namespace Content.Server.Mind
|
|||||||
_roles.Remove(role);
|
_roles.Remove(role);
|
||||||
|
|
||||||
var message = new RoleRemovedEvent(role);
|
var message = new RoleRemovedEvent(role);
|
||||||
IoCManager.Resolve<IEntityManager>().EventBus.RaiseLocalEvent(OwnedEntity, message);
|
|
||||||
|
if (OwnedEntity != default)
|
||||||
|
{
|
||||||
|
IoCManager.Resolve<IEntityManager>().EventBus.RaiseLocalEvent(OwnedEntity.Value, message);
|
||||||
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
public bool HasRole<T>() where T : Role
|
public bool HasRole<T>() where T : Role
|
||||||
|
|||||||
@@ -32,6 +32,8 @@ namespace Content.Server.Morgue.Components
|
|||||||
public class CrematoriumEntityStorageComponent : MorgueEntityStorageComponent, IExamine, ISuicideAct
|
public class CrematoriumEntityStorageComponent : MorgueEntityStorageComponent, IExamine, ISuicideAct
|
||||||
#pragma warning restore 618
|
#pragma warning restore 618
|
||||||
{
|
{
|
||||||
|
[Dependency] private readonly IEntityManager _entities = default!;
|
||||||
|
|
||||||
public override string Name => "CrematoriumEntityStorage";
|
public override string Name => "CrematoriumEntityStorage";
|
||||||
|
|
||||||
[DataField("cremateStartSound")] private SoundSpecifier _cremateStartSound = new SoundPathSpecifier("/Audio/Items/lighter1.ogg");
|
[DataField("cremateStartSound")] private SoundSpecifier _cremateStartSound = new SoundPathSpecifier("/Audio/Items/lighter1.ogg");
|
||||||
@@ -104,7 +106,7 @@ namespace Content.Server.Morgue.Components
|
|||||||
_cremateCancelToken = new CancellationTokenSource();
|
_cremateCancelToken = new CancellationTokenSource();
|
||||||
Owner.SpawnTimer(_burnMilis, () =>
|
Owner.SpawnTimer(_burnMilis, () =>
|
||||||
{
|
{
|
||||||
if ((!IoCManager.Resolve<IEntityManager>().EntityExists(Owner) ? EntityLifeStage.Deleted : IoCManager.Resolve<IEntityManager>().GetComponent<MetaDataComponent>(Owner).EntityLifeStage) >= EntityLifeStage.Deleted)
|
if ((!_entities.EntityExists(Owner) ? EntityLifeStage.Deleted : _entities.GetComponent<MetaDataComponent>(Owner).EntityLifeStage) >= EntityLifeStage.Deleted)
|
||||||
return;
|
return;
|
||||||
|
|
||||||
Appearance?.SetData(CrematoriumVisuals.Burning, false);
|
Appearance?.SetData(CrematoriumVisuals.Burning, false);
|
||||||
@@ -116,10 +118,10 @@ namespace Content.Server.Morgue.Components
|
|||||||
{
|
{
|
||||||
var item = Contents.ContainedEntities[i];
|
var item = Contents.ContainedEntities[i];
|
||||||
Contents.Remove(item);
|
Contents.Remove(item);
|
||||||
IoCManager.Resolve<IEntityManager>().DeleteEntity(item);
|
_entities.DeleteEntity(item);
|
||||||
}
|
}
|
||||||
|
|
||||||
var ash = IoCManager.Resolve<IEntityManager>().SpawnEntity("Ash", IoCManager.Resolve<IEntityManager>().GetComponent<TransformComponent>(Owner).Coordinates);
|
var ash = _entities.SpawnEntity("Ash", _entities.GetComponent<TransformComponent>(Owner).Coordinates);
|
||||||
Contents.Insert(ash);
|
Contents.Insert(ash);
|
||||||
}
|
}
|
||||||
|
|
||||||
@@ -132,13 +134,13 @@ namespace Content.Server.Morgue.Components
|
|||||||
|
|
||||||
SuicideKind ISuicideAct.Suicide(EntityUid victim, IChatManager chat)
|
SuicideKind ISuicideAct.Suicide(EntityUid victim, IChatManager chat)
|
||||||
{
|
{
|
||||||
if (IoCManager.Resolve<IEntityManager>().TryGetComponent(victim, out ActorComponent? actor) && actor.PlayerSession.ContentData()?.Mind is {} mind)
|
if (_entities.TryGetComponent(victim, out ActorComponent? actor) && actor.PlayerSession.ContentData()?.Mind is {} mind)
|
||||||
{
|
{
|
||||||
EntitySystem.Get<GameTicker>().OnGhostAttempt(mind, false);
|
EntitySystem.Get<GameTicker>().OnGhostAttempt(mind, false);
|
||||||
|
|
||||||
if (mind.OwnedEntity.Valid)
|
if (mind.OwnedEntity is {Valid: true} entity)
|
||||||
{
|
{
|
||||||
mind.OwnedEntity.PopupMessage(Loc.GetString("crematorium-entity-storage-component-suicide-message"));
|
entity.PopupMessage(Loc.GetString("crematorium-entity-storage-component-suicide-message"));
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
@@ -151,7 +153,7 @@ namespace Content.Server.Morgue.Components
|
|||||||
}
|
}
|
||||||
else
|
else
|
||||||
{
|
{
|
||||||
IoCManager.Resolve<IEntityManager>().DeleteEntity(victim);
|
_entities.DeleteEntity(victim);
|
||||||
}
|
}
|
||||||
|
|
||||||
Cremate();
|
Cremate();
|
||||||
|
|||||||
@@ -12,6 +12,8 @@ namespace Content.Server.Nutrition
|
|||||||
[AdminCommand(AdminFlags.Debug)]
|
[AdminCommand(AdminFlags.Debug)]
|
||||||
public class Hungry : IConsoleCommand
|
public class Hungry : IConsoleCommand
|
||||||
{
|
{
|
||||||
|
[Dependency] private readonly IEntityManager _entities = default!;
|
||||||
|
|
||||||
public string Command => "hungry";
|
public string Command => "hungry";
|
||||||
public string Description => "Makes you hungry.";
|
public string Description => "Makes you hungry.";
|
||||||
public string Help => $"{Command}";
|
public string Help => $"{Command}";
|
||||||
@@ -25,13 +27,13 @@ namespace Content.Server.Nutrition
|
|||||||
return;
|
return;
|
||||||
}
|
}
|
||||||
|
|
||||||
if (player.AttachedEntity == null)
|
if (player.AttachedEntity is not {Valid: true} playerEntity)
|
||||||
{
|
{
|
||||||
shell.WriteLine("You cannot use this command without an entity.");
|
shell.WriteLine("You cannot use this command without an entity.");
|
||||||
return;
|
return;
|
||||||
}
|
}
|
||||||
|
|
||||||
if (!IoCManager.Resolve<IEntityManager>().TryGetComponent(player.AttachedEntity, out HungerComponent? hunger))
|
if (!_entities.TryGetComponent(playerEntity, out HungerComponent? hunger))
|
||||||
{
|
{
|
||||||
shell.WriteLine($"Your entity does not have a {nameof(HungerComponent)} component.");
|
shell.WriteLine($"Your entity does not have a {nameof(HungerComponent)} component.");
|
||||||
return;
|
return;
|
||||||
|
|||||||
@@ -22,8 +22,8 @@ namespace Content.Server.Objectives.Conditions
|
|||||||
|
|
||||||
if (Target.CharacterName != null)
|
if (Target.CharacterName != null)
|
||||||
targetName = Target.CharacterName;
|
targetName = Target.CharacterName;
|
||||||
else if (Target.OwnedEntity != null)
|
else if (Target.OwnedEntity is {Valid: true} owned)
|
||||||
targetName = IoCManager.Resolve<IEntityManager>().GetComponent<MetaDataComponent>(Target.OwnedEntity).EntityName;
|
targetName = IoCManager.Resolve<IEntityManager>().GetComponent<MetaDataComponent>(owned).EntityName;
|
||||||
|
|
||||||
return Loc.GetString("objective-condition-kill-person-title", ("targetName", targetName));
|
return Loc.GetString("objective-condition-kill-person-title", ("targetName", targetName));
|
||||||
}
|
}
|
||||||
|
|||||||
@@ -57,8 +57,8 @@ namespace Content.Server.Objectives.Conditions
|
|||||||
{
|
{
|
||||||
get
|
get
|
||||||
{
|
{
|
||||||
if (_mind?.OwnedEntity == null) return 0f;
|
if (_mind?.OwnedEntity is not {Valid: true} owned) return 0f;
|
||||||
if (!IoCManager.Resolve<IEntityManager>().TryGetComponent<ContainerManagerComponent?>(_mind.OwnedEntity, out var containerManagerComponent)) return 0f;
|
if (!IoCManager.Resolve<IEntityManager>().TryGetComponent<ContainerManagerComponent?>(owned, out var containerManagerComponent)) return 0f;
|
||||||
|
|
||||||
float count = containerManagerComponent.CountPrototypeOccurencesRecursive(_prototypeId);
|
float count = containerManagerComponent.CountPrototypeOccurencesRecursive(_prototypeId);
|
||||||
return count/_amount;
|
return count/_amount;
|
||||||
|
|||||||
@@ -145,7 +145,7 @@ namespace Content.Server.PDA
|
|||||||
private void OnUIMessage(PDAComponent pda, ServerBoundUserInterfaceMessage msg)
|
private void OnUIMessage(PDAComponent pda, ServerBoundUserInterfaceMessage msg)
|
||||||
{
|
{
|
||||||
// cast EntityUid? to EntityUid
|
// cast EntityUid? to EntityUid
|
||||||
if (msg.Session.AttachedEntity is not EntityUid playerUid)
|
if (msg.Session.AttachedEntity is not { } playerUid)
|
||||||
return;
|
return;
|
||||||
|
|
||||||
switch (msg.Message)
|
switch (msg.Message)
|
||||||
|
|||||||
@@ -152,8 +152,8 @@ namespace Content.Server.ParticleAccelerator.Components
|
|||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
if (!obj.Session.AttachedEntity.Valid ||
|
if (obj.Session.AttachedEntity is not {Valid: true} attached ||
|
||||||
!EntitySystem.Get<ActionBlockerSystem>().CanInteract(obj.Session.AttachedEntity))
|
!EntitySystem.Get<ActionBlockerSystem>().CanInteract(attached))
|
||||||
{
|
{
|
||||||
return;
|
return;
|
||||||
}
|
}
|
||||||
|
|||||||
@@ -2,11 +2,9 @@
|
|||||||
using System.Collections.Generic;
|
using System.Collections.Generic;
|
||||||
using Content.Shared.Pulling;
|
using Content.Shared.Pulling;
|
||||||
using Robust.Shared.GameObjects;
|
using Robust.Shared.GameObjects;
|
||||||
using Robust.Shared.IoC;
|
using Robust.Shared.Maths;
|
||||||
using Robust.Shared.Physics;
|
using Robust.Shared.Physics;
|
||||||
using Robust.Shared.Physics.Controllers;
|
using Robust.Shared.Physics.Controllers;
|
||||||
using Robust.Shared.Maths;
|
|
||||||
using Robust.Shared.Utility;
|
|
||||||
|
|
||||||
namespace Content.Server.Physics.Controllers
|
namespace Content.Server.Physics.Controllers
|
||||||
{
|
{
|
||||||
@@ -66,32 +64,31 @@ namespace Content.Server.Physics.Controllers
|
|||||||
continue;
|
continue;
|
||||||
}
|
}
|
||||||
|
|
||||||
var puller = pullable.Puller;
|
if (pullable.Puller is not {Valid: true} puller)
|
||||||
if (puller == null)
|
|
||||||
{
|
{
|
||||||
continue;
|
continue;
|
||||||
}
|
}
|
||||||
|
|
||||||
// Now that's over with...
|
// Now that's over with...
|
||||||
|
|
||||||
var pullerPosition = IoCManager.Resolve<IEntityManager>().GetComponent<TransformComponent>(puller).MapPosition;
|
var pullerPosition = EntityManager.GetComponent<TransformComponent>(puller).MapPosition;
|
||||||
var movingTo = pullable.MovingTo.Value.ToMap(IoCManager.Resolve<IEntityManager>());
|
var movingTo = pullable.MovingTo.Value.ToMap(EntityManager);
|
||||||
if (movingTo.MapId != pullerPosition.MapId)
|
if (movingTo.MapId != pullerPosition.MapId)
|
||||||
{
|
{
|
||||||
_pullableSystem.StopMoveTo(pullable);
|
_pullableSystem.StopMoveTo(pullable);
|
||||||
continue;
|
continue;
|
||||||
}
|
}
|
||||||
|
|
||||||
if (!IoCManager.Resolve<IEntityManager>().TryGetComponent<PhysicsComponent?>(pullable.Owner, out var physics) ||
|
if (!EntityManager.TryGetComponent<PhysicsComponent?>(pullable.Owner, out var physics) ||
|
||||||
physics.BodyType == BodyType.Static ||
|
physics.BodyType == BodyType.Static ||
|
||||||
movingTo.MapId != IoCManager.Resolve<IEntityManager>().GetComponent<TransformComponent>(pullable.Owner).MapID)
|
movingTo.MapId != EntityManager.GetComponent<TransformComponent>(pullable.Owner).MapID)
|
||||||
{
|
{
|
||||||
_pullableSystem.StopMoveTo(pullable);
|
_pullableSystem.StopMoveTo(pullable);
|
||||||
continue;
|
continue;
|
||||||
}
|
}
|
||||||
|
|
||||||
var movingPosition = movingTo.Position;
|
var movingPosition = movingTo.Position;
|
||||||
var ownerPosition = IoCManager.Resolve<IEntityManager>().GetComponent<TransformComponent>(pullable.Owner).MapPosition.Position;
|
var ownerPosition = EntityManager.GetComponent<TransformComponent>(pullable.Owner).MapPosition.Position;
|
||||||
|
|
||||||
var diff = movingPosition - ownerPosition;
|
var diff = movingPosition - ownerPosition;
|
||||||
var diffLength = diff.Length;
|
var diffLength = diff.Length;
|
||||||
@@ -119,7 +116,7 @@ namespace Content.Server.Physics.Controllers
|
|||||||
var impulse = accel * physics.Mass * frameTime;
|
var impulse = accel * physics.Mass * frameTime;
|
||||||
physics.ApplyLinearImpulse(impulse);
|
physics.ApplyLinearImpulse(impulse);
|
||||||
|
|
||||||
if (IoCManager.Resolve<IEntityManager>().TryGetComponent<PhysicsComponent?>(puller, out var pullerPhysics))
|
if (EntityManager.TryGetComponent<PhysicsComponent?>(puller, out var pullerPhysics))
|
||||||
{
|
{
|
||||||
pullerPhysics.WakeBody();
|
pullerPhysics.WakeBody();
|
||||||
pullerPhysics.ApplyLinearImpulse(-impulse);
|
pullerPhysics.ApplyLinearImpulse(-impulse);
|
||||||
|
|||||||
@@ -1,4 +1,5 @@
|
|||||||
using System.Collections.Generic;
|
using System.Collections.Generic;
|
||||||
|
using Robust.Shared.GameObjects;
|
||||||
|
|
||||||
namespace Content.Server.Radio.Components
|
namespace Content.Server.Radio.Components
|
||||||
{
|
{
|
||||||
|
|||||||
@@ -18,6 +18,8 @@ namespace Content.Server.Storage.Components
|
|||||||
[RegisterComponent]
|
[RegisterComponent]
|
||||||
public class SecretStashComponent : Component, IDestroyAct
|
public class SecretStashComponent : Component, IDestroyAct
|
||||||
{
|
{
|
||||||
|
[Dependency] private readonly IEntityManager _entities = default!;
|
||||||
|
|
||||||
public override string Name => "SecretStash";
|
public override string Name => "SecretStash";
|
||||||
|
|
||||||
[ViewVariables] [DataField("maxItemSize")]
|
[ViewVariables] [DataField("maxItemSize")]
|
||||||
@@ -78,20 +80,20 @@ namespace Content.Server.Storage.Components
|
|||||||
/// <returns>True if user recieved item</returns>
|
/// <returns>True if user recieved item</returns>
|
||||||
public bool TryGetItem(EntityUid user)
|
public bool TryGetItem(EntityUid user)
|
||||||
{
|
{
|
||||||
if (_itemContainer.ContainedEntity == null)
|
if (_itemContainer.ContainedEntity is not {Valid: true} contained)
|
||||||
return false;
|
return false;
|
||||||
|
|
||||||
Owner.PopupMessage(user, Loc.GetString("comp-secret-stash-action-get-item-found-something", ("stash", SecretPartName)));
|
Owner.PopupMessage(user, Loc.GetString("comp-secret-stash-action-get-item-found-something", ("stash", SecretPartName)));
|
||||||
|
|
||||||
if (IoCManager.Resolve<IEntityManager>().TryGetComponent(user, out HandsComponent? hands))
|
if (IoCManager.Resolve<IEntityManager>().TryGetComponent(user, out HandsComponent? hands))
|
||||||
{
|
{
|
||||||
if (!IoCManager.Resolve<IEntityManager>().TryGetComponent(_itemContainer.ContainedEntity, out ItemComponent? item))
|
if (!IoCManager.Resolve<IEntityManager>().TryGetComponent(contained, out ItemComponent? item))
|
||||||
return false;
|
return false;
|
||||||
hands.PutInHandOrDrop(item);
|
hands.PutInHandOrDrop(item);
|
||||||
}
|
}
|
||||||
else if (_itemContainer.Remove(_itemContainer.ContainedEntity))
|
else if (_itemContainer.Remove(contained))
|
||||||
{
|
{
|
||||||
IoCManager.Resolve<IEntityManager>().GetComponent<TransformComponent>(_itemContainer.ContainedEntity).Coordinates = IoCManager.Resolve<IEntityManager>().GetComponent<TransformComponent>(Owner).Coordinates;
|
IoCManager.Resolve<IEntityManager>().GetComponent<TransformComponent>(contained).Coordinates = IoCManager.Resolve<IEntityManager>().GetComponent<TransformComponent>(Owner).Coordinates;
|
||||||
}
|
}
|
||||||
|
|
||||||
return true;
|
return true;
|
||||||
@@ -109,9 +111,9 @@ namespace Content.Server.Storage.Components
|
|||||||
public void OnDestroy(DestructionEventArgs eventArgs)
|
public void OnDestroy(DestructionEventArgs eventArgs)
|
||||||
{
|
{
|
||||||
// drop item inside
|
// drop item inside
|
||||||
if (_itemContainer.ContainedEntity != null)
|
if (_itemContainer.ContainedEntity is {Valid: true} contained)
|
||||||
{
|
{
|
||||||
IoCManager.Resolve<IEntityManager>().GetComponent<TransformComponent>(_itemContainer.ContainedEntity).Coordinates = IoCManager.Resolve<IEntityManager>().GetComponent<TransformComponent>(Owner).Coordinates;
|
_entities.GetComponent<TransformComponent>(contained).Coordinates = _entities.GetComponent<TransformComponent>(Owner).Coordinates;
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|||||||
@@ -452,9 +452,7 @@ namespace Content.Server.Storage.Components
|
|||||||
{
|
{
|
||||||
EnsureInitialCalculated();
|
EnsureInitialCalculated();
|
||||||
|
|
||||||
var player = session.AttachedEntity;
|
if (session.AttachedEntity is not {Valid: true} player)
|
||||||
|
|
||||||
if (!player.Valid)
|
|
||||||
{
|
{
|
||||||
break;
|
break;
|
||||||
}
|
}
|
||||||
@@ -491,9 +489,7 @@ namespace Content.Server.Storage.Components
|
|||||||
{
|
{
|
||||||
EnsureInitialCalculated();
|
EnsureInitialCalculated();
|
||||||
|
|
||||||
var player = session.AttachedEntity;
|
if (session.AttachedEntity is not {Valid: true} player)
|
||||||
|
|
||||||
if (player == null)
|
|
||||||
{
|
{
|
||||||
break;
|
break;
|
||||||
}
|
}
|
||||||
@@ -570,7 +566,7 @@ namespace Content.Server.Storage.Components
|
|||||||
|
|
||||||
// Pick up all entities in a radius around the clicked location.
|
// Pick up all entities in a radius around the clicked location.
|
||||||
// The last half of the if is because carpets exist and this is terrible
|
// The last half of the if is because carpets exist and this is terrible
|
||||||
if (_areaInsert && (eventArgs.Target == null || !_entityManager.HasComponent<SharedItemComponent>(eventArgs.Target)))
|
if (_areaInsert && (eventArgs.Target == null || !_entityManager.HasComponent<SharedItemComponent>(eventArgs.Target.Value)))
|
||||||
{
|
{
|
||||||
var validStorables = new List<EntityUid>();
|
var validStorables = new List<EntityUid>();
|
||||||
foreach (var entity in IoCManager.Resolve<IEntityLookup>().GetEntitiesInRange(eventArgs.ClickLocation, _areaInsertRadius, LookupFlags.None))
|
foreach (var entity in IoCManager.Resolve<IEntityLookup>().GetEntitiesInRange(eventArgs.ClickLocation, _areaInsertRadius, LookupFlags.None))
|
||||||
|
|||||||
@@ -151,13 +151,13 @@ namespace Content.Server.Storage.EntitySystems
|
|||||||
var attachedEntity = session.AttachedEntity;
|
var attachedEntity = session.AttachedEntity;
|
||||||
|
|
||||||
// The component manages the set of sessions, so this invalid session should be removed soon.
|
// The component manages the set of sessions, so this invalid session should be removed soon.
|
||||||
if (attachedEntity == null || !IoCManager.Resolve<IEntityManager>().EntityExists(attachedEntity))
|
if (attachedEntity == null || !IoCManager.Resolve<IEntityManager>().EntityExists(attachedEntity.Value))
|
||||||
continue;
|
continue;
|
||||||
|
|
||||||
if (storageMap != IoCManager.Resolve<IEntityManager>().GetComponent<TransformComponent>(attachedEntity).MapID)
|
if (storageMap != IoCManager.Resolve<IEntityManager>().GetComponent<TransformComponent>(attachedEntity.Value).MapID)
|
||||||
continue;
|
continue;
|
||||||
|
|
||||||
var distanceSquared = (storagePos - IoCManager.Resolve<IEntityManager>().GetComponent<TransformComponent>(attachedEntity).WorldPosition).LengthSquared;
|
var distanceSquared = (storagePos - IoCManager.Resolve<IEntityManager>().GetComponent<TransformComponent>(attachedEntity.Value).WorldPosition).LengthSquared;
|
||||||
if (distanceSquared > InteractionSystem.InteractionRangeSquared)
|
if (distanceSquared > InteractionSystem.InteractionRangeSquared)
|
||||||
{
|
{
|
||||||
storageComp.UnsubscribeSession(session);
|
storageComp.UnsubscribeSession(session);
|
||||||
|
|||||||
@@ -25,6 +25,8 @@ namespace Content.Server.Strip
|
|||||||
[ComponentReference(typeof(SharedStrippableComponent))]
|
[ComponentReference(typeof(SharedStrippableComponent))]
|
||||||
public sealed class StrippableComponent : SharedStrippableComponent
|
public sealed class StrippableComponent : SharedStrippableComponent
|
||||||
{
|
{
|
||||||
|
[Dependency] private readonly IEntityManager _entities = default!;
|
||||||
|
|
||||||
public const float StripDelay = 2f;
|
public const float StripDelay = 2f;
|
||||||
|
|
||||||
// TODO: This component needs localization.
|
// TODO: This component needs localization.
|
||||||
@@ -45,17 +47,17 @@ namespace Content.Server.Strip
|
|||||||
Owner.EnsureComponentWarn<HandsComponent>();
|
Owner.EnsureComponentWarn<HandsComponent>();
|
||||||
Owner.EnsureComponentWarn<CuffableComponent>();
|
Owner.EnsureComponentWarn<CuffableComponent>();
|
||||||
|
|
||||||
if (IoCManager.Resolve<IEntityManager>().TryGetComponent(Owner, out CuffableComponent? cuffed))
|
if (_entities.TryGetComponent(Owner, out CuffableComponent? cuffed))
|
||||||
{
|
{
|
||||||
cuffed.OnCuffedStateChanged += UpdateSubscribed;
|
cuffed.OnCuffedStateChanged += UpdateSubscribed;
|
||||||
}
|
}
|
||||||
|
|
||||||
if (IoCManager.Resolve<IEntityManager>().TryGetComponent(Owner, out InventoryComponent? inventory))
|
if (_entities.TryGetComponent(Owner, out InventoryComponent? inventory))
|
||||||
{
|
{
|
||||||
inventory.OnItemChanged += UpdateSubscribed;
|
inventory.OnItemChanged += UpdateSubscribed;
|
||||||
}
|
}
|
||||||
|
|
||||||
if (IoCManager.Resolve<IEntityManager>().TryGetComponent(Owner, out HandsComponent? hands))
|
if (_entities.TryGetComponent(Owner, out HandsComponent? hands))
|
||||||
{
|
{
|
||||||
hands.OnItemChanged += UpdateSubscribed;
|
hands.OnItemChanged += UpdateSubscribed;
|
||||||
}
|
}
|
||||||
@@ -80,7 +82,7 @@ namespace Content.Server.Strip
|
|||||||
|
|
||||||
public override bool Drop(DragDropEvent args)
|
public override bool Drop(DragDropEvent args)
|
||||||
{
|
{
|
||||||
if (!IoCManager.Resolve<IEntityManager>().TryGetComponent(args.User, out ActorComponent? actor)) return false;
|
if (!_entities.TryGetComponent(args.User, out ActorComponent? actor)) return false;
|
||||||
|
|
||||||
OpenUserInterface(actor.PlayerSession);
|
OpenUserInterface(actor.PlayerSession);
|
||||||
return true;
|
return true;
|
||||||
@@ -90,14 +92,15 @@ namespace Content.Server.Strip
|
|||||||
{
|
{
|
||||||
var dictionary = new Dictionary<EntityUid, string>();
|
var dictionary = new Dictionary<EntityUid, string>();
|
||||||
|
|
||||||
if (!IoCManager.Resolve<IEntityManager>().TryGetComponent(Owner, out CuffableComponent? cuffed))
|
if (!_entities.TryGetComponent(Owner, out CuffableComponent? cuffed))
|
||||||
{
|
{
|
||||||
return dictionary;
|
return dictionary;
|
||||||
}
|
}
|
||||||
|
|
||||||
foreach (EntityUid entity in cuffed.StoredEntities)
|
foreach (var entity in cuffed.StoredEntities)
|
||||||
{
|
{
|
||||||
dictionary.Add(entity, entity.Name);
|
var name = _entities.GetComponent<MetaDataComponent>(entity).EntityName;
|
||||||
|
dictionary.Add(entity, name);
|
||||||
}
|
}
|
||||||
|
|
||||||
return dictionary;
|
return dictionary;
|
||||||
@@ -107,7 +110,7 @@ namespace Content.Server.Strip
|
|||||||
{
|
{
|
||||||
var dictionary = new Dictionary<Slots, string>();
|
var dictionary = new Dictionary<Slots, string>();
|
||||||
|
|
||||||
if (!IoCManager.Resolve<IEntityManager>().TryGetComponent(Owner, out InventoryComponent? inventory))
|
if (!_entities.TryGetComponent(Owner, out InventoryComponent? inventory))
|
||||||
{
|
{
|
||||||
return dictionary;
|
return dictionary;
|
||||||
}
|
}
|
||||||
@@ -117,7 +120,7 @@ namespace Content.Server.Strip
|
|||||||
var name = "None";
|
var name = "None";
|
||||||
|
|
||||||
if (inventory.GetSlotItem(slot) is { } item)
|
if (inventory.GetSlotItem(slot) is { } item)
|
||||||
name = item.Owner.Name;
|
name = _entities.GetComponent<MetaDataComponent>(item.Owner).EntityName;
|
||||||
|
|
||||||
dictionary[slot] = name;
|
dictionary[slot] = name;
|
||||||
}
|
}
|
||||||
@@ -129,7 +132,7 @@ namespace Content.Server.Strip
|
|||||||
{
|
{
|
||||||
var dictionary = new Dictionary<string, string>();
|
var dictionary = new Dictionary<string, string>();
|
||||||
|
|
||||||
if (!IoCManager.Resolve<IEntityManager>().TryGetComponent(Owner, out HandsComponent? hands))
|
if (!_entities.TryGetComponent(Owner, out HandsComponent? hands))
|
||||||
{
|
{
|
||||||
return dictionary;
|
return dictionary;
|
||||||
}
|
}
|
||||||
@@ -138,13 +141,13 @@ namespace Content.Server.Strip
|
|||||||
{
|
{
|
||||||
var owner = hands.GetItem(hand)?.Owner;
|
var owner = hands.GetItem(hand)?.Owner;
|
||||||
|
|
||||||
if ((owner != null ? IoCManager.Resolve<IEntityManager>().HasComponent<HandVirtualItemComponent>(owner) : (bool?) null) ?? true)
|
if (!owner.HasValue || _entities.HasComponent<HandVirtualItemComponent>(owner.Value))
|
||||||
{
|
{
|
||||||
dictionary[hand] = "None";
|
dictionary[hand] = "None";
|
||||||
continue;
|
continue;
|
||||||
}
|
}
|
||||||
|
|
||||||
dictionary[hand] = owner.Name;
|
dictionary[hand] = _entities.GetComponent<MetaDataComponent>(owner.Value).EntityName;
|
||||||
}
|
}
|
||||||
|
|
||||||
return dictionary;
|
return dictionary;
|
||||||
@@ -160,8 +163,8 @@ namespace Content.Server.Strip
|
|||||||
/// </summary>
|
/// </summary>
|
||||||
private async void PlaceActiveHandItemInInventory(EntityUid user, Slots slot)
|
private async void PlaceActiveHandItemInInventory(EntityUid user, Slots slot)
|
||||||
{
|
{
|
||||||
var inventory = IoCManager.Resolve<IEntityManager>().GetComponent<InventoryComponent>(Owner);
|
var inventory = _entities.GetComponent<InventoryComponent>(Owner);
|
||||||
var userHands = IoCManager.Resolve<IEntityManager>().GetComponent<HandsComponent>(user);
|
var userHands = _entities.GetComponent<HandsComponent>(user);
|
||||||
var item = userHands.GetActiveHand;
|
var item = userHands.GetActiveHand;
|
||||||
|
|
||||||
bool Check()
|
bool Check()
|
||||||
@@ -225,8 +228,8 @@ namespace Content.Server.Strip
|
|||||||
/// </summary>
|
/// </summary>
|
||||||
private async void PlaceActiveHandItemInHands(EntityUid user, string hand)
|
private async void PlaceActiveHandItemInHands(EntityUid user, string hand)
|
||||||
{
|
{
|
||||||
var hands = IoCManager.Resolve<IEntityManager>().GetComponent<HandsComponent>(Owner);
|
var hands = _entities.GetComponent<HandsComponent>(Owner);
|
||||||
var userHands = IoCManager.Resolve<IEntityManager>().GetComponent<HandsComponent>(user);
|
var userHands = _entities.GetComponent<HandsComponent>(user);
|
||||||
var item = userHands.GetActiveHand;
|
var item = userHands.GetActiveHand;
|
||||||
|
|
||||||
bool Check()
|
bool Check()
|
||||||
@@ -291,8 +294,8 @@ namespace Content.Server.Strip
|
|||||||
/// </summary>
|
/// </summary>
|
||||||
private async void TakeItemFromInventory(EntityUid user, Slots slot)
|
private async void TakeItemFromInventory(EntityUid user, Slots slot)
|
||||||
{
|
{
|
||||||
var inventory = IoCManager.Resolve<IEntityManager>().GetComponent<InventoryComponent>(Owner);
|
var inventory = _entities.GetComponent<InventoryComponent>(Owner);
|
||||||
var userHands = IoCManager.Resolve<IEntityManager>().GetComponent<HandsComponent>(user);
|
var userHands = _entities.GetComponent<HandsComponent>(user);
|
||||||
|
|
||||||
bool Check()
|
bool Check()
|
||||||
{
|
{
|
||||||
@@ -347,8 +350,8 @@ namespace Content.Server.Strip
|
|||||||
/// </summary>
|
/// </summary>
|
||||||
private async void TakeItemFromHands(EntityUid user, string hand)
|
private async void TakeItemFromHands(EntityUid user, string hand)
|
||||||
{
|
{
|
||||||
var hands = IoCManager.Resolve<IEntityManager>().GetComponent<HandsComponent>(Owner);
|
var hands = _entities.GetComponent<HandsComponent>(Owner);
|
||||||
var userHands = IoCManager.Resolve<IEntityManager>().GetComponent<HandsComponent>(user);
|
var userHands = _entities.GetComponent<HandsComponent>(user);
|
||||||
|
|
||||||
bool Check()
|
bool Check()
|
||||||
{
|
{
|
||||||
@@ -364,7 +367,7 @@ namespace Content.Server.Strip
|
|||||||
return false;
|
return false;
|
||||||
}
|
}
|
||||||
|
|
||||||
if (IoCManager.Resolve<IEntityManager>().HasComponent<HandVirtualItemComponent>(heldItem.Owner))
|
if (_entities.HasComponent<HandVirtualItemComponent>(heldItem.Owner))
|
||||||
return false;
|
return false;
|
||||||
|
|
||||||
if (!hands.CanDrop(hand, false))
|
if (!hands.CanDrop(hand, false))
|
||||||
@@ -398,8 +401,9 @@ namespace Content.Server.Strip
|
|||||||
|
|
||||||
private void HandleUserInterfaceMessage(ServerBoundUserInterfaceMessage obj)
|
private void HandleUserInterfaceMessage(ServerBoundUserInterfaceMessage obj)
|
||||||
{
|
{
|
||||||
var user = obj.Session.AttachedEntity;
|
if (obj.Session.AttachedEntity is not {Valid: true} user ||
|
||||||
if (user == null || !IoCManager.Resolve<IEntityManager>().TryGetComponent(user, out HandsComponent? userHands)) return;
|
!_entities.TryGetComponent(user, out HandsComponent? userHands))
|
||||||
|
return;
|
||||||
|
|
||||||
var placingItem = userHands.GetActiveHand != null;
|
var placingItem = userHands.GetActiveHand != null;
|
||||||
|
|
||||||
@@ -407,7 +411,7 @@ namespace Content.Server.Strip
|
|||||||
{
|
{
|
||||||
case StrippingInventoryButtonPressed inventoryMessage:
|
case StrippingInventoryButtonPressed inventoryMessage:
|
||||||
|
|
||||||
if (IoCManager.Resolve<IEntityManager>().TryGetComponent<InventoryComponent?>(Owner, out var inventory))
|
if (_entities.TryGetComponent<InventoryComponent?>(Owner, out var inventory))
|
||||||
{
|
{
|
||||||
if (inventory.TryGetSlotItem(inventoryMessage.Slot, out ItemComponent? _))
|
if (inventory.TryGetSlotItem(inventoryMessage.Slot, out ItemComponent? _))
|
||||||
placingItem = false;
|
placingItem = false;
|
||||||
@@ -421,7 +425,7 @@ namespace Content.Server.Strip
|
|||||||
|
|
||||||
case StrippingHandButtonPressed handMessage:
|
case StrippingHandButtonPressed handMessage:
|
||||||
|
|
||||||
if (IoCManager.Resolve<IEntityManager>().TryGetComponent<HandsComponent?>(Owner, out var hands))
|
if (_entities.TryGetComponent<HandsComponent?>(Owner, out var hands))
|
||||||
{
|
{
|
||||||
if (hands.TryGetItem(handMessage.Hand, out _))
|
if (hands.TryGetItem(handMessage.Hand, out _))
|
||||||
placingItem = false;
|
placingItem = false;
|
||||||
@@ -435,7 +439,7 @@ namespace Content.Server.Strip
|
|||||||
|
|
||||||
case StrippingHandcuffButtonPressed handcuffMessage:
|
case StrippingHandcuffButtonPressed handcuffMessage:
|
||||||
|
|
||||||
if (IoCManager.Resolve<IEntityManager>().TryGetComponent<CuffableComponent?>(Owner, out var cuffed))
|
if (_entities.TryGetComponent<CuffableComponent?>(Owner, out var cuffed))
|
||||||
{
|
{
|
||||||
foreach (var entity in cuffed.StoredEntities)
|
foreach (var entity in cuffed.StoredEntities)
|
||||||
{
|
{
|
||||||
|
|||||||
@@ -10,6 +10,7 @@ using Content.Shared.Audio;
|
|||||||
using Content.Shared.Examine;
|
using Content.Shared.Examine;
|
||||||
using Content.Shared.Interaction;
|
using Content.Shared.Interaction;
|
||||||
using Content.Shared.Jittering;
|
using Content.Shared.Jittering;
|
||||||
|
using Content.Shared.Popups;
|
||||||
using Content.Shared.StatusEffect;
|
using Content.Shared.StatusEffect;
|
||||||
using Content.Shared.Stunnable;
|
using Content.Shared.Stunnable;
|
||||||
using Content.Shared.Throwing;
|
using Content.Shared.Throwing;
|
||||||
|
|||||||
@@ -133,7 +133,7 @@ namespace Content.Server.UserInterface
|
|||||||
|
|
||||||
public class ActivatableUIOpenAttemptEvent : CancellableEntityEventArgs
|
public class ActivatableUIOpenAttemptEvent : CancellableEntityEventArgs
|
||||||
{
|
{
|
||||||
public EntityUidUser { get; }
|
public EntityUid user { get; }
|
||||||
public ActivatableUIOpenAttemptEvent(EntityUidwho)
|
public ActivatableUIOpenAttemptEvent(EntityUidwho)
|
||||||
{
|
{
|
||||||
User = who;
|
User = who;
|
||||||
|
|||||||
@@ -208,18 +208,18 @@ namespace Content.Server.Weapon.Melee
|
|||||||
return;
|
return;
|
||||||
}
|
}
|
||||||
|
|
||||||
if (!args.Target.Valid)
|
if (!args.Target.HasValue)
|
||||||
return;
|
return;
|
||||||
|
|
||||||
var location = IoCManager.Resolve<IEntityManager>().GetComponent<TransformComponent>(args.User).Coordinates;
|
var location = IoCManager.Resolve<IEntityManager>().GetComponent<TransformComponent>(args.User).Coordinates;
|
||||||
var diff = args.ClickLocation.ToMapPos(IoCManager.Resolve<IEntityManager>()) - location.ToMapPos(IoCManager.Resolve<IEntityManager>());
|
var diff = args.ClickLocation.ToMapPos(IoCManager.Resolve<IEntityManager>()) - location.ToMapPos(IoCManager.Resolve<IEntityManager>());
|
||||||
var angle = Angle.FromWorldVec(diff);
|
var angle = Angle.FromWorldVec(diff);
|
||||||
|
|
||||||
var hitEvent = new MeleeInteractEvent(args.Target, args.User);
|
var hitEvent = new MeleeInteractEvent(args.Target.Value, args.User);
|
||||||
RaiseLocalEvent(owner, hitEvent, false);
|
RaiseLocalEvent(owner, hitEvent, false);
|
||||||
|
|
||||||
if (!hitEvent.CanInteract) return;
|
if (!hitEvent.CanInteract) return;
|
||||||
SendAnimation(comp.ClickArc, angle, args.User, owner, new List<EntityUid>() { args.Target }, comp.ClickAttackEffect, false);
|
SendAnimation(comp.ClickArc, angle, args.User, owner, new List<EntityUid>() { args.Target.Value }, comp.ClickAttackEffect, false);
|
||||||
|
|
||||||
comp.LastAttackTime = curTime;
|
comp.LastAttackTime = curTime;
|
||||||
comp.CooldownEnd = comp.LastAttackTime + TimeSpan.FromSeconds(comp.CooldownTime);
|
comp.CooldownEnd = comp.LastAttackTime + TimeSpan.FromSeconds(comp.CooldownTime);
|
||||||
|
|||||||
@@ -22,6 +22,8 @@ namespace Content.Server.Weapon.Ranged.Ammunition.Components
|
|||||||
public sealed class AmmoBoxComponent : Component, IInteractUsing, IUse, IInteractHand, IMapInit, IExamine
|
public sealed class AmmoBoxComponent : Component, IInteractUsing, IUse, IInteractHand, IMapInit, IExamine
|
||||||
#pragma warning restore 618
|
#pragma warning restore 618
|
||||||
{
|
{
|
||||||
|
[Dependency] private readonly IEntityManager _entities = default!;
|
||||||
|
|
||||||
public override string Name => "AmmoBox";
|
public override string Name => "AmmoBox";
|
||||||
|
|
||||||
[DataField("caliber")]
|
[DataField("caliber")]
|
||||||
@@ -73,7 +75,7 @@ namespace Content.Server.Weapon.Ranged.Ammunition.Components
|
|||||||
|
|
||||||
private void UpdateAppearance()
|
private void UpdateAppearance()
|
||||||
{
|
{
|
||||||
if (IoCManager.Resolve<IEntityManager>().TryGetComponent(Owner, out AppearanceComponent? appearanceComponent))
|
if (_entities.TryGetComponent(Owner, out AppearanceComponent? appearanceComponent))
|
||||||
{
|
{
|
||||||
appearanceComponent.SetData(MagazineBarrelVisuals.MagLoaded, true);
|
appearanceComponent.SetData(MagazineBarrelVisuals.MagLoaded, true);
|
||||||
appearanceComponent.SetData(AmmoVisuals.AmmoCount, AmmoLeft);
|
appearanceComponent.SetData(AmmoVisuals.AmmoCount, AmmoLeft);
|
||||||
@@ -81,7 +83,7 @@ namespace Content.Server.Weapon.Ranged.Ammunition.Components
|
|||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
public EntityUid TakeAmmo()
|
public EntityUid? TakeAmmo()
|
||||||
{
|
{
|
||||||
if (_spawnedAmmo.TryPop(out var ammo))
|
if (_spawnedAmmo.TryPop(out var ammo))
|
||||||
{
|
{
|
||||||
@@ -91,10 +93,10 @@ namespace Content.Server.Weapon.Ranged.Ammunition.Components
|
|||||||
|
|
||||||
if (_unspawnedCount > 0)
|
if (_unspawnedCount > 0)
|
||||||
{
|
{
|
||||||
ammo = IoCManager.Resolve<IEntityManager>().SpawnEntity(_fillPrototype, IoCManager.Resolve<IEntityManager>().GetComponent<TransformComponent>(Owner).Coordinates);
|
ammo = _entities.SpawnEntity(_fillPrototype, _entities.GetComponent<TransformComponent>(Owner).Coordinates);
|
||||||
|
|
||||||
// when dumping from held ammo box, this detaches the spawned ammo from the player.
|
// when dumping from held ammo box, this detaches the spawned ammo from the player.
|
||||||
IoCManager.Resolve<IEntityManager>().GetComponent<TransformComponent>(ammo).AttachParentToContainerOrGrid();
|
_entities.GetComponent<TransformComponent>(ammo).AttachParentToContainerOrGrid();
|
||||||
|
|
||||||
_unspawnedCount--;
|
_unspawnedCount--;
|
||||||
}
|
}
|
||||||
@@ -104,7 +106,7 @@ namespace Content.Server.Weapon.Ranged.Ammunition.Components
|
|||||||
|
|
||||||
public bool TryInsertAmmo(EntityUid user, EntityUid entity)
|
public bool TryInsertAmmo(EntityUid user, EntityUid entity)
|
||||||
{
|
{
|
||||||
if (!IoCManager.Resolve<IEntityManager>().TryGetComponent(entity, out AmmoComponent? ammoComponent))
|
if (!_entities.TryGetComponent(entity, out AmmoComponent? ammoComponent))
|
||||||
{
|
{
|
||||||
return false;
|
return false;
|
||||||
}
|
}
|
||||||
@@ -129,12 +131,12 @@ namespace Content.Server.Weapon.Ranged.Ammunition.Components
|
|||||||
|
|
||||||
async Task<bool> IInteractUsing.InteractUsing(InteractUsingEventArgs eventArgs)
|
async Task<bool> IInteractUsing.InteractUsing(InteractUsingEventArgs eventArgs)
|
||||||
{
|
{
|
||||||
if (IoCManager.Resolve<IEntityManager>().HasComponent<AmmoComponent>(eventArgs.Using))
|
if (_entities.HasComponent<AmmoComponent>(eventArgs.Using))
|
||||||
{
|
{
|
||||||
return TryInsertAmmo(eventArgs.User, eventArgs.Using);
|
return TryInsertAmmo(eventArgs.User, eventArgs.Using);
|
||||||
}
|
}
|
||||||
|
|
||||||
if (IoCManager.Resolve<IEntityManager>().TryGetComponent(eventArgs.Using, out RangedMagazineComponent? rangedMagazine))
|
if (_entities.TryGetComponent(eventArgs.Using, out RangedMagazineComponent? rangedMagazine))
|
||||||
{
|
{
|
||||||
for (var i = 0; i < Math.Max(10, rangedMagazine.ShotsLeft); i++)
|
for (var i = 0; i < Math.Max(10, rangedMagazine.ShotsLeft); i++)
|
||||||
{
|
{
|
||||||
@@ -160,19 +162,17 @@ namespace Content.Server.Weapon.Ranged.Ammunition.Components
|
|||||||
|
|
||||||
private bool TryUse(EntityUid user)
|
private bool TryUse(EntityUid user)
|
||||||
{
|
{
|
||||||
if (!IoCManager.Resolve<IEntityManager>().TryGetComponent(user, out HandsComponent? handsComponent))
|
if (!_entities.TryGetComponent(user, out HandsComponent? handsComponent))
|
||||||
{
|
{
|
||||||
return false;
|
return false;
|
||||||
}
|
}
|
||||||
|
|
||||||
var ammo = TakeAmmo();
|
if (TakeAmmo() is not { } ammo)
|
||||||
|
|
||||||
if (ammo == null)
|
|
||||||
{
|
{
|
||||||
return false;
|
return false;
|
||||||
}
|
}
|
||||||
|
|
||||||
if (IoCManager.Resolve<IEntityManager>().TryGetComponent(ammo, out ItemComponent? item))
|
if (_entities.TryGetComponent(ammo, out ItemComponent? item))
|
||||||
{
|
{
|
||||||
if (!handsComponent.CanPutInHand(item))
|
if (!handsComponent.CanPutInHand(item))
|
||||||
{
|
{
|
||||||
@@ -194,8 +194,7 @@ namespace Content.Server.Weapon.Ranged.Ammunition.Components
|
|||||||
|
|
||||||
for (var i = 0; i < Math.Min(count, Capacity); i++)
|
for (var i = 0; i < Math.Min(count, Capacity); i++)
|
||||||
{
|
{
|
||||||
var ammo = TakeAmmo();
|
if (TakeAmmo() is not { } ammo)
|
||||||
if (ammo == null)
|
|
||||||
{
|
{
|
||||||
break;
|
break;
|
||||||
}
|
}
|
||||||
|
|||||||
@@ -259,24 +259,27 @@ namespace Content.Server.Weapon.Ranged.Barrels.Components
|
|||||||
/// <param name="robustRandom"></param>
|
/// <param name="robustRandom"></param>
|
||||||
/// <param name="prototypeManager"></param>
|
/// <param name="prototypeManager"></param>
|
||||||
/// <param name="ejectDirections"></param>
|
/// <param name="ejectDirections"></param>
|
||||||
public void EjectCasing(
|
public static void EjectCasing(
|
||||||
EntityUid entity,
|
EntityUid entity,
|
||||||
bool playSound = true,
|
bool playSound = true,
|
||||||
|
Direction[]? ejectDirections = null,
|
||||||
IRobustRandom? robustRandom = null,
|
IRobustRandom? robustRandom = null,
|
||||||
IPrototypeManager? prototypeManager = null,
|
IPrototypeManager? prototypeManager = null,
|
||||||
Direction[]? ejectDirections = null)
|
IEntityManager? entities = null)
|
||||||
{
|
{
|
||||||
robustRandom ??= IoCManager.Resolve<IRobustRandom>();
|
IoCManager.Resolve(ref robustRandom, ref prototypeManager, ref entities);
|
||||||
|
|
||||||
ejectDirections ??= new[]
|
ejectDirections ??= new[]
|
||||||
{Direction.East, Direction.North, Direction.NorthWest, Direction.South, Direction.SouthEast, Direction.West};
|
{Direction.East, Direction.North, Direction.NorthWest, Direction.South, Direction.SouthEast, Direction.West};
|
||||||
|
|
||||||
const float ejectOffset = 1.8f;
|
const float ejectOffset = 1.8f;
|
||||||
var ammo = _entities.GetComponent<AmmoComponent>(entity);
|
var ammo = entities.GetComponent<AmmoComponent>(entity);
|
||||||
var offsetPos = ((robustRandom.NextFloat() - 0.5f) * ejectOffset, (robustRandom.NextFloat() - 0.5f) * ejectOffset);
|
var offsetPos = ((robustRandom.NextFloat() - 0.5f) * ejectOffset, (robustRandom.NextFloat() - 0.5f) * ejectOffset);
|
||||||
_entities.GetComponent<TransformComponent>(entity).Coordinates = _entities.GetComponent<TransformComponent>(entity).Coordinates.Offset(offsetPos);
|
entities.GetComponent<TransformComponent>(entity).Coordinates = entities.GetComponent<TransformComponent>(entity).Coordinates.Offset(offsetPos);
|
||||||
_entities.GetComponent<TransformComponent>(entity).LocalRotation = robustRandom.Pick(ejectDirections).ToAngle();
|
entities.GetComponent<TransformComponent>(entity).LocalRotation = robustRandom.Pick(ejectDirections).ToAngle();
|
||||||
|
|
||||||
SoundSystem.Play(Filter.Broadcast(), ammo.SoundCollectionEject.GetSound(), _entities.GetComponent<TransformComponent>(entity).Coordinates, AudioParams.Default.WithVolume(-1));
|
var coordinates = entities.GetComponent<TransformComponent>(entity).Coordinates;
|
||||||
|
SoundSystem.Play(Filter.Broadcast(), ammo.SoundCollectionEject.GetSound(), coordinates, AudioParams.Default.WithVolume(-1));
|
||||||
}
|
}
|
||||||
|
|
||||||
/// <summary>
|
/// <summary>
|
||||||
@@ -284,7 +287,7 @@ namespace Content.Server.Weapon.Ranged.Barrels.Components
|
|||||||
/// Wraps EjectCasing to make it less toxic for bulk ejections
|
/// Wraps EjectCasing to make it less toxic for bulk ejections
|
||||||
/// </summary>
|
/// </summary>
|
||||||
/// <param name="entities"></param>
|
/// <param name="entities"></param>
|
||||||
public void EjectCasings(IEnumerable<EntityUid> entities)
|
public static void EjectCasings(IEnumerable<EntityUid> entities)
|
||||||
{
|
{
|
||||||
var robustRandom = IoCManager.Resolve<IRobustRandom>();
|
var robustRandom = IoCManager.Resolve<IRobustRandom>();
|
||||||
var prototypeManager = IoCManager.Resolve<IPrototypeManager>();
|
var prototypeManager = IoCManager.Resolve<IPrototypeManager>();
|
||||||
@@ -294,7 +297,7 @@ namespace Content.Server.Weapon.Ranged.Barrels.Components
|
|||||||
|
|
||||||
foreach (var entity in entities)
|
foreach (var entity in entities)
|
||||||
{
|
{
|
||||||
EjectCasing(entity, playSound, robustRandom, prototypeManager, ejectDirections);
|
EjectCasing(entity, playSound, ejectDirections, robustRandom, prototypeManager);
|
||||||
soundPlayCount++;
|
soundPlayCount++;
|
||||||
if (soundPlayCount > 3)
|
if (soundPlayCount > 3)
|
||||||
{
|
{
|
||||||
|
|||||||
@@ -24,7 +24,7 @@ namespace Content.Shared.Pulling.Components
|
|||||||
/// The current entity pulling this component.
|
/// The current entity pulling this component.
|
||||||
/// SharedPullingStateManagementSystem should be writing this. This means definitely not you.
|
/// SharedPullingStateManagementSystem should be writing this. This means definitely not you.
|
||||||
/// </summary>
|
/// </summary>
|
||||||
public EntityUid Puller { get; set; }
|
public EntityUid? Puller { get; set; }
|
||||||
/// <summary>
|
/// <summary>
|
||||||
/// The pull joint.
|
/// The pull joint.
|
||||||
/// SharedPullingStateManagementSystem should be writing this. This means probably not you.
|
/// SharedPullingStateManagementSystem should be writing this. This means probably not you.
|
||||||
|
|||||||
@@ -17,7 +17,7 @@ namespace Content.Shared.Pulling.Components
|
|||||||
public float SprintSpeedModifier => Pulling == default ? 1.0f : 0.75f;
|
public float SprintSpeedModifier => Pulling == default ? 1.0f : 0.75f;
|
||||||
|
|
||||||
[ViewVariables]
|
[ViewVariables]
|
||||||
public EntityUid Pulling { get; set; }
|
public EntityUid? Pulling { get; set; }
|
||||||
|
|
||||||
protected override void Shutdown()
|
protected override void Shutdown()
|
||||||
{
|
{
|
||||||
|
|||||||
@@ -20,7 +20,7 @@ namespace Content.Shared.Pulling.Systems
|
|||||||
private void OnRelayMoveInput(EntityUid uid, SharedPullableComponent component, RelayMoveInputEvent args)
|
private void OnRelayMoveInput(EntityUid uid, SharedPullableComponent component, RelayMoveInputEvent args)
|
||||||
{
|
{
|
||||||
var entity = args.Session.AttachedEntity;
|
var entity = args.Session.AttachedEntity;
|
||||||
if (!entity.IsValid() || !_blocker.CanMove(entity)) return;
|
if (!entity.HasValue || !_blocker.CanMove(entity.Value)) return;
|
||||||
_pullSystem.TryStopPull(component);
|
_pullSystem.TryStopPull(component);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|||||||
@@ -41,7 +41,7 @@ namespace Content.Shared.Verbs
|
|||||||
// call ActionBlocker checks, just cache it for the verb request.
|
// call ActionBlocker checks, just cache it for the verb request.
|
||||||
var canInteract = force || _actionBlockerSystem.CanInteract(user);
|
var canInteract = force || _actionBlockerSystem.CanInteract(user);
|
||||||
|
|
||||||
EntityUid? @using = null;
|
EntityUid @using = default;
|
||||||
if (EntityManager.TryGetComponent(user, out SharedHandsComponent? hands) && (force || _actionBlockerSystem.CanUse(user)))
|
if (EntityManager.TryGetComponent(user, out SharedHandsComponent? hands) && (force || _actionBlockerSystem.CanUse(user)))
|
||||||
{
|
{
|
||||||
hands.TryGetActiveHeldEntity(out @using);
|
hands.TryGetActiveHeldEntity(out @using);
|
||||||
@@ -49,9 +49,9 @@ namespace Content.Shared.Verbs
|
|||||||
// Check whether the "Held" entity is a virtual pull entity. If yes, set that as the entity being "Used".
|
// Check whether the "Held" entity is a virtual pull entity. If yes, set that as the entity being "Used".
|
||||||
// This allows you to do things like buckle a dragged person onto a surgery table, without click-dragging
|
// This allows you to do things like buckle a dragged person onto a surgery table, without click-dragging
|
||||||
// their sprite.
|
// their sprite.
|
||||||
if (@using != null && EntityManager.TryGetComponent<HandVirtualItemComponent?>(@using.Value, out var pull))
|
if (@using != default && EntityManager.TryGetComponent<HandVirtualItemComponent?>(@using, out var pull))
|
||||||
{
|
{
|
||||||
@using = pull.BlockingEntity
|
@using = pull.BlockingEntity;
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
@@ -110,25 +110,25 @@ namespace Content.Shared.Verbs
|
|||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
public void LogVerb(Verb verb, EntityUid userUid, EntityUid targetUid, bool forced)
|
public void LogVerb(Verb verb, EntityUid user, EntityUid target, bool forced)
|
||||||
{
|
{
|
||||||
// first get the held item. again.
|
// first get the held item. again.
|
||||||
EntityUid usedUid = default;
|
EntityUid usedUid = default;
|
||||||
if (EntityManager.TryGetComponent(userUid, out SharedHandsComponent? hands) &&
|
if (EntityManager.TryGetComponent(user, out SharedHandsComponent? hands) &&
|
||||||
hands.TryGetActiveHeldEntity(out var heldEntity))
|
hands.TryGetActiveHeldEntity(out var heldEntity))
|
||||||
{
|
{
|
||||||
usedUid = heldEntity;
|
usedUid = heldEntity;
|
||||||
if (usedUid != null && EntityManager.TryGetComponent(usedUid.Value, out HandVirtualItemComponent? pull))
|
if (usedUid != default && EntityManager.TryGetComponent(usedUid, out HandVirtualItemComponent? pull))
|
||||||
usedUid = pull.BlockingEntity;
|
usedUid = pull.BlockingEntity;
|
||||||
}
|
}
|
||||||
|
|
||||||
// get all the entities
|
// get all the entities
|
||||||
if (!userUid.IsValid() || !targetUid.IsValid())
|
if (!user.IsValid() || !target.IsValid())
|
||||||
return;
|
return;
|
||||||
|
|
||||||
EntityUid? used = null;
|
EntityUid? used = null;
|
||||||
if (usedUid != null)
|
if (usedUid != default)
|
||||||
EntityManager.EntityExists(usedUid.Value);
|
EntityManager.EntityExists(usedUid);
|
||||||
|
|
||||||
// then prepare the basic log message body
|
// then prepare the basic log message body
|
||||||
var verbText = $"{verb.Category?.Text} {verb.Text}".Trim();
|
var verbText = $"{verb.Category?.Text} {verb.Text}".Trim();
|
||||||
@@ -137,7 +137,7 @@ namespace Content.Shared.Verbs
|
|||||||
: $"executed '{verbText}' verb targeting ";
|
: $"executed '{verbText}' verb targeting ";
|
||||||
|
|
||||||
// then log with entity information
|
// then log with entity information
|
||||||
if (usedUidused != null)
|
if (used != null)
|
||||||
_logSystem.Add(LogType.Verb, verb.Impact,
|
_logSystem.Add(LogType.Verb, verb.Impact,
|
||||||
$"{user} {logText} {target} while holding {used}");
|
$"{user} {logText} {target} while holding {used}");
|
||||||
else
|
else
|
||||||
|
|||||||
Reference in New Issue
Block a user