Refactors radiation (#2009)

* Work on refactoring radiation.

* mmmm grayons

* fixes

* Now you can specify whether the pulse will decay or not

* whoops

* Move IRadiationAct to shared, make DamageableComponent implement it instead and add metallic resistances to walls

* General improvements, send draw and decay with state. Rename DPS to RadsPerSecond

* E N T I T Y  C O O R D I N A T E S

* Entity coordinates goood

* Remove unused using statements

* resistances: metallicResistances

* - type: Breakable moment

Co-authored-by: DrSmugleaf <DrSmugleaf@users.noreply.github.com>
This commit is contained in:
Víctor Aguilera Puerto
2020-09-21 01:49:40 +02:00
committed by GitHub
parent 2927ab5cd1
commit 6ec2939f15
37 changed files with 250 additions and 123 deletions

View File

@@ -4,6 +4,7 @@ using System.Collections.Generic;
using Content.Shared.Damage;
using Content.Shared.Damage.DamageContainer;
using Content.Shared.Damage.ResistanceSet;
using Content.Shared.Interfaces.GameObjects.Components;
using Robust.Shared.GameObjects;
using Robust.Shared.Interfaces.GameObjects;
using Robust.Shared.IoC;
@@ -19,7 +20,7 @@ namespace Content.Shared.GameObjects.Components.Damage
/// </summary>
[RegisterComponent]
[ComponentReference(typeof(IDamageableComponent))]
public class DamageableComponent : Component, IDamageableComponent
public class DamageableComponent : Component, IDamageableComponent, IRadiationAct
{
[Dependency] private readonly IPrototypeManager _prototypeManager = default!;
@@ -388,5 +389,12 @@ namespace Content.Shared.GameObjects.Components.Damage
Dirty();
}
public void RadiationAct(float frameTime, SharedRadiationPulseComponent radiation)
{
var totalDamage = Math.Max((int)(frameTime * radiation.RadsPerSecond), 1);
ChangeDamage(DamageType.Radiation, totalDamage, false, radiation.Owner);
}
}
}

View File

@@ -9,30 +9,38 @@ namespace Content.Shared.GameObjects.Components
public override string Name => "RadiationPulse";
public override uint? NetID => ContentNetIDs.RADIATION_PULSE;
public virtual float RadsPerSecond { get; set; }
/// <summary>
/// Radius of the pulse from its position
/// </summary>
public float Range => _range;
private float _range;
public virtual float Range { get; set; }
public override void ExposeData(ObjectSerializer serializer)
{
base.ExposeData(serializer);
serializer.DataField(ref _range, "range", 5.0f);
}
public virtual bool Decay { get; set; }
public virtual bool Draw { get; set; }
public virtual TimeSpan EndTime { get; }
}
/// <summary>
/// For syncing the pulse's lifespan between client and server for the overlay
/// </summary>
[Serializable, NetSerializable]
public sealed class RadiationPulseMessage : ComponentState
public class RadiationPulseState : ComponentState
{
public TimeSpan EndTime { get; }
public readonly float RadsPerSecond;
public readonly float Range;
public readonly bool Draw;
public readonly bool Decay;
public readonly TimeSpan EndTime;
public RadiationPulseMessage(TimeSpan endTime) : base(ContentNetIDs.RADIATION_PULSE)
public RadiationPulseState(float radsPerSecond, float range, bool draw, bool decay, TimeSpan endTime) : base(ContentNetIDs.RADIATION_PULSE)
{
RadsPerSecond = radsPerSecond;
Range = range;
Draw = draw;
Decay = decay;
EndTime = endTime;
}
}
}
}