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,3 +1,4 @@
using System.Threading;
using Content.Server.Body.Components;
using Content.Server.Body.Systems;
using Content.Server.Chemistry.EntitySystems;
@@ -20,7 +21,6 @@ using Content.Shared.Verbs;
using Robust.Shared.Audio;
using Robust.Shared.Player;
using Robust.Shared.Utility;
using System.Threading;
namespace Content.Server.Nutrition.EntitySystems
{
@@ -48,7 +48,7 @@ namespace Content.Server.Nutrition.EntitySystems
SubscribeLocalEvent<FoodComponent, UseInHandEvent>(OnUseFoodInHand);
SubscribeLocalEvent<FoodComponent, AfterInteractEvent>(OnFeedFood);
SubscribeLocalEvent<FoodComponent, GetVerbsEvent<AlternativeVerb>>(AddEatVerb);
SubscribeLocalEvent<SharedBodyComponent, FeedEvent>(OnFeed);
SubscribeLocalEvent<BodyComponent, FeedEvent>(OnFeed);
SubscribeLocalEvent<ForceFeedCancelledEvent>(OnFeedCancelled);
SubscribeLocalEvent<InventoryComponent, IngestionAttemptEvent>(OnInventoryIngestAttempt);
}
@@ -88,7 +88,7 @@ namespace Content.Server.Nutrition.EntitySystems
return false;
// Target can't be fed
if (!EntityManager.HasComponent<SharedBodyComponent>(target))
if (!EntityManager.HasComponent<BodyComponent>(target))
return false;
if (!_solutionContainerSystem.TryGetSolution(food.Owner, food.SolutionName, out var foodSolution))
@@ -145,14 +145,14 @@ namespace Content.Server.Nutrition.EntitySystems
}
private void OnFeed(EntityUid uid, SharedBodyComponent body, FeedEvent args)
private void OnFeed(EntityUid uid, BodyComponent body, FeedEvent args)
{
if (args.Food.Deleted)
return;
args.Food.CancelToken = null;
if (!_bodySystem.TryGetComponentsOnMechanisms<StomachComponent>(uid, out var stomachs, body))
if (!_bodySystem.TryGetBodyOrganComponents<StomachComponent>(uid, out var stomachs, body))
return;
var transferAmount = args.Food.TransferAmount != null
@@ -243,8 +243,8 @@ namespace Content.Server.Nutrition.EntitySystems
if (uid == ev.User ||
!ev.CanInteract ||
!ev.CanAccess ||
!EntityManager.TryGetComponent(ev.User, out SharedBodyComponent? body) ||
!_bodySystem.TryGetComponentsOnMechanisms<StomachComponent>(ev.User, out var stomachs, body))
!EntityManager.TryGetComponent(ev.User, out BodyComponent? body) ||
!_bodySystem.TryGetBodyOrganComponents<StomachComponent>(ev.User, out var stomachs, body))
return;
if (EntityManager.TryGetComponent<MobStateComponent>(uid, out var mobState) && mobState.IsAlive())
@@ -279,7 +279,7 @@ namespace Content.Server.Nutrition.EntitySystems
if (!_solutionContainerSystem.TryGetSolution(uid, food.SolutionName, out var foodSolution))
return;
if (!_bodySystem.TryGetComponentsOnMechanisms<StomachComponent>(target, out var stomachs, body))
if (!_bodySystem.TryGetBodyOrganComponents<StomachComponent>(target, out var stomachs, body))
return;
if (food.UsesRemaining <= 0)