Remove manual container ejection checking code.
This fixes map load when something is in a storage component.
This commit is contained in:
@@ -7,6 +7,7 @@ using Content.Shared.Input;
|
||||
using JetBrains.Annotations;
|
||||
using Robust.Server.GameObjects;
|
||||
using Robust.Server.GameObjects.Components.Container;
|
||||
using Robust.Server.GameObjects.EntitySystemMessages;
|
||||
using Robust.Server.Interfaces.Player;
|
||||
using Robust.Shared.GameObjects;
|
||||
using Robust.Shared.Input;
|
||||
@@ -91,22 +92,6 @@ namespace Content.Server.GameObjects
|
||||
return false;
|
||||
}
|
||||
|
||||
/// <inheritdoc />
|
||||
public void RemoveHandEntity(IEntity entity)
|
||||
{
|
||||
if (entity == null)
|
||||
return;
|
||||
|
||||
foreach (var slot in hands.Values)
|
||||
{
|
||||
if (slot.ContainedEntity == entity)
|
||||
{
|
||||
slot.Remove(entity);
|
||||
}
|
||||
}
|
||||
Dirty();
|
||||
}
|
||||
|
||||
public ItemComponent GetHand(string index)
|
||||
{
|
||||
var slot = hands[index];
|
||||
@@ -504,5 +489,26 @@ namespace Content.Server.GameObjects
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
public void HandleSlotModifiedMaybe(ContainerModifiedMessage message)
|
||||
{
|
||||
foreach (var container in hands.Values)
|
||||
{
|
||||
if (container != message.Container)
|
||||
{
|
||||
continue;
|
||||
}
|
||||
|
||||
Dirty();
|
||||
if (!message.Entity.TryGetComponent(out PhysicsComponent physics))
|
||||
{
|
||||
return;
|
||||
}
|
||||
|
||||
// set velocity to zero
|
||||
physics.LinearVelocity = Vector2.Zero;
|
||||
return;
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
@@ -18,6 +18,7 @@ using Robust.Shared.GameObjects.EntitySystemMessages;
|
||||
using Robust.Shared.Interfaces.Map;
|
||||
using Robust.Shared.ViewVariables;
|
||||
using Content.Server.GameObjects.Components;
|
||||
using Robust.Server.GameObjects.EntitySystemMessages;
|
||||
|
||||
namespace Content.Server.GameObjects
|
||||
{
|
||||
@@ -82,14 +83,21 @@ namespace Content.Server.GameObjects
|
||||
public bool Remove(IEntity toremove)
|
||||
{
|
||||
_ensureInitialCalculated();
|
||||
if (storage.Remove(toremove))
|
||||
return storage.Remove(toremove);
|
||||
}
|
||||
|
||||
internal void HandleEntityMaybeRemoved(EntRemovedFromContainerMessage message)
|
||||
{
|
||||
if (message.Container != storage)
|
||||
{
|
||||
Logger.InfoS("Storage", "Storage (UID {0}) had entity (UID {1}) removed from it.", Owner.Uid, toremove.Uid);
|
||||
StorageUsed -= toremove.GetComponent<StoreableComponent>().ObjectSize;
|
||||
UpdateClientInventories();
|
||||
return true;
|
||||
return;
|
||||
}
|
||||
return false;
|
||||
|
||||
_ensureInitialCalculated();
|
||||
Logger.DebugS("Storage", "Storage (UID {0}) had entity (UID {1}) removed from it.", Owner.Uid,
|
||||
message.Entity.Uid);
|
||||
StorageUsed -= message.Entity.GetComponent<StoreableComponent>().ObjectSize;
|
||||
UpdateClientInventories();
|
||||
}
|
||||
|
||||
/// <summary>
|
||||
@@ -99,14 +107,21 @@ namespace Content.Server.GameObjects
|
||||
/// <returns></returns>
|
||||
public bool Insert(IEntity toinsert)
|
||||
{
|
||||
if (CanInsert(toinsert) && storage.Insert(toinsert))
|
||||
return CanInsert(toinsert) && storage.Insert(toinsert);
|
||||
}
|
||||
|
||||
internal void HandleEntityMaybeInserted(EntInsertedIntoContainerMessage message)
|
||||
{
|
||||
if (message.Container != storage)
|
||||
{
|
||||
Logger.InfoS("Storage", "Storage (UID {0}) had entity (UID {1}) inserted into it.", Owner.Uid, toinsert.Uid);
|
||||
StorageUsed += toinsert.GetComponent<StoreableComponent>().ObjectSize;
|
||||
UpdateClientInventories();
|
||||
return true;
|
||||
return;
|
||||
}
|
||||
return false;
|
||||
|
||||
_ensureInitialCalculated();
|
||||
Logger.DebugS("Storage", "Storage (UID {0}) had entity (UID {1}) inserted into it.", Owner.Uid,
|
||||
message.Entity.Uid);
|
||||
StorageUsed += message.Entity.GetComponent<StoreableComponent>().ObjectSize;
|
||||
UpdateClientInventories();
|
||||
}
|
||||
|
||||
/// <summary>
|
||||
@@ -328,6 +343,11 @@ namespace Content.Server.GameObjects
|
||||
|
||||
StorageUsed = 0;
|
||||
|
||||
if (storage == null)
|
||||
{
|
||||
return;
|
||||
}
|
||||
|
||||
foreach (var entity in storage.ContainedEntities)
|
||||
{
|
||||
var item = entity.GetComponent<ItemComponent>();
|
||||
|
||||
Reference in New Issue
Block a user