Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Makes snap pop explosions unable to throw away items #31617

Open
wants to merge 4 commits into
base: master
Choose a base branch
from
Open
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
Original file line number Diff line number Diff line change
Expand Up @@ -664,6 +664,11 @@ struct ExplosionData
/// </summary>
private readonly bool _canCreateVacuum;

/// <summary>
/// Whether this explosion can throw away items.
/// </summary>
private readonly bool _canThrowItems;

private readonly IEntityManager _entMan;
private readonly ExplosionSystem _system;

Expand All @@ -685,6 +690,7 @@ public Explosion(ExplosionSystem system,
float tileBreakScale,
int maxTileBreak,
bool canCreateVacuum,
bool canThrowItems,
IEntityManager entMan,
IMapManager mapMan,
EntityUid visualEnt,
Expand All @@ -701,6 +707,7 @@ public Explosion(ExplosionSystem system,
_tileBreakScale = tileBreakScale;
_maxTileBreak = maxTileBreak;
_canCreateVacuum = canCreateVacuum;
_canThrowItems = canThrowItems;
_entMan = entMan;

_xformQuery = entMan.GetEntityQuery<TransformComponent>();
Expand Down Expand Up @@ -760,7 +767,7 @@ private bool TryGetNextTileEnumerator()
_currentDamage = ExplosionType.DamagePerIntensity * _currentIntensity;

// only throw if either the explosion is small, or if this is the outer ring of a large explosion.
var doThrow = Area < _system.ThrowLimit || CurrentIteration > _tileSetIntensity.Count - 6;
var doThrow = _canThrowItems && (Area < _system.ThrowLimit || CurrentIteration > _tileSetIntensity.Count - 6);
_currentThrowForce = doThrow ? 10 * MathF.Sqrt(_currentIntensity) : 0;

// for each grid/space tile set
Expand Down Expand Up @@ -916,5 +923,6 @@ public sealed class QueuedExplosion
public float TotalIntensity, Slope, MaxTileIntensity, TileBreakScale;
public int MaxTileBreak;
public bool CanCreateVacuum;
public bool CanThrowItems;
public EntityUid? Cause; // The entity that exploded, for logging purposes.
}
7 changes: 6 additions & 1 deletion Content.Server/Explosion/EntitySystems/ExplosionSystem.cs
Original file line number Diff line number Diff line change
Expand Up @@ -168,6 +168,7 @@ public override void TriggerExplosive(EntityUid uid, ExplosiveComponent? explosi
explosive.TileBreakScale,
explosive.MaxTileBreak,
explosive.CanCreateVacuum,
explosive.CanThrowItems,
user);

if (explosive.DeleteAfterExplosion ?? delete)
Expand Down Expand Up @@ -237,6 +238,7 @@ public void QueueExplosion(EntityUid uid,
float tileBreakScale = 1f,
int maxTileBreak = int.MaxValue,
bool canCreateVacuum = true,
bool canThrowItems = true,
EntityUid? user = null,
bool addLog = true)
{
Expand All @@ -246,7 +248,7 @@ public void QueueExplosion(EntityUid uid,

var posFound = _transformSystem.TryGetMapOrGridCoordinates(uid, out var gridPos, pos);

QueueExplosion(mapPos, typeId, totalIntensity, slope, maxTileIntensity, uid, tileBreakScale, maxTileBreak, canCreateVacuum, addLog: false);
QueueExplosion(mapPos, typeId, totalIntensity, slope, maxTileIntensity, uid, tileBreakScale, maxTileBreak, canCreateVacuum, canThrowItems, addLog: false);

if (!addLog)
return;
Expand Down Expand Up @@ -278,6 +280,7 @@ public void QueueExplosion(MapCoordinates epicenter,
float tileBreakScale = 1f,
int maxTileBreak = int.MaxValue,
bool canCreateVacuum = true,
bool canThrowItems = true,
bool addLog = true)
{
if (totalIntensity <= 0 || slope <= 0)
Expand Down Expand Up @@ -319,6 +322,7 @@ public void QueueExplosion(MapCoordinates epicenter,
TileBreakScale = tileBreakScale,
MaxTileBreak = maxTileBreak,
CanCreateVacuum = canCreateVacuum,
CanThrowItems = canThrowItems,
Cause = cause
};
_explosionQueue.Enqueue(boom);
Expand Down Expand Up @@ -386,6 +390,7 @@ public void QueueExplosion(MapCoordinates epicenter,
queued.TileBreakScale,
queued.MaxTileBreak,
queued.CanCreateVacuum,
queued.CanThrowItems,
EntityManager,
_mapManager,
visualEnt,
Expand Down
7 changes: 7 additions & 0 deletions Content.Shared/Explosion/Components/ExplosiveComponent.cs
Original file line number Diff line number Diff line change
Expand Up @@ -65,6 +65,13 @@ public sealed partial class ExplosiveComponent : Component
[DataField]
public bool CanCreateVacuum = true;

/// <summary>
/// Whether this explosive can throw away items.
/// </summary>
[ViewVariables(VVAccess.ReadWrite)]
[DataField("canThrowItems")]
public bool CanThrowItems = true;

/// <summary>
/// An override for whether or not the entity should be deleted after it explodes.
/// If null, the system calling the explode method handles it.
Expand Down
1 change: 1 addition & 0 deletions Resources/Prototypes/Entities/Objects/Fun/snap_pops.yml
Original file line number Diff line number Diff line change
Expand Up @@ -33,6 +33,7 @@
maxIntensity: 0.01
intensitySlope: 1
totalIntensity: 0.01
canThrowItems: false

- type: entity
parent: BaseStorageItem
Expand Down
Loading