Fix 3000 errors

This commit is contained in:
DrSmugleaf
2021-12-05 18:09:01 +01:00
parent 2bfec7ec62
commit 2a3b7d809d
569 changed files with 2979 additions and 3280 deletions

View File

@@ -1,8 +1,11 @@
using System.Collections.Generic;
using System.Diagnostics.CodeAnalysis;
using Content.Server.Body.Components;
using Content.Server.Body.Systems;
using Content.Server.Chemistry.EntitySystems;
using Content.Server.DoAfter;
using Content.Server.Hands.Components;
using Content.Server.Inventory.Components;
using Content.Server.Items;
using Content.Server.Nutrition.Components;
using Content.Server.Popups;
@@ -15,20 +18,16 @@ using Content.Shared.Database;
using Content.Shared.FixedPoint;
using Content.Shared.Interaction;
using Content.Shared.Interaction.Helpers;
using Content.Shared.Inventory;
using Content.Shared.MobState.Components;
using Content.Shared.Tag;
using Content.Shared.Verbs;
using Robust.Shared.Audio;
using Robust.Shared.GameObjects;
using Robust.Shared.IoC;
using Robust.Shared.Localization;
using Robust.Shared.Player;
using System.Collections.Generic;
using System.Linq;
using Robust.Shared.Utility;
using Content.Server.Inventory.Components;
using Content.Shared.Inventory;
using System.Diagnostics.CodeAnalysis;
using Content.Shared.Tag;
namespace Content.Server.Nutrition.EntitySystems
{
@@ -65,16 +64,16 @@ namespace Content.Server.Nutrition.EntitySystems
if (ev.Handled)
return;
if (!_actionBlockerSystem.CanInteract(ev.UserUid) || !_actionBlockerSystem.CanUse(ev.UserUid))
if (!_actionBlockerSystem.CanInteract(ev.User) || !_actionBlockerSystem.CanUse(ev.User))
return;
if (!ev.UserUid.InRangeUnobstructed(uid, popup: true))
if (!ev.User.InRangeUnobstructed(uid, popup: true))
{
ev.Handled = true;
return;
}
ev.Handled = TryUseFood(uid, ev.UserUid);
ev.Handled = TryUseFood(uid, ev.User);
}
/// <summary>
@@ -82,80 +81,79 @@ namespace Content.Server.Nutrition.EntitySystems
/// </summary>
private void OnFeedFood(EntityUid uid, FoodComponent foodComponent, AfterInteractEvent args)
{
if (args.Handled || args.TargetUid == null)
if (args.Handled || args.Target == default)
return;
if (!_actionBlockerSystem.CanInteract(args.UserUid) || !_actionBlockerSystem.CanUse(args.UserUid))
if (!_actionBlockerSystem.CanInteract(args.User) || !_actionBlockerSystem.CanUse(args.User))
return;
if (!args.UserUid.InRangeUnobstructed(uid, popup: true))
if (!args.User.InRangeUnobstructed(uid, popup: true))
{
args.Handled = true;
return;
}
if (args.UserUid == args.TargetUid)
if (args.User == args.Target)
{
args.Handled = TryUseFood(uid, args.UserUid);
args.Handled = TryUseFood(uid, args.User);
return;
}
if (!args.UserUid.InRangeUnobstructed(args.TargetUid.Value, popup: true))
if (!args.User.InRangeUnobstructed(args.Target.Value, popup: true))
{
args.Handled = true;
return;
}
args.Handled = TryForceFeed(uid, args.UserUid, args.TargetUid.Value);
args.Handled = TryForceFeed(uid, args.User, args.Target.Value);
}
/// <summary>
/// Tries to eat some food
/// </summary>
/// <param name="uid">Food entity.</param>
/// <param name="userUid">Feeding initiator.</param>
/// <param name="targetUid">Feeding target.</param>
/// <param name="user">Feeding initiator.</param>
/// <returns>True if an interaction occurred (i.e., food was consumed, or a pop-up message was created)</returns>
public bool TryUseFood(EntityUid uid, EntityUid userUid, FoodComponent? component = null)
public bool TryUseFood(EntityUid uid, EntityUid user, FoodComponent? food = null)
{
if (!Resolve(uid, ref component))
if (!Resolve(uid, ref food))
return false;
if (uid == userUid || //Suppresses self-eating
if (uid == user || //Suppresses self-eating
EntityManager.TryGetComponent<MobStateComponent>(uid, out var mobState) && mobState.IsAlive()) // Suppresses eating alive mobs
return false;
if (!_solutionContainerSystem.TryGetSolution(uid, component.SolutionName, out var solution))
if (!_solutionContainerSystem.TryGetSolution(uid, food.SolutionName, out var solution))
return false;
if (component.UsesRemaining <= 0)
if (food.UsesRemaining <= 0)
{
_popupSystem.PopupEntity(Loc.GetString("food-system-try-use-food-is-empty", ("entity", EntityManager.GetEntity(uid))), userUid, Filter.Entities(userUid));
DeleteAndSpawnTrash(component, userUid);
_popupSystem.PopupEntity(Loc.GetString("food-system-try-use-food-is-empty", ("entity", uid)), user, Filter.Entities(user));
DeleteAndSpawnTrash(food, user);
return true;
}
if (!EntityManager.TryGetComponent(userUid, out SharedBodyComponent ? body) ||
!_bodySystem.TryGetComponentsOnMechanisms<StomachComponent>(userUid, out var stomachs, body))
if (!EntityManager.TryGetComponent(user, out SharedBodyComponent ? body) ||
!_bodySystem.TryGetComponentsOnMechanisms<StomachComponent>(user, out var stomachs, body))
return false;
if (IsMouthBlocked(userUid, out var blocker))
if (IsMouthBlocked(user, out var blocker))
{
var name = EntityManager.GetComponent<MetaDataComponent>(blocker.Value).EntityName;
_popupSystem.PopupEntity(Loc.GetString("food-system-remove-mask", ("entity", name)),
userUid, Filter.Entities(userUid));
user, Filter.Entities(user));
return true;
}
var usedUtensils = new List<UtensilComponent>();
if (!TryGetRequiredUtensils(userUid, component, out var utensils))
if (!TryGetRequiredUtensils(user, food, out var utensils))
return true;
if (!userUid.InRangeUnobstructed(uid, popup: true))
if (!user.InRangeUnobstructed(uid, popup: true))
return true;
var transferAmount = component.TransferAmount != null ? FixedPoint2.Min((FixedPoint2) component.TransferAmount, solution.CurrentVolume) : solution.CurrentVolume;
var transferAmount = food.TransferAmount != null ? FixedPoint2.Min((FixedPoint2) food.TransferAmount, solution.CurrentVolume) : solution.CurrentVolume;
var split = _solutionContainerSystem.SplitSolution(uid, solution, transferAmount);
var firstStomach = stomachs.FirstOrNull(
stomach => _stomachSystem.CanTransferSolution(((IComponent) stomach.Comp).Owner, split));
@@ -163,51 +161,51 @@ namespace Content.Server.Nutrition.EntitySystems
if (firstStomach == null)
{
_solutionContainerSystem.TryAddSolution(uid, solution, split);
_popupSystem.PopupEntity(Loc.GetString("food-system-you-cannot-eat-any-more"), userUid, Filter.Entities(userUid));
_popupSystem.PopupEntity(Loc.GetString("food-system-you-cannot-eat-any-more"), user, Filter.Entities(user));
return true;
}
// TODO: Account for partial transfer.
split.DoEntityReaction(userUid, ReactionMethod.Ingestion);
split.DoEntityReaction(user, ReactionMethod.Ingestion);
_stomachSystem.TryTransferSolution(((IComponent) firstStomach.Value.Comp).Owner, split, firstStomach.Value.Comp);
SoundSystem.Play(Filter.Pvs(userUid), component.UseSound.GetSound(), userUid, AudioParams.Default.WithVolume(-1f));
_popupSystem.PopupEntity(Loc.GetString(component.EatMessage, ("food", component.Owner)), userUid, Filter.Entities(userUid));
SoundSystem.Play(Filter.Pvs(user), food.UseSound.GetSound(), user, AudioParams.Default.WithVolume(-1f));
_popupSystem.PopupEntity(Loc.GetString(food.EatMessage, ("food", food.Owner)), user, Filter.Entities(user));
// Try to break all used utensils
foreach (var utensil in usedUtensils)
{
_utensilSystem.TryBreak(((IComponent) utensil).Owner, userUid);
_utensilSystem.TryBreak(((IComponent) utensil).Owner, user);
}
if (component.UsesRemaining > 0)
if (food.UsesRemaining > 0)
{
return true;
}
if (string.IsNullOrEmpty(component.TrashPrototype))
EntityManager.QueueDeleteEntity(((IComponent) component).Owner);
if (string.IsNullOrEmpty(food.TrashPrototype))
EntityManager.QueueDeleteEntity(((IComponent) food).Owner);
else
DeleteAndSpawnTrash(component, userUid);
DeleteAndSpawnTrash(food, user);
return true;
}
private void DeleteAndSpawnTrash(FoodComponent component, EntityUid? userUid = null)
private void DeleteAndSpawnTrash(FoodComponent component, EntityUid? user = null)
{
//We're empty. Become trash.
var position = IoCManager.Resolve<IEntityManager>().GetComponent<TransformComponent>(component.Owner).Coordinates;
var finisher = IoCManager.Resolve<IEntityManager>().SpawnEntity(component.TrashPrototype, position);
var position = EntityManager.GetComponent<TransformComponent>(component.Owner).Coordinates;
var finisher = EntityManager.SpawnEntity(component.TrashPrototype, position);
// If the user is holding the item
if (userUid != null &&
EntityManager.TryGetComponent(userUid.Value, out HandsComponent? handsComponent) &&
if (user != null &&
EntityManager.TryGetComponent(user.Value, out HandsComponent? handsComponent) &&
handsComponent.IsHolding(component.Owner))
{
EntityManager.DeleteEntity(((IComponent) component).Owner);
// Put the trash in the user's hand
if (IoCManager.Resolve<IEntityManager>().TryGetComponent(finisher, out ItemComponent? item) &&
if (EntityManager.TryGetComponent(finisher, out ItemComponent? item) &&
handsComponent.CanPutInHand(item))
{
handsComponent.PutInHand(item);
@@ -220,24 +218,26 @@ namespace Content.Server.Nutrition.EntitySystems
private void AddEatVerb(EntityUid uid, FoodComponent component, GetInteractionVerbsEvent ev)
{
if (uid == ev.UserUid ||
if (uid == ev.User ||
!ev.CanInteract ||
!ev.CanAccess ||
!EntityManager.TryGetComponent(ev.UserUid, out SharedBodyComponent? body) ||
!_bodySystem.TryGetComponentsOnMechanisms<StomachComponent>(ev.UserUid, out var stomachs, body))
!EntityManager.TryGetComponent(ev.User, out SharedBodyComponent? body) ||
!_bodySystem.TryGetComponentsOnMechanisms<StomachComponent>(ev.User, out var stomachs, body))
return;
if (EntityManager.TryGetComponent<MobStateComponent>(uid, out var mobState) && mobState.IsAlive())
return;
Verb verb = new();
verb.Act = () =>
Verb verb = new()
{
TryUseFood(uid, ev.UserUid, component);
Act = () =>
{
TryUseFood(uid, ev.User, component);
},
Text = Loc.GetString("food-system-verb-eat"),
Priority = -1
};
verb.Text = Loc.GetString("food-system-verb-eat");
verb.Priority = -1;
ev.Verbs.Add(verb);
}
@@ -245,12 +245,12 @@ namespace Content.Server.Nutrition.EntitySystems
/// <summary>
/// Attempts to force feed a target. Returns true if any interaction occurred, including pop-up generation
/// </summary>
public bool TryForceFeed(EntityUid uid, EntityUid userUid, EntityUid targetUid, FoodComponent? food = null)
public bool TryForceFeed(EntityUid uid, EntityUid user, EntityUid target, FoodComponent? food = null)
{
if (!Resolve(uid, ref food))
return false;
if (!EntityManager.HasComponent<SharedBodyComponent>(targetUid))
if (!EntityManager.HasComponent<SharedBodyComponent>(target))
return false;
if (!_solutionContainerSystem.TryGetSolution(uid, food.SolutionName, out var foodSolution))
@@ -259,44 +259,41 @@ namespace Content.Server.Nutrition.EntitySystems
if (food.UsesRemaining <= 0)
{
_popupSystem.PopupEntity(Loc.GetString("food-system-try-use-food-is-empty",
("entity", EntityManager.GetEntity(uid))), userUid, Filter.Entities(userUid));
DeleteAndSpawnTrash(food, userUid);
("entity", uid)), user, Filter.Entities(user));
DeleteAndSpawnTrash(food, user);
return true;
}
if (IsMouthBlocked(targetUid, out var blocker))
if (IsMouthBlocked(target, out var blocker))
{
var name = EntityManager.GetComponent<MetaDataComponent>(blocker.Value).EntityName;
_popupSystem.PopupEntity(Loc.GetString("food-system-remove-mask", ("entity", name)),
userUid, Filter.Entities(userUid));
user, Filter.Entities(user));
return true;
}
if (!TryGetRequiredUtensils(userUid, food, out var utensils))
if (!TryGetRequiredUtensils(user, food, out var utensils))
return true;
EntityManager.TryGetComponent(userUid, out MetaDataComponent? meta);
EntityManager.TryGetComponent(user, out MetaDataComponent? meta);
var userName = meta?.EntityName ?? string.Empty;
_popupSystem.PopupEntity(Loc.GetString("food-system-force-feed", ("user", userName)),
userUid, Filter.Entities(targetUid));
user, Filter.Entities(target));
_doAfterSystem.DoAfter(new DoAfterEventArgs(userUid, food.ForceFeedDelay, target: targetUid)
_doAfterSystem.DoAfter(new DoAfterEventArgs(user, food.ForceFeedDelay, target: target)
{
BreakOnUserMove = true,
BreakOnDamage = true,
BreakOnStun = true,
BreakOnTargetMove = true,
MovementThreshold = 1.0f,
TargetFinishedEvent = new ForceFeedEvent(userUid, food, foodSolution, utensils),
TargetFinishedEvent = new ForceFeedEvent(user, food, foodSolution, utensils),
BroadcastCancelledEvent = new ForceFeedCancelledEvent(food)
});
// logging
var user = EntityManager.GetEntity(userUid);
var target = EntityManager.GetEntity(targetUid);
var edible = EntityManager.GetEntity(uid);
_logSystem.Add(LogType.ForceFeed, LogImpact.Medium, $"{user} is forcing {target} to eat {edible}");
_logSystem.Add(LogType.ForceFeed, LogImpact.Medium, $"{user} is forcing {target} to eat {uid}");
food.InUse = true;
return true;
@@ -383,15 +380,12 @@ namespace Content.Server.Nutrition.EntitySystems
return;
// logging
var userEntity = (user == null) ? null : EntityManager.GetEntity(user.Value);
var targetEntity = EntityManager.GetEntity(target);
var edible = EntityManager.GetEntity(uid);
if (userEntity == null)
_logSystem.Add(LogType.ForceFeed, $"{edible} was thrown into the mouth of {targetEntity}");
if (user == null)
_logSystem.Add(LogType.ForceFeed, $"{uid} was thrown into the mouth of {target}");
else
_logSystem.Add(LogType.ForceFeed, $"{userEntity} threw {edible} into the mouth of {targetEntity}");
_logSystem.Add(LogType.ForceFeed, $"{user} threw {uid} into the mouth of {target}");
var filter = (user == null) ? Filter.Entities(target) : Filter.Entities(target, user.Value);
var filter = user == null ? Filter.Entities(target) : Filter.Entities(target, user.Value);
_popupSystem.PopupEntity(Loc.GetString(food.EatMessage), target, filter);
foodSolution.DoEntityReaction(uid, ReactionMethod.Ingestion);
@@ -404,7 +398,7 @@ namespace Content.Server.Nutrition.EntitySystems
DeleteAndSpawnTrash(food);
}
private bool TryGetRequiredUtensils(EntityUid userUid, FoodComponent component,
private bool TryGetRequiredUtensils(EntityUid user, FoodComponent component,
out List<UtensilComponent> utensils, HandsComponent? hands = null)
{
utensils = new();
@@ -412,7 +406,7 @@ namespace Content.Server.Nutrition.EntitySystems
if (component.Utensil != UtensilType.None)
return true;
if (!Resolve(userUid, ref hands, false))
if (!Resolve(user, ref hands, false))
return false;
var usedTypes = UtensilType.None;
@@ -420,7 +414,7 @@ namespace Content.Server.Nutrition.EntitySystems
foreach (var item in hands.GetAllHeldItems())
{
// Is utensil?
if (!IoCManager.Resolve<IEntityManager>().TryGetComponent(item.Owner, out UtensilComponent? utensil))
if (!EntityManager.TryGetComponent(item.Owner, out UtensilComponent? utensil))
continue;
if ((utensil.Types & component.Utensil) != 0 && // Acceptable type?
@@ -435,7 +429,7 @@ namespace Content.Server.Nutrition.EntitySystems
// If "required" field is set, try to block eating without proper utensils used
if (component.UtensilRequired && (usedTypes & component.Utensil) != component.Utensil)
{
_popupSystem.PopupEntity(Loc.GetString("food-you-need-to-hold-utensil", ("utensil", component.Utensil ^ usedTypes)), userUid, Filter.Entities(userUid));
_popupSystem.PopupEntity(Loc.GetString("food-you-need-to-hold-utensil", ("utensil", component.Utensil ^ usedTypes)), user, Filter.Entities(user));
return false;
}
@@ -464,7 +458,7 @@ namespace Content.Server.Nutrition.EntitySystems
{
// For now, lets just assume that any masks always covers the mouth
// TODO MASKS if the ability is added to raise/lower masks, this needs to be updated.
blockingEntity = mask.OwnerUid;
blockingEntity = mask.Owner;
return true;
}
@@ -473,7 +467,7 @@ namespace Content.Server.Nutrition.EntitySystems
EntityManager.TryGetComponent(((IComponent) head).Owner, out TagComponent tag) &&
tag.HasTag("ConcealsFace"))
{
blockingEntity = head.OwnerUid;
blockingEntity = head.Owner;
return true;
}