A bunch of AttachedEntity bullshit

This commit is contained in:
metalgearsloth
2021-12-06 15:39:46 +11:00
parent 215cae5655
commit 525297c5fe
58 changed files with 135 additions and 133 deletions

View File

@@ -16,7 +16,7 @@ namespace Content.Shared.CombatMode
{
var entity = eventArgs.SenderSession.AttachedEntity;
if (entity == null || !EntityManager.TryGetComponent(entity.Value, out SharedCombatModeComponent? combatModeComponent))
if (entity == null || !EntityManager.TryGetComponent(entity, out SharedCombatModeComponent? combatModeComponent))
{
return;
}

View File

@@ -244,14 +244,14 @@ namespace Content.Shared.Containers.ItemSlots
if (!hands.TryGetActiveHeldEntity(out var item))
return false;
if (!CanInsert(uid, item.Value, slot))
if (!CanInsert(uid, item, slot))
return false;
// hands.Drop(item) checks CanDrop action blocker
if (!_actionBlockerSystem.CanInteract(user) && hands.Drop(item.Value))
if (!_actionBlockerSystem.CanInteract(user) && hands.Drop(item))
return false;
Insert(uid, slot, item.Value);
Insert(uid, slot, item);
return true;
}
#endregion

View File

@@ -35,9 +35,9 @@ namespace Content.Shared.Cuffs
private void HandleStopPull(EntityUid uid, SharedCuffableComponent component, StopPullingEvent args)
{
if (args.User == null || !EntityManager.EntityExists(args.User.Value) return;
if (args.User == null || !EntityManager.EntityExists(args.User.Value)) return;
if (user == component.Owner && !component.CanStillInteract)
if (args.User.Value == component.Owner && !component.CanStillInteract)
{
args.Cancel();
}

View File

@@ -12,8 +12,7 @@ namespace Content.Shared.Gravity
private void HandleGridInitialize(GridInitializeEvent ev)
{
var gridev.EntityUid
gridEnt.EnsureComponent<GravityComponent>();
EntityManager.EnsureComponent<GravityComponent>(ev.EntityUid);
}
}
}

View File

@@ -112,7 +112,7 @@ namespace Content.Shared.Hands.Components
if (hand.HeldEntity == null)
continue;
if (!entMan.TryGetComponent(hand.HeldEntity.Value, out SharedItemComponent? item) || item.RsiPath == null)
if (!entMan.TryGetComponent(hand.HeldEntity, out SharedItemComponent? item) || item.RsiPath == null)
continue;
var handState = new HandVisualState(item.RsiPath, item.EquippedPrefix, hand.Location, item.Color);
@@ -250,7 +250,7 @@ namespace Content.Shared.Hands.Components
foreach (var hand in Hands)
{
if (hand.HeldEntity != default)
yield return hand.HeldEntity.Value;
yield return hand.HeldEntity;
}
}
@@ -416,7 +416,7 @@ namespace Content.Shared.Hands.Components
if (hand.HeldEntity == null)
return false;
var heldEntity = hand.HeldEntity.Value;
var heldEntity = hand.HeldEntity;
var handContainer = hand.Container;
if (handContainer == null)
@@ -447,7 +447,7 @@ namespace Content.Shared.Hands.Components
if (hand.HeldEntity == null)
return;
var heldEntity = hand.HeldEntity.Value;
var heldEntity = hand.HeldEntity;
var handContainer = hand.Container;
if (handContainer == null)
@@ -475,7 +475,7 @@ namespace Content.Shared.Hands.Components
if (hand.HeldEntity == null)
return;
var heldEntity = hand.HeldEntity.Value;
var heldEntity = hand.HeldEntity;
RemoveHeldEntityFromHand(hand);
@@ -538,7 +538,7 @@ namespace Content.Shared.Hands.Components
if (hand.HeldEntity == null)
return false;
var heldEntity = hand.HeldEntity.Value;
var heldEntity = hand.HeldEntity;
if (checkActionBlocker && !PlayerCanDrop())
return false;
@@ -557,7 +557,7 @@ namespace Content.Shared.Hands.Components
if (hand.HeldEntity == null)
return;
var heldEntity = hand.HeldEntity.Value;
var heldEntity = hand.HeldEntity;
RemoveHeldEntityFromHand(hand);
@@ -713,7 +713,7 @@ namespace Content.Shared.Hands.Components
return;
await EntitySystem.Get<SharedInteractionSystem>()
.InteractUsing(Owner, activeHeldEntity.Value, heldEntity.Value, EntityCoordinates.Invalid);
.InteractUsing(Owner, activeHeldEntity, heldEntity, EntityCoordinates.Invalid);
}
public void ActivateItem(bool altInteract = false)
@@ -722,7 +722,7 @@ namespace Content.Shared.Hands.Components
return;
EntitySystem.Get<SharedInteractionSystem>()
.TryUseInteraction(Owner, heldEntity.Value, altInteract);
.TryUseInteraction(Owner, heldEntity, altInteract);
}
public void ActivateHeldEntity(string handName)
@@ -745,14 +745,14 @@ namespace Content.Shared.Hands.Components
if (!TryGetHeldEntity(handName, out var heldEntity))
return false;
if (!CanInsertEntityIntoHand(activeHand, heldEntity.Value) || !CanRemoveHeldEntityFromHand(hand))
if (!CanInsertEntityIntoHand(activeHand, heldEntity) || !CanRemoveHeldEntityFromHand(hand))
return false;
if (checkActionBlocker && (!PlayerCanDrop() || !PlayerCanPickup()))
return false;
RemoveHeldEntityFromHand(hand);
PutEntityIntoHand(activeHand, heldEntity.Value);
PutEntityIntoHand(activeHand, heldEntity);
return true;
}
@@ -761,13 +761,13 @@ namespace Content.Shared.Hands.Components
private void DeselectActiveHeldEntity()
{
if (TryGetActiveHeldEntity(out var entity))
EntitySystem.Get<SharedInteractionSystem>().HandDeselectedInteraction(Owner, entity.Value);
EntitySystem.Get<SharedInteractionSystem>().HandDeselectedInteraction(Owner, entity);
}
private void SelectActiveHeldEntity()
{
if (TryGetActiveHeldEntity(out var entity))
EntitySystem.Get<SharedInteractionSystem>().HandSelectedInteraction(Owner, entity.Value);
EntitySystem.Get<SharedInteractionSystem>().HandSelectedInteraction(Owner, entity);
}
private void HandCountChanged()

View File

@@ -22,7 +22,7 @@ namespace Content.Shared.Hands
{
var entity = eventArgs.SenderSession.AttachedEntity;
if (entity == default || !EntityManager.TryGetComponent(entity, out SharedHandsComponent? hands))
if (entity == null || !EntityManager.TryGetComponent(entity, out SharedHandsComponent? hands))
return;
hands.ActiveHand = msg.HandName;

View File

@@ -20,7 +20,7 @@ namespace Content.Shared.Pulling.Systems
private void OnRelayMoveInput(EntityUid uid, SharedPullableComponent component, RelayMoveInputEvent args)
{
var entity = args.Session.AttachedEntity;
if (!entity.HasValue || !_blocker.CanMove(entity.Value)) return;
if (entity == default || !_blocker.CanMove(entity)) return;
_pullSystem.TryStopPull(component);
}
}