Files
tbd-station-14/Content.Server/GameObjects/Components/Damage/DestructibleComponent.cs
clusterfack 37df61113e Species Component (#130)
* Fix this
fug
oksure
Creates the initial species component, damage states, and threshold templates and hooks them into the damageable component

* More rebase fixes

* test

* Pre future rebase

* Please

* Lol

* Lol2

* SHADERS

* Update Engine

* yml file

* Fix an initialization issue, injects dependencies

* Fix error in loading shaders

* Makes a master character ui controller component added upon client attachment to entity and remove upon client detachment from entity

* Fixes just about everytrhing

* Address PJB's comments

* geeze

* Make overlays work in worldspace instead of screen space and not cover user interfaces

* update submodule
2018-12-13 14:47:18 +01:00

66 lines
2.0 KiB
C#

using System;
using System.Collections.Generic;
using SS14.Shared.GameObjects;
using SS14.Shared.Log;
using SS14.Shared.Utility;
using YamlDotNet.RepresentationModel;
using Content.Server.Interfaces;
using Content.Shared.GameObjects;
using SS14.Shared.Serialization;
using SS14.Shared.ViewVariables;
namespace Content.Server.GameObjects
{
/// <summary>
/// Deletes the entity once a certain damage threshold has been reached.
/// </summary>
public class DestructibleComponent : Component, IOnDamageBehavior
{
/// <inheritdoc />
public override string Name => "Destructible";
/// <inheritdoc />
public override uint? NetID => ContentNetIDs.DESTRUCTIBLE;
/// <summary>
/// Damage threshold calculated from the values
/// given in the prototype declaration.
/// </summary>
[ViewVariables]
public DamageThreshold Threshold { get; private set; }
public override void ExposeData(ObjectSerializer serializer)
{
base.ExposeData(serializer);
// TODO: Writing
if (serializer.Reading)
{
DamageType damageType = DamageType.Total;
int damageValue = 0;
serializer.DataReadFunction("thresholdtype", DamageType.Total, type => damageType = type);
serializer.DataReadFunction("thresholdvalue", 0, val => damageValue = val);
Threshold = new DamageThreshold(damageType, damageValue, ThresholdType.Destruction);
}
}
/// <inheritdoc />
public List<DamageThreshold> GetAllDamageThresholds()
{
return new List<DamageThreshold>() { Threshold };
}
/// <inheritdoc />
public void OnDamageThresholdPassed(object obj, DamageThresholdPassedEventArgs e)
{
if (e.Passed && e.DamageThreshold == Threshold)
{
Owner.EntityManager.DeleteEntity(Owner);
}
}
}
}