Construction warning cleanup (#12256)
This commit is contained in:
@@ -1,7 +1,6 @@
|
||||
using System.IO;
|
||||
using System.Linq;
|
||||
using System.Threading.Tasks;
|
||||
using Content.Server.Administration.Logs;
|
||||
using Content.Server.Construction.Components;
|
||||
using Content.Server.DoAfter;
|
||||
using Content.Server.Hands.Components;
|
||||
@@ -15,8 +14,8 @@ using Content.Shared.Database;
|
||||
using Content.Shared.Hands.EntitySystems;
|
||||
using Content.Shared.Interaction;
|
||||
using Content.Shared.Inventory;
|
||||
using Content.Shared.Popups;
|
||||
using Robust.Shared.Containers;
|
||||
using Robust.Shared.Player;
|
||||
using Robust.Shared.Players;
|
||||
using Robust.Shared.Timing;
|
||||
|
||||
@@ -82,7 +81,7 @@ namespace Content.Server.Construction
|
||||
|
||||
foreach (var near in _lookupSystem.GetEntitiesInRange(user, 2f, LookupFlags.Approximate))
|
||||
{
|
||||
if (_interactionSystem.InRangeUnobstructed(pos, near, 2f) && _containerSystem.IsInSameOrParentContainer(user, near))
|
||||
if (_interactionSystem.InRangeUnobstructed(pos, near, 2f) && _container.IsInSameOrParentContainer(user, near))
|
||||
yield return near;
|
||||
}
|
||||
}
|
||||
@@ -91,11 +90,11 @@ namespace Content.Server.Construction
|
||||
private async Task<EntityUid?> Construct(EntityUid user, string materialContainer, ConstructionGraphPrototype graph, ConstructionGraphEdge edge, ConstructionGraphNode targetNode)
|
||||
{
|
||||
// We need a place to hold our construction items!
|
||||
var container = ContainerHelpers.EnsureContainer<Container>(user, materialContainer, out var existed);
|
||||
var container = _container.EnsureContainer<Container>(user, materialContainer, out var existed);
|
||||
|
||||
if (existed)
|
||||
{
|
||||
user.PopupMessageCursor(Loc.GetString("construction-system-construct-cannot-start-another-construction"));
|
||||
_popup.PopupCursor(Loc.GetString("construction-system-construct-cannot-start-another-construction"), Filter.Entities(user));
|
||||
return null;
|
||||
}
|
||||
|
||||
@@ -107,15 +106,16 @@ namespace Content.Server.Construction
|
||||
// But I'd rather do this shit than risk having collisions with other containers.
|
||||
Container GetContainer(string name)
|
||||
{
|
||||
if (containers!.ContainsKey(name))
|
||||
if (containers.ContainsKey(name))
|
||||
return containers[name];
|
||||
|
||||
while (true)
|
||||
{
|
||||
var random = _robustRandom.Next();
|
||||
var c = ContainerHelpers.EnsureContainer<Container>(user!, random.ToString(), out var existed);
|
||||
var c = _container.EnsureContainer<Container>(user, random.ToString(), out var exists);
|
||||
|
||||
if (existed) continue;
|
||||
if (exists)
|
||||
continue;
|
||||
|
||||
containers[name] = c;
|
||||
return c;
|
||||
@@ -124,12 +124,12 @@ namespace Content.Server.Construction
|
||||
|
||||
void FailCleanup()
|
||||
{
|
||||
foreach (var entity in container!.ContainedEntities.ToArray())
|
||||
foreach (var entity in container.ContainedEntities.ToArray())
|
||||
{
|
||||
container.Remove(entity);
|
||||
}
|
||||
|
||||
foreach (var cont in containers!.Values)
|
||||
foreach (var cont in containers.Values)
|
||||
{
|
||||
foreach (var entity in cont.ContainedEntities.ToArray())
|
||||
{
|
||||
@@ -143,8 +143,8 @@ namespace Content.Server.Construction
|
||||
|
||||
void ShutdownContainers()
|
||||
{
|
||||
container!.Shutdown();
|
||||
foreach (var c in containers!.Values.ToArray())
|
||||
container.Shutdown();
|
||||
foreach (var c in containers.Values.ToArray())
|
||||
{
|
||||
c.Shutdown();
|
||||
}
|
||||
@@ -219,7 +219,7 @@ namespace Content.Server.Construction
|
||||
|
||||
if (failed)
|
||||
{
|
||||
user.PopupMessageCursor(Loc.GetString("construction-system-construct-no-materials"));
|
||||
_popup.PopupCursor(Loc.GetString("construction-system-construct-no-materials"), Filter.Entities(user));
|
||||
FailCleanup();
|
||||
return null;
|
||||
}
|
||||
@@ -255,7 +255,7 @@ namespace Content.Server.Construction
|
||||
// We preserve the containers...
|
||||
foreach (var (name, cont) in containers)
|
||||
{
|
||||
var newCont = ContainerHelpers.EnsureContainer<Container>(newEntity, name);
|
||||
var newCont = _container.EnsureContainer<Container>(newEntity, name);
|
||||
|
||||
foreach (var entity in cont.ContainedEntities.ToArray())
|
||||
{
|
||||
@@ -306,10 +306,11 @@ namespace Content.Server.Construction
|
||||
var targetNode = constructionGraph.Nodes[constructionPrototype.TargetNode];
|
||||
var pathFind = constructionGraph.Path(startNode.Name, targetNode.Name);
|
||||
|
||||
if (args.SenderSession.AttachedEntity is not {Valid: true} user ||
|
||||
!Get<ActionBlockerSystem>().CanInteract(user, null)) return;
|
||||
if (args.SenderSession.AttachedEntity is not {Valid: true} user || _actionBlocker.CanInteract(user, null))
|
||||
return;
|
||||
|
||||
if (!EntityManager.TryGetComponent(user, out HandsComponent? hands)) return;
|
||||
if (!HasComp<HandsComponent>(user))
|
||||
return;
|
||||
|
||||
foreach (var condition in constructionPrototype.Conditions)
|
||||
{
|
||||
@@ -318,14 +319,18 @@ namespace Content.Server.Construction
|
||||
}
|
||||
|
||||
if (pathFind == null)
|
||||
{
|
||||
throw new InvalidDataException(
|
||||
$"Can't find path from starting node to target node in construction! Recipe: {ev.PrototypeName}");
|
||||
}
|
||||
|
||||
var edge = startNode.GetEdge(pathFind[0].Name);
|
||||
|
||||
if (edge == null)
|
||||
{
|
||||
throw new InvalidDataException(
|
||||
$"Can't find edge from starting node to the next node in pathfinding! Recipe: {ev.PrototypeName}");
|
||||
}
|
||||
|
||||
// No support for conditions here!
|
||||
|
||||
@@ -370,9 +375,9 @@ namespace Content.Server.Construction
|
||||
return;
|
||||
}
|
||||
|
||||
if (user.IsInContainer())
|
||||
if (_container.IsEntityInContainer(user))
|
||||
{
|
||||
user.PopupMessageCursor(Loc.GetString("construction-system-inside-container"));
|
||||
_popup.PopupCursor(Loc.GetString("construction-system-inside-container"), Filter.Entities(user));
|
||||
return;
|
||||
}
|
||||
|
||||
@@ -385,7 +390,7 @@ namespace Content.Server.Construction
|
||||
{
|
||||
if (!set.Add(ev.Ack))
|
||||
{
|
||||
user.PopupMessageCursor(Loc.GetString("construction-system-already-building"));
|
||||
_popup.PopupCursor(Loc.GetString("construction-system-already-building"), Filter.Entities(user));
|
||||
return;
|
||||
}
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user