Add test for adding each component individually to an entity (#1870)

* Add test for adding each component individually to entities

* Put one-to-one test before all-at-once test
This commit is contained in:
DrSmugleaf
2020-08-24 13:39:00 +02:00
committed by GitHub
parent 9e6459ac79
commit a4f527351e
13 changed files with 297 additions and 114 deletions

View File

@@ -1,4 +1,3 @@
using System;
using Content.Server.GameObjects.Components.Mobs;
using Robust.Shared.GameObjects;
using Robust.Shared.GameObjects.Components;
@@ -32,10 +31,11 @@ namespace Content.Server.GameObjects.Components.Projectiles
public override void Initialize()
{
base.Initialize();
if (!Owner.HasComponent<ProjectileComponent>())
if (!Owner.EnsureComponent(out ProjectileComponent _))
{
Logger.Error("StunProjectile entity must have a ProjectileComponent");
throw new InvalidOperationException();
Logger.Warning(
$"Entity {Owner.Name} at {Owner.Transform.MapPosition} didn't have a {nameof(ProjectileComponent)}");
}
}