Destructible component rework (#157)
* Walls are destructible now * Added girders that spawn after wall’s destruction * Girders drop metal sheet on destruction
This commit is contained in:
committed by
Pieter-Jan Briers
parent
9a224398d3
commit
4a5168f14c
@@ -45,6 +45,7 @@ using Content.Shared.GameObjects.Components.Mobs;
|
||||
using Content.Shared.Interfaces;
|
||||
using SS14.Server.Interfaces.ServerStatus;
|
||||
using SS14.Shared.Timing;
|
||||
using Content.Server.GameObjects.Components.Destructible;
|
||||
|
||||
namespace Content.Server
|
||||
{
|
||||
|
||||
@@ -9,7 +9,7 @@ using Content.Shared.GameObjects;
|
||||
using SS14.Shared.Serialization;
|
||||
using SS14.Shared.ViewVariables;
|
||||
|
||||
namespace Content.Server.GameObjects
|
||||
namespace Content.Server.GameObjects.Components.Destructible
|
||||
{
|
||||
/// <summary>
|
||||
/// Deletes the entity once a certain damage threshold has been reached.
|
||||
@@ -19,9 +19,6 @@ namespace Content.Server.GameObjects
|
||||
/// <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.
|
||||
@@ -29,35 +26,35 @@ namespace Content.Server.GameObjects
|
||||
[ViewVariables]
|
||||
public DamageThreshold Threshold { get; private set; }
|
||||
|
||||
public DamageType damageType = DamageType.Total;
|
||||
public int damageValue = 0;
|
||||
public string spawnOnDestroy = "SteelSheet";
|
||||
public bool destroyed = false;
|
||||
|
||||
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);
|
||||
}
|
||||
serializer.DataField(ref damageValue, "thresholdvalue", 100);
|
||||
serializer.DataField(ref damageType, "thresholdtype", DamageType.Total);
|
||||
serializer.DataField(ref spawnOnDestroy, "spawnondestroy", "SteelSheet");
|
||||
}
|
||||
|
||||
/// <inheritdoc />
|
||||
public List<DamageThreshold> GetAllDamageThresholds()
|
||||
List<DamageThreshold> IOnDamageBehavior.GetAllDamageThresholds()
|
||||
{
|
||||
Threshold = new DamageThreshold(damageType, damageValue, ThresholdType.Destruction);
|
||||
return new List<DamageThreshold>() { Threshold };
|
||||
}
|
||||
|
||||
/// <inheritdoc />
|
||||
public void OnDamageThresholdPassed(object obj, DamageThresholdPassedEventArgs e)
|
||||
void IOnDamageBehavior.OnDamageThresholdPassed(object obj, DamageThresholdPassedEventArgs e)
|
||||
{
|
||||
if (e.Passed && e.DamageThreshold == Threshold)
|
||||
if (e.Passed && e.DamageThreshold == Threshold && destroyed == false)
|
||||
{
|
||||
destroyed = true;
|
||||
var wreck = Owner.EntityManager.SpawnEntity(spawnOnDestroy);
|
||||
wreck.Transform.GridPosition = Owner.Transform.GridPosition;
|
||||
Owner.EntityManager.DeleteEntity(Owner);
|
||||
}
|
||||
}
|
||||
|
||||
@@ -34,19 +34,19 @@ entities:
|
||||
pos: 4.5,-0.5
|
||||
rot: -1.570796 rad
|
||||
type: Transform
|
||||
- type: wall
|
||||
- type: girder
|
||||
components:
|
||||
- grid: 0
|
||||
pos: -7,6
|
||||
rot: -1.570796 rad
|
||||
type: Transform
|
||||
- type: wall
|
||||
- type: girder
|
||||
components:
|
||||
- grid: 0
|
||||
pos: -7,-4
|
||||
rot: -1.570796 rad
|
||||
type: Transform
|
||||
- type: wall
|
||||
- type: girder
|
||||
components:
|
||||
- grid: 0
|
||||
pos: -7,-3
|
||||
@@ -178,13 +178,13 @@ entities:
|
||||
pos: -7,-6
|
||||
rot: -1.570796 rad
|
||||
type: Transform
|
||||
- type: wall
|
||||
- type: girder
|
||||
components:
|
||||
- grid: 0
|
||||
pos: -4,-6
|
||||
rot: -1.570796 rad
|
||||
type: Transform
|
||||
- type: wall
|
||||
- type: girder
|
||||
components:
|
||||
- grid: 0
|
||||
pos: -4,-5
|
||||
|
||||
22
Resources/Prototypes/Entities/girder.yml
Normal file
22
Resources/Prototypes/Entities/girder.yml
Normal file
@@ -0,0 +1,22 @@
|
||||
- type: entity
|
||||
id: girder
|
||||
name: Girder
|
||||
components:
|
||||
- type: Clickable
|
||||
- type: Sprite
|
||||
texture: Buildings/wall_girder.png
|
||||
- type: Icon
|
||||
texture: Buildings/wall_girder.png
|
||||
|
||||
- type: BoundingBox
|
||||
- type: Collidable
|
||||
- type: Damageable
|
||||
- type: Destructible
|
||||
thresholdvalue: 50
|
||||
spawnondestroy: SteelSheet1
|
||||
- type: SnapGrid
|
||||
offset: Edge
|
||||
|
||||
placement:
|
||||
snap:
|
||||
- Wall
|
||||
@@ -15,6 +15,10 @@
|
||||
|
||||
- type: BoundingBox
|
||||
- type: Collidable
|
||||
- type: Damageable
|
||||
- type: Destructible
|
||||
thresholdvalue: 100
|
||||
spawnondestroy: girder
|
||||
- type: Occluder
|
||||
sizeX: 32
|
||||
sizeY: 32
|
||||
|
||||
Reference in New Issue
Block a user