Merge branch 'master' of https://github.com/space-wizards/space-station-14
This commit is contained in:
@@ -24,6 +24,19 @@ namespace Content.Server.GameObjects.EntitySystems
|
||||
public bool IsSpawnWreck { get; set; }
|
||||
}
|
||||
|
||||
public class BreakageEventArgs : EventArgs
|
||||
{
|
||||
public IEntity Owner { get; set; }
|
||||
}
|
||||
|
||||
public interface IBreakAct
|
||||
{
|
||||
/// <summary>
|
||||
/// Called when object is broken
|
||||
/// </summary>
|
||||
void OnBreak(BreakageEventArgs eventArgs);
|
||||
}
|
||||
|
||||
public interface IExAct
|
||||
{
|
||||
/// <summary>
|
||||
@@ -73,6 +86,19 @@ namespace Content.Server.GameObjects.EntitySystems
|
||||
exAct.OnExplosion(eventArgs);
|
||||
}
|
||||
}
|
||||
|
||||
public void HandleBreakage(IEntity owner)
|
||||
{
|
||||
var eventArgs = new BreakageEventArgs
|
||||
{
|
||||
Owner = owner,
|
||||
};
|
||||
var breakActs = owner.GetAllComponents<IBreakAct>().ToList();
|
||||
foreach (var breakAct in breakActs)
|
||||
{
|
||||
breakAct.OnBreak(eventArgs);
|
||||
}
|
||||
}
|
||||
}
|
||||
public enum ExplosionSeverity
|
||||
{
|
||||
@@ -80,4 +106,4 @@ namespace Content.Server.GameObjects.EntitySystems
|
||||
Heavy,
|
||||
Light,
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
34
Content.Server/GameObjects/EntitySystems/ProjectileSystem.cs
Normal file
34
Content.Server/GameObjects/EntitySystems/ProjectileSystem.cs
Normal file
@@ -0,0 +1,34 @@
|
||||
using Content.Server.GameObjects.Components.Projectiles;
|
||||
using JetBrains.Annotations;
|
||||
using Robust.Shared.GameObjects;
|
||||
using Robust.Shared.GameObjects.Systems;
|
||||
|
||||
namespace Content.Server.GameObjects.EntitySystems
|
||||
{
|
||||
[UsedImplicitly]
|
||||
internal sealed class ProjectileSystem : EntitySystem
|
||||
{
|
||||
public override void Initialize()
|
||||
{
|
||||
base.Initialize();
|
||||
|
||||
EntityQuery = new TypeEntityQuery(typeof(ProjectileComponent));
|
||||
}
|
||||
|
||||
public override void Update(float frameTime)
|
||||
{
|
||||
base.Update(frameTime);
|
||||
|
||||
foreach (var entity in RelevantEntities)
|
||||
{
|
||||
var component = entity.GetComponent<ProjectileComponent>();
|
||||
component.TimeLeft -= frameTime;
|
||||
|
||||
if (component.TimeLeft <= 0)
|
||||
{
|
||||
entity.Delete();
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
Reference in New Issue
Block a user