* Add basic chemical reaction system What it adds: - Reactions defined in yaml with an arbitrary amount of reactants (can be catalysts), products, and effects. What it doesn't add: - Temperature dependent reactions - Metabolism or other medical/health effects * Add many common SS13 chemicals and reactions Added many of the common SS13 medicines and other chemicals, and their chemical reactions. Note that many of them are lacking their effects since we don't have medical yet. * Add ExplosiveReactionEffect Shows how IReactionEffect can be implemented to have effects that occur with a reaction by adding ExplosionReactionEffect and the potassium + water explosion reaction. * Move ReactionSystem logic into SolutionComponent No need for this to be a system currently so the behavior for reaction checking has been moved into SolutionComponent. Now it only checks for reactions when a reagent or solution is added to a solution. Also fixed a bug with SolutionValidReaction incorrectly returning true. * Move explosion logic out of ExplosiveComponent Allows you to create explosions without needing to add an ExplosiveComponent to an entity first. * Add SolutionComponent.SolutionChanged event. Trigger dispenser ui updates with it. This removes the need for SolutionComponent having a reference to the dispenser it's in. Instead the dispenser subscribes to the event and updates it's UI whenever the event is triggered. * Add forgotten checks `SolutionComponent.TryAddReagent` and `SolutionComponent.TryAddSolution` now check to see if `skipReactionCheck` is false before checking for a chemical reaction to avoid unnecessarily checking themselves for a reaction again when `SolutionComponent.PerformReaction` calls either of them. * Change SolutionComponent.SolutionChanged to an Action The arguments for event handler have no use here, and any class that can access SolutionChanged can access the SolutionComponent so it can just be an Action with no arguments instead.
66 lines
2.2 KiB
C#
66 lines
2.2 KiB
C#
using Content.Server.GameObjects.EntitySystems;
|
|
using Robust.Server.Interfaces.GameObjects;
|
|
using Robust.Shared.GameObjects;
|
|
using Robust.Shared.Interfaces.GameObjects;
|
|
using Robust.Shared.Interfaces.Map;
|
|
using Robust.Shared.Interfaces.Random;
|
|
using Robust.Shared.IoC;
|
|
using Robust.Shared.Serialization;
|
|
using Content.Server.Explosions;
|
|
|
|
namespace Content.Server.GameObjects.Components.Explosive
|
|
{
|
|
[RegisterComponent]
|
|
public class ExplosiveComponent : Component, ITimerTrigger, IDestroyAct
|
|
{
|
|
#pragma warning disable 649
|
|
[Dependency] private readonly ITileDefinitionManager _tileDefinitionManager;
|
|
[Dependency] private readonly IMapManager _mapManager;
|
|
[Dependency] private readonly IServerEntityManager _serverEntityManager;
|
|
[Dependency] private readonly IEntitySystemManager _entitySystemManager;
|
|
[Dependency] private readonly IRobustRandom _robustRandom;
|
|
#pragma warning restore 649
|
|
|
|
public override string Name => "Explosive";
|
|
|
|
public int DevastationRange = 0;
|
|
public int HeavyImpactRange = 0;
|
|
public int LightImpactRange = 0;
|
|
public int FlashRange = 0;
|
|
|
|
private bool _beingExploded = false;
|
|
|
|
public override void ExposeData(ObjectSerializer serializer)
|
|
{
|
|
base.ExposeData(serializer);
|
|
|
|
serializer.DataField(ref DevastationRange, "devastationRange", 0);
|
|
serializer.DataField(ref HeavyImpactRange, "heavyImpactRange", 0);
|
|
serializer.DataField(ref LightImpactRange, "lightImpactRange", 0);
|
|
serializer.DataField(ref FlashRange, "flashRange", 0);
|
|
}
|
|
|
|
public bool Explosion()
|
|
{
|
|
//Prevent adjacent explosives from infinitely blowing each other up.
|
|
if (_beingExploded) return true;
|
|
_beingExploded = true;
|
|
|
|
ExplosionHelper.SpawnExplosion(Owner.Transform.GridPosition, DevastationRange, HeavyImpactRange, LightImpactRange, FlashRange);
|
|
|
|
Owner.Delete();
|
|
return true;
|
|
}
|
|
|
|
bool ITimerTrigger.Trigger(TimerTriggerEventArgs eventArgs)
|
|
{
|
|
return Explosion();
|
|
}
|
|
|
|
void IDestroyAct.OnDestroy(DestructionEventArgs eventArgs)
|
|
{
|
|
Explosion();
|
|
}
|
|
}
|
|
}
|