disposal emag fix and refactoring (#19790)
Co-authored-by: deltanedas <@deltanedas:kde.org>
This commit is contained in:
@@ -80,8 +80,7 @@ public abstract class SharedDisposalUnitSystem : EntitySystem
|
||||
var otherBody = args.OtherEntity;
|
||||
|
||||
// Items dropped shouldn't collide but items thrown should
|
||||
if (EntityManager.HasComponent<ItemComponent>(otherBody) &&
|
||||
!EntityManager.HasComponent<ThrownItemComponent>(otherBody))
|
||||
if (HasComp<ItemComponent>(otherBody) && !HasComp<ThrownItemComponent>(otherBody))
|
||||
{
|
||||
args.Cancelled = true;
|
||||
return;
|
||||
@@ -110,25 +109,20 @@ public abstract class SharedDisposalUnitSystem : EntitySystem
|
||||
|
||||
public virtual bool CanInsert(EntityUid uid, SharedDisposalUnitComponent component, EntityUid entity)
|
||||
{
|
||||
if (!EntityManager.GetComponent<TransformComponent>(uid).Anchored)
|
||||
if (!Transform(uid).Anchored)
|
||||
return false;
|
||||
|
||||
// TODO: Probably just need a disposable tag.
|
||||
if (!EntityManager.TryGetComponent(entity, out ItemComponent? storable) &&
|
||||
!EntityManager.HasComponent<BodyComponent>(entity))
|
||||
{
|
||||
var storable = HasComp<ItemComponent>(entity);
|
||||
if (!storable && !HasComp<BodyComponent>(entity))
|
||||
return false;
|
||||
}
|
||||
|
||||
//Check if the entity is a mob and if mobs can be inserted
|
||||
if (TryComp<MobStateComponent>(entity, out var damageState) && !component.MobsCanEnter)
|
||||
return false;
|
||||
|
||||
if (EntityManager.TryGetComponent(entity, out PhysicsComponent? physics) &&
|
||||
(physics.CanCollide || storable != null))
|
||||
{
|
||||
if (TryComp<PhysicsComponent>(entity, out var physics) && (physics.CanCollide || storable))
|
||||
return true;
|
||||
}
|
||||
|
||||
return damageState != null && (!component.MobsCanEnter || _mobState.IsDead(entity, damageState));
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user