ECS and cleanup body system, merge body templates and presets into body prototypes (#11991)

Co-authored-by: Jezithyr <Jezithyr@gmail.com>
This commit is contained in:
DrSmugleaf
2022-10-23 00:46:28 +02:00
committed by GitHub
parent 9a38736c3c
commit f323fb7644
140 changed files with 2478 additions and 2571 deletions

View File

@@ -1,5 +1,6 @@
using System.Linq;
using Content.Server.Administration;
using Content.Server.Body.Systems;
using Content.Shared.Administration;
using Content.Shared.Body.Components;
using Content.Shared.Body.Part;
@@ -31,7 +32,8 @@ namespace Content.Server.Body.Commands
return;
}
if (!IoCManager.Resolve<IEntityManager>().TryGetComponent(player.AttachedEntity, out SharedBodyComponent? body))
var entityManager = IoCManager.Resolve<IEntityManager>();
if (!entityManager.TryGetComponent(player.AttachedEntity, out BodyComponent? body))
{
var random = IoCManager.Resolve<IRobustRandom>();
var text = $"You have no body{(random.Prob(0.2f) ? " and you must scream." : ".")}";
@@ -40,15 +42,16 @@ namespace Content.Server.Body.Commands
return;
}
var hand = body.GetPartsOfType(BodyPartType.Hand).FirstOrDefault();
var bodySystem = entityManager.System<BodySystem>();
var hand = bodySystem.GetBodyChildrenOfType(player.AttachedEntity, BodyPartType.Hand, body).FirstOrDefault();
if (hand == null)
if (hand == default)
{
shell.WriteLine("You have no hands.");
}
else
{
body.RemovePart(hand);
bodySystem.DropPart(hand.Id, hand.Component);
}
}
}