Add a test that puts all components on an entity and checks for no exceptions (#1815)
* Add test that puts all components on an entity and checks for no exceptions Also fix all the exceptions that happened because of this * Add comments to the test * Fix nullable errors * Fix more nullable errors * More nullable error fixes * Unignore basic actor component * Fix more nullable errors * NULLABLE ERROR * Add string interpolation * Merge if checks * Remove redundant pragma warning disable 649 * Address reviews * Remove null wrappers around TryGetComponent * Merge conflict fixes * APC battery component error fix * Fix power test * Fix atmos mapgrid usages
This commit is contained in:
@@ -15,17 +15,16 @@ namespace Content.Server.GameObjects.Components.Projectiles
|
||||
public override void Initialize()
|
||||
{
|
||||
base.Initialize();
|
||||
if (!Owner.HasComponent<ExplosiveComponent>())
|
||||
{
|
||||
Logger.Error("ExplosiveProjectiles need an ExplosiveComponent");
|
||||
throw new InvalidOperationException();
|
||||
}
|
||||
|
||||
Owner.EnsureComponent<ExplosiveComponent>();
|
||||
}
|
||||
|
||||
void ICollideBehavior.CollideWith(IEntity entity)
|
||||
{
|
||||
var explosiveComponent = Owner.GetComponent<ExplosiveComponent>();
|
||||
explosiveComponent.Explosion();
|
||||
if (Owner.TryGetComponent(out ExplosiveComponent explosive))
|
||||
{
|
||||
explosive.Explosion();
|
||||
}
|
||||
}
|
||||
|
||||
// Projectile should handle the deleting
|
||||
@@ -34,4 +33,4 @@ namespace Content.Server.GameObjects.Components.Projectiles
|
||||
return;
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user