Remove IRadiationAct (#7757)
* Move radiation collector to ECS * Damagable system * Remove IRadiationAct * Add small helper field * Update Content.Server/Radiation/Systems/RadiationSystem.cs Co-authored-by: Leon Friedrich <60421075+ElectroJr@users.noreply.github.com> * Delete comment * Fixed total rads Co-authored-by: Leon Friedrich <60421075+ElectroJr@users.noreply.github.com>
This commit is contained in:
@@ -1,17 +1,9 @@
|
||||
using System;
|
||||
using System.Collections.Generic;
|
||||
using Content.Shared.Acts;
|
||||
using Content.Shared.Damage.Prototypes;
|
||||
using Content.Shared.FixedPoint;
|
||||
using Content.Shared.Radiation;
|
||||
using Robust.Shared.Analyzers;
|
||||
using Robust.Shared.GameObjects;
|
||||
using Robust.Shared.GameStates;
|
||||
using Robust.Shared.Serialization;
|
||||
using Robust.Shared.Serialization.Manager.Attributes;
|
||||
using Robust.Shared.Serialization.TypeSerializers.Implementations.Custom.Prototype;
|
||||
using Robust.Shared.Serialization.TypeSerializers.Implementations.Custom.Prototype.List;
|
||||
using Robust.Shared.ViewVariables;
|
||||
|
||||
namespace Content.Shared.Damage
|
||||
{
|
||||
@@ -25,7 +17,7 @@ namespace Content.Shared.Damage
|
||||
[RegisterComponent]
|
||||
[NetworkedComponent()]
|
||||
[Friend(typeof(DamageableSystem))]
|
||||
public sealed class DamageableComponent : Component, IRadiationAct
|
||||
public sealed class DamageableComponent : Component
|
||||
{
|
||||
/// <summary>
|
||||
/// This <see cref="DamageContainerPrototype"/> specifies what damage types are supported by this component.
|
||||
@@ -77,21 +69,6 @@ namespace Content.Shared.Damage
|
||||
[ViewVariables]
|
||||
[DataField("explosionDamageTypes", customTypeSerializer: typeof(PrototypeIdListSerializer<DamageTypePrototype>))]
|
||||
public List<string> ExplosionDamageTypeIDs = new() { "Piercing", "Heat" };
|
||||
|
||||
// TODO RADIATION Remove this.
|
||||
void IRadiationAct.RadiationAct(float frameTime, SharedRadiationPulseComponent radiation)
|
||||
{
|
||||
var damageValue = FixedPoint2.New(MathF.Max((frameTime * radiation.RadsPerSecond), 1));
|
||||
|
||||
// Radiation should really just be a damage group instead of a list of types.
|
||||
DamageSpecifier damage = new();
|
||||
foreach (var typeID in RadiationDamageTypeIDs)
|
||||
{
|
||||
damage.DamageDict.Add(typeID, damageValue);
|
||||
}
|
||||
|
||||
EntitySystem.Get<DamageableSystem>().TryChangeDamage(Owner, damage);
|
||||
}
|
||||
}
|
||||
|
||||
[Serializable, NetSerializable]
|
||||
|
||||
@@ -2,6 +2,7 @@ using System.Linq;
|
||||
using Content.Shared.Damage.Prototypes;
|
||||
using Content.Shared.FixedPoint;
|
||||
using Content.Shared.Inventory;
|
||||
using Content.Shared.Radiation.Events;
|
||||
using Robust.Shared.GameObjects;
|
||||
using Robust.Shared.GameStates;
|
||||
using Robust.Shared.IoC;
|
||||
@@ -19,6 +20,7 @@ namespace Content.Shared.Damage
|
||||
SubscribeLocalEvent<DamageableComponent, ComponentInit>(DamageableInit);
|
||||
SubscribeLocalEvent<DamageableComponent, ComponentHandleState>(DamageableHandleState);
|
||||
SubscribeLocalEvent<DamageableComponent, ComponentGetState>(DamageableGetState);
|
||||
SubscribeLocalEvent<DamageableComponent, OnIrradiatedEvent>(OnIrradiated);
|
||||
}
|
||||
|
||||
/// <summary>
|
||||
@@ -195,12 +197,26 @@ namespace Content.Shared.Damage
|
||||
|
||||
Dirty(comp);
|
||||
}
|
||||
|
||||
|
||||
private void DamageableGetState(EntityUid uid, DamageableComponent component, ref ComponentGetState args)
|
||||
{
|
||||
args.State = new DamageableComponentState(component.Damage.DamageDict, component.DamageModifierSetId);
|
||||
}
|
||||
|
||||
private void OnIrradiated(EntityUid uid, DamageableComponent component, OnIrradiatedEvent args)
|
||||
{
|
||||
var damageValue = FixedPoint2.New(args.TotalRads);
|
||||
|
||||
// Radiation should really just be a damage group instead of a list of types.
|
||||
DamageSpecifier damage = new();
|
||||
foreach (var typeId in component.RadiationDamageTypeIDs)
|
||||
{
|
||||
damage.DamageDict.Add(typeId, damageValue);
|
||||
}
|
||||
|
||||
TryChangeDamage(uid, damage);
|
||||
}
|
||||
|
||||
private void DamageableHandleState(EntityUid uid, DamageableComponent component, ref ComponentHandleState args)
|
||||
{
|
||||
if (args.Current is not DamageableComponentState state)
|
||||
|
||||
Reference in New Issue
Block a user