disposal emag fix and refactoring (#19790)

Co-authored-by: deltanedas <@deltanedas:kde.org>
This commit is contained in:
deltanedas
2023-09-04 15:11:34 +01:00
committed by GitHub
parent db1ff07821
commit 4b5228e10d
3 changed files with 15 additions and 18 deletions

View File

@@ -542,7 +542,7 @@ public sealed class DisposalUnitSystem : SharedDisposalUnitSystem
if (entry == default || component is not DisposalUnitComponent sDisposals) if (entry == default || component is not DisposalUnitComponent sDisposals)
{ {
component.Engaged = false; component.Engaged = false;
Dirty(component); Dirty(uid, component);
return false; return false;
} }
@@ -550,7 +550,10 @@ public sealed class DisposalUnitSystem : SharedDisposalUnitSystem
_disposalTubeSystem.TryInsert(entry, sDisposals, beforeFlushArgs.Tags); _disposalTubeSystem.TryInsert(entry, sDisposals, beforeFlushArgs.Tags);
component.NextPressurized = GameTiming.CurTime + TimeSpan.FromSeconds(1f / PressurePerSecond); component.NextPressurized = GameTiming.CurTime;
if (!component.DisablePressure)
component.NextPressurized += TimeSpan.FromSeconds(1f / PressurePerSecond);
component.Engaged = false; component.Engaged = false;
// stop queuing NOW // stop queuing NOW
component.NextFlush = null; component.NextFlush = null;
@@ -558,7 +561,7 @@ public sealed class DisposalUnitSystem : SharedDisposalUnitSystem
UpdateVisualState(uid, component, true); UpdateVisualState(uid, component, true);
UpdateInterface(uid, component, component.Powered); UpdateInterface(uid, component, component.Powered);
Dirty(component); Dirty(uid, component);
return true; return true;
} }
@@ -674,7 +677,7 @@ public sealed class DisposalUnitSystem : SharedDisposalUnitSystem
component.RecentlyEjected.Add(toRemove); component.RecentlyEjected.Add(toRemove);
UpdateVisualState(uid, component); UpdateVisualState(uid, component);
Dirty(component); Dirty(uid, component);
} }
public bool CanFlush(EntityUid unit, SharedDisposalUnitComponent component) public bool CanFlush(EntityUid unit, SharedDisposalUnitComponent component)
@@ -689,7 +692,7 @@ public sealed class DisposalUnitSystem : SharedDisposalUnitSystem
component.Engaged = true; component.Engaged = true;
UpdateVisualState(uid, component); UpdateVisualState(uid, component);
UpdateInterface(uid, component, component.Powered); UpdateInterface(uid, component, component.Powered);
Dirty(component); Dirty(uid, component);
if (!CanFlush(uid, component)) if (!CanFlush(uid, component))
return; return;
@@ -713,7 +716,7 @@ public sealed class DisposalUnitSystem : SharedDisposalUnitSystem
UpdateVisualState(uid, component); UpdateVisualState(uid, component);
UpdateInterface(uid, component, component.Powered); UpdateInterface(uid, component, component.Powered);
Dirty(component); Dirty(uid, component);
} }
/// <summary> /// <summary>

View File

@@ -55,7 +55,7 @@ public abstract partial class SharedDisposalUnitComponent : Component
/// Removes the pressure requirement for flushing. /// Removes the pressure requirement for flushing.
/// </summary> /// </summary>
[DataField("disablePressure"), ViewVariables(VVAccess.ReadWrite)] [DataField("disablePressure"), ViewVariables(VVAccess.ReadWrite)]
public bool DisablePressure = false; public bool DisablePressure;
/// <summary> /// <summary>
/// Last time that an entity tried to exit this disposal unit. /// Last time that an entity tried to exit this disposal unit.

View File

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