sourceSolution.RemoveAllSolution();
- _triggerSystem.Trigger(source);
+ _triggerSystem.Trigger(source, user);
}
}
}
{
RaiseLocalEvent(uid, new DamageThresholdReached(component, threshold), true);
- threshold.Execute(uid, this, EntityManager);
+ threshold.Execute(uid, this, EntityManager, args.Origin);
}
// if destruction behavior (or some other deletion effect) occurred, don't run other triggers.
[DataField("node")]
public string Node { get; private set; } = string.Empty;
- public void Execute(EntityUid owner, DestructibleSystem system)
+ public void Execute(EntityUid owner, DestructibleSystem system, EntityUid? cause = null)
{
if (string.IsNullOrEmpty(Node) || !system.EntityManager.TryGetComponent(owner, out ConstructionComponent? construction))
return;
return (Acts & act) != 0;
}
- public void Execute(EntityUid owner, DestructibleSystem system)
+ public void Execute(EntityUid owner, DestructibleSystem system, EntityUid? cause = null)
{
if (HasAct(ThresholdActs.Breakage))
{
[DataDefinition]
public sealed class DumpCanisterBehavior : IThresholdBehavior
{
- public void Execute(EntityUid owner, DestructibleSystem system)
+ public void Execute(EntityUid owner, DestructibleSystem system, EntityUid? cause = null)
{
system.EntityManager.EntitySysManager.GetEntitySystem<GasCanisterSystem>().PurgeContents(owner);
}
[DataField("offset")]
public float Offset { get; set; } = 0.5f;
- public void Execute(EntityUid owner, DestructibleSystem system)
+ public void Execute(EntityUid owner, DestructibleSystem system, EntityUid? cause = null)
{
if (!system.EntityManager.TryGetComponent<VendingMachineRestockComponent>(owner, out var packagecomp) ||
!system.EntityManager.TryGetComponent<TransformComponent>(owner, out var xform))
[DataField("max")]
public int Max = 3;
- public void Execute(EntityUid owner, DestructibleSystem system)
+ public void Execute(EntityUid owner, DestructibleSystem system, EntityUid? cause = null)
{
if (!system.EntityManager.TryGetComponent<VendingMachineComponent>(owner, out var vendingcomp) ||
!system.EntityManager.TryGetComponent<TransformComponent>(owner, out var xform))
[DataDefinition]
public sealed class EmptyAllContainersBehaviour : IThresholdBehavior
{
- public void Execute(EntityUid owner, DestructibleSystem system)
+ public void Execute(EntityUid owner, DestructibleSystem system, EntityUid? cause = null)
{
if (!system.EntityManager.TryGetComponent<ContainerManagerComponent>(owner, out var containerManager))
return;
[DataDefinition]
public sealed class ExplodeBehavior : IThresholdBehavior
{
- public void Execute(EntityUid owner, DestructibleSystem system)
+ public void Execute(EntityUid owner, DestructibleSystem system, EntityUid? cause = null)
{
- system.ExplosionSystem.TriggerExplosive(owner);
+ system.ExplosionSystem.TriggerExplosive(owner, user:cause);
}
}
}
{
[DataField("recursive")] private bool _recursive = true;
- public void Execute(EntityUid owner, DestructibleSystem system)
+ public void Execute(EntityUid owner, DestructibleSystem system, EntityUid? cause = null)
{
if (system.EntityManager.TryGetComponent(owner, out BodyComponent? body))
{
/// An instance of <see cref="DestructibleSystem"/> to pull dependencies
/// and other systems from.
/// </param>
- void Execute(EntityUid owner, DestructibleSystem system);
+ /// <param name="cause">The entity that caused this behavior.</param>
+ void Execute(EntityUid owner, DestructibleSystem system, EntityUid? cause = null);
}
}
/// </summary>
[DataField("sound", required: true)] public SoundSpecifier Sound { get; set; } = default!;
- public void Execute(EntityUid owner, DestructibleSystem system)
+ public void Execute(EntityUid owner, DestructibleSystem system, EntityUid? cause = null)
{
var pos = system.EntityManager.GetComponent<TransformComponent>(owner).Coordinates;
SoundSystem.Play(Sound.GetSound(), Filter.Pvs(pos), pos, AudioHelpers.WithVariation(0.125f));
[DataField("solution", required: true)]
public string Solution = default!;
- public void Execute(EntityUid owner, DestructibleSystem system)
+ public void Execute(EntityUid owner, DestructibleSystem system, EntityUid? cause = null)
{
if (system.SolutionContainerSystem.TryGetSolution(owner, Solution, out var explodingSolution)
&& system.EntityManager.TryGetComponent(owner, out ExplosiveComponent? explosiveComponent))
// Don't delete the object here - let other processes like physical damage from the
// explosion clean up the exploding object(s)
var explosiveTotalIntensity = explosiveComponent.TotalIntensity * explosionScaleFactor;
- system.ExplosionSystem.TriggerExplosive(owner, explosiveComponent, false, explosiveTotalIntensity);
+ system.ExplosionSystem.TriggerExplosive(owner, explosiveComponent, false, explosiveTotalIntensity, user:cause);
}
}
}
[DataField("offset")]
public float Offset { get; set; } = 0.5f;
- public void Execute(EntityUid owner, DestructibleSystem system)
+ public void Execute(EntityUid owner, DestructibleSystem system, EntityUid? cause = null)
{
var position = system.EntityManager.GetComponent<TransformComponent>(owner).MapPosition;
/// </summary>
/// <param name="owner">Entity on which behavior is executed</param>
/// <param name="system">system calling the behavior</param>
- public void Execute(EntityUid owner, DestructibleSystem system)
+ /// <param name="cause"></param>
+ public void Execute(EntityUid owner, DestructibleSystem system, EntityUid? cause = null)
{
var solutionContainerSystem = EntitySystem.Get<SolutionContainerSystem>();
var spillableSystem = EntitySystem.Get<SpillableSystem>();
[DataDefinition]
public sealed class TriggerBehavior : IThresholdBehavior
{
- public void Execute(EntityUid owner, DestructibleSystem system)
+ public void Execute(EntityUid owner, DestructibleSystem system, EntityUid? cause = null)
{
- system.TriggerSystem.Trigger(owner);
+ system.TriggerSystem.Trigger(owner, cause);
}
}
/// An instance of <see cref="DestructibleSystem"/> to get dependency and
/// system references from, if relevant.
/// </param>
- public void Execute(EntityUid owner, DestructibleSystem system, IEntityManager entityManager)
+ /// <param name="entityManager"></param>
+ /// <param name="cause"></param>
+ public void Execute(EntityUid owner, DestructibleSystem system, IEntityManager entityManager, EntityUid? cause)
{
Triggered = true;
if (!entityManager.EntityExists(owner))
return;
- behavior.Execute(owner, system);
+ behavior.Execute(owner, system, cause);
}
}
}
using System.Linq;
+using Content.Server.Explosion.Components;
+using Content.Server.Mind.Components;
using Content.Shared.CCVar;
using Content.Shared.Damage;
+using Content.Shared.Database;
using Content.Shared.Explosion;
+using Content.Shared.FixedPoint;
using Content.Shared.Maps;
using Content.Shared.Physics;
using Content.Shared.Spawners.Components;
{
// no damage-dict multiplication required.
_damageableSystem.TryChangeDamage(uid, damage, ignoreResistances: true, damageable: damageable);
+ if (HasComp<MindComponent>(uid) || HasComp<ExplosiveComponent>(uid))
+ {
+ var damageStr = string.Join(", ", damage.DamageDict.Select(entry => $"{entry.Key}: {entry.Value}"));
+ _adminLogger.Add(LogType.Explosion, LogImpact.Medium,
+ $"Explosion caused {{{damageStr}}} to {ToPrettyString(uid):target} at {Transform(uid).Coordinates}");
+ }
}
else
{
- _damageableSystem.TryChangeDamage(uid, damage * ev.DamageCoefficient, ignoreResistances: true, damageable: damageable);
+ var appliedDamage = damage * ev.DamageCoefficient;
+ _damageableSystem.TryChangeDamage(uid, appliedDamage, ignoreResistances: true, damageable: damageable);
+ if (HasComp<MindComponent>(uid) || HasComp<ExplosiveComponent>(uid))
+ {
+ var damageStr = string.Join(", ", appliedDamage.DamageDict.Select(entry => $"{entry.Key}: {entry.Value}"));
+ _adminLogger.Add(LogType.Explosion, LogImpact.Medium,
+ $"Explosion caused {{{damageStr}}} to {ToPrettyString(uid):target} at {Transform(uid).Coordinates}");
+ }
}
}
int maxTileBreak = int.MaxValue,
bool canCreateVacuum = true,
EntityUid? user = null,
- bool addLog = false)
+ bool addLog = true)
{
- var pos = Transform(uid).MapPosition;
+ var pos = Transform(uid);
- QueueExplosion(pos, typeId, totalIntensity, slope, maxTileIntensity, tileBreakScale, maxTileBreak, canCreateVacuum, addLog: false);
+ QueueExplosion(pos.MapPosition, typeId, totalIntensity, slope, maxTileIntensity, tileBreakScale, maxTileBreak, canCreateVacuum, addLog: false);
if (!addLog)
return;
if (user == null)
_adminLogger.Add(LogType.Explosion, LogImpact.High,
- $"{ToPrettyString(uid):entity} exploded at {pos:coordinates} with intensity {totalIntensity} slope {slope}");
+ $"{ToPrettyString(uid):entity} exploded ({typeId}) at {pos.Coordinates:coordinates} with intensity {totalIntensity} slope {slope}");
else
_adminLogger.Add(LogType.Explosion, LogImpact.High,
- $"{ToPrettyString(user.Value):user} caused {ToPrettyString(uid):entity} to explode at {pos:coordinates} with intensity {totalIntensity} slope {slope}");
+ $"{ToPrettyString(user.Value):user} caused {ToPrettyString(uid):entity} to explode ({typeId}) at {pos.Coordinates:coordinates} with intensity {totalIntensity} slope {slope}");
}
/// <summary>
float tileBreakScale = 1f,
int maxTileBreak = int.MaxValue,
bool canCreateVacuum = true,
- bool addLog = false)
+ bool addLog = true)
{
if (totalIntensity <= 0 || slope <= 0)
return;
}
if (addLog) // dont log if already created a separate, more detailed, log.
- _adminLogger.Add(LogType.Explosion, LogImpact.High, $"Explosion spawned at {epicenter:coordinates} with intensity {totalIntensity} slope {slope}");
+ _adminLogger.Add(LogType.Explosion, LogImpact.High, $"Explosion ({typeId}) spawned at {epicenter:coordinates} with intensity {totalIntensity} slope {slope}");
_explosionQueue.Enqueue(() => SpawnExplosion(epicenter, type, totalIntensity,
slope, maxTileIntensity, tileBreakScale, maxTileBreak, canCreateVacuum));
public sealed partial class TriggerSystem
{
[Dependency] private readonly SignalLinkerSystem _signalSystem = default!;
-
+
private void InitializeSignal()
{
SubscribeLocalEvent<TriggerOnSignalComponent,SignalReceivedEvent>(OnSignalReceived);
if (args.Port != component.Port)
return;
- Trigger(uid);
+ Trigger(uid, args.Trigger);
}
private void OnInit(EntityUid uid, TriggerOnSignalComponent component, ComponentInit args)
{
{
_adminLogger.Add(LogType.Trigger, LogImpact.High,
$"A voice-trigger on {ToPrettyString(uid):entity} was triggered by {ToPrettyString(args.Source):speaker} speaking the key-phrase {component.KeyPhrase}.");
- Trigger(uid);
+ Trigger(uid, args.Source);
}
}
public sealed class BeingMicrowavedEvent : HandledEntityEventArgs
{
public EntityUid Microwave;
+ public EntityUid? User;
- public BeingMicrowavedEvent(EntityUid microwave)
+ public BeingMicrowavedEvent(EntityUid microwave, EntityUid? user)
{
Microwave = microwave;
+ User = user;
}
}
}
SubscribeLocalEvent<MicrowaveComponent, RefreshPartsEvent>(OnRefreshParts);
SubscribeLocalEvent<MicrowaveComponent, UpgradeExamineEvent>(OnUpgradeExamine);
- SubscribeLocalEvent<MicrowaveComponent, MicrowaveStartCookMessage>((u,c,_) => Wzhzhzh(u,c));
+ SubscribeLocalEvent<MicrowaveComponent, MicrowaveStartCookMessage>((u,c,m) => Wzhzhzh(u,c,m.Session.AttachedEntity));
SubscribeLocalEvent<MicrowaveComponent, MicrowaveEjectMessage>(OnEjectMessage);
SubscribeLocalEvent<MicrowaveComponent, MicrowaveEjectSolidIndexedMessage>(OnEjectIndex);
SubscribeLocalEvent<MicrowaveComponent, MicrowaveSelectCookTimeMessage>(OnSelectTime);
_audio.PlayPvs(component.ClickSound, uid, AudioParams.Default.WithVolume(-2));
component.CurrentCookTimerTime = 10;
- Wzhzhzh(uid, component);
+ Wzhzhzh(uid, component, args.Victim);
UpdateUserInterfaceState(uid, component);
}
/// It does not make a "wzhzhzh" sound, it makes a "mmmmmmmm" sound!
/// -emo
/// </remarks>
- public void Wzhzhzh(EntityUid uid, MicrowaveComponent component)
+ public void Wzhzhzh(EntityUid uid, MicrowaveComponent component, EntityUid? user)
{
if (!HasContents(component) || HasComp<ActiveMicrowaveComponent>(uid))
return;
foreach (var item in component.Storage.ContainedEntities)
{
// special behavior when being microwaved ;)
- var ev = new BeingMicrowavedEvent(uid);
+ var ev = new BeingMicrowavedEvent(uid, user);
RaiseLocalEvent(item, ev);
if (ev.Handled)
public sealed class SignalReceivedEvent : EntityEventArgs
{
public readonly string Port;
+ public readonly EntityUid? Trigger;
- public SignalReceivedEvent(string port)
+ public SignalReceivedEvent(string port, EntityUid? trigger)
{
Port = port;
+ Trigger = trigger;
}
}
}
return;
foreach (var receiver in receivers)
- RaiseLocalEvent(receiver.Uid, new SignalReceivedEvent(receiver.Port), false);
+ RaiseLocalEvent(receiver.Uid, new SignalReceivedEvent(receiver.Port, uid), false);
}
private void OnTransmitterStartup(EntityUid uid, SignalTransmitterComponent transmitter, ComponentStartup args)
args.Handled = true;
// What the fuck are you doing???
- Explode(uid, component);
+ Explode(uid, component, args.User);
}
private void OnChargeChanged(EntityUid uid, PowerCellComponent component, ChargeChangedEvent args)
{
if (component.IsRigged)
{
- Explode(uid);
+ Explode(uid, cause: null);
return;
}
}
}
- private void Explode(EntityUid uid, BatteryComponent? battery = null)
+ private void Explode(EntityUid uid, BatteryComponent? battery = null, EntityUid? cause = null)
{
- _adminLogger.Add(LogType.Explosion, LogImpact.High, $"Sabotaged power cell {ToPrettyString(uid)} is exploding");
-
if (!Resolve(uid, ref battery))
return;
- var radius = MathF.Min(5, MathF.Ceiling(MathF.Sqrt(battery.CurrentCharge) / 30));
+ var radius = MathF.Min(5, MathF.Sqrt(battery.CurrentCharge) / 9);
- _explosionSystem.TriggerExplosive(uid, radius: radius);
+ _explosionSystem.TriggerExplosive(uid, radius: radius, user:cause);
QueueDel(uid);
}
- type: PowerCell
- type: Explosive
explosionType: Default
+ maxIntensity: 200
+ intensitySlope: 1.5
- type: Sprite
sprite: Objects/Power/power_cells.rsi
netsync: false