Don't let bullets fly forever. Give them 10 seconds until deleted.
This commit is contained in:
@@ -20,6 +20,8 @@ namespace Content.Server.GameObjects.Components.Projectiles
|
|||||||
|
|
||||||
public Dictionary<DamageType, int> damages = new Dictionary<DamageType, int>();
|
public Dictionary<DamageType, int> damages = new Dictionary<DamageType, int>();
|
||||||
|
|
||||||
|
public float TimeLeft { get; set; } = 10;
|
||||||
|
|
||||||
/// <summary>
|
/// <summary>
|
||||||
/// Function that makes the collision of this object ignore a specific entity so we don't collide with ourselves
|
/// Function that makes the collision of this object ignore a specific entity so we don't collide with ourselves
|
||||||
/// </summary>
|
/// </summary>
|
||||||
|
|||||||
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