mirror of
https://github.com/space-wizards/RobustToolbox.git
synced 2026-02-14 19:29:36 +01:00
@@ -69,29 +69,21 @@ namespace Robust.Server.GameObjects
|
||||
|
||||
if (!string.IsNullOrWhiteSpace(prototypeName))
|
||||
{
|
||||
if (PrototypeManager.TryIndex<EntityPrototype>(prototypeName, out var prototype))
|
||||
{
|
||||
var prototype = PrototypeManager.Index<EntityPrototype>(prototypeName);
|
||||
|
||||
// At this point in time, all data configure on the entity *should* be purely from the prototype.
|
||||
// As such, we can reset the modified ticks to Zero,
|
||||
// which indicates "not different from client's own deserialization".
|
||||
// So the initial data for the component or even the creation doesn't have to be sent over the wire.
|
||||
foreach (var (netId, component) in GetNetComponents(entity.Uid))
|
||||
{
|
||||
// Make sure to ONLY get components that are defined in the prototype.
|
||||
// Others could be instantiated directly by AddComponent (e.g. ContainerManager).
|
||||
// And those aren't guaranteed to exist on the client, so don't clear them.
|
||||
if (prototype.Components.ContainsKey(component.Name)) ((Component) component).ClearTicks();
|
||||
}
|
||||
}
|
||||
else
|
||||
// At this point in time, all data configure on the entity *should* be purely from the prototype.
|
||||
// As such, we can reset the modified ticks to Zero,
|
||||
// which indicates "not different from client's own deserialization".
|
||||
// So the initial data for the component or even the creation doesn't have to be sent over the wire.
|
||||
foreach (var (netId, component) in GetNetComponents(entity.Uid))
|
||||
{
|
||||
Logger.Error($"Invalid prototypeId '{prototypeName}' passed to {nameof(CreateEntity)}.");
|
||||
// Make sure to ONLY get components that are defined in the prototype.
|
||||
// Others could be instantiated directly by AddComponent (e.g. ContainerManager).
|
||||
// And those aren't guaranteed to exist on the client, so don't clear them.
|
||||
if (prototype.Components.ContainsKey(component.Name)) ((Component) component).ClearTicks();
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
|
||||
return entity;
|
||||
}
|
||||
|
||||
|
||||
@@ -3,7 +3,6 @@ using System.Collections.Generic;
|
||||
using System.Diagnostics.CodeAnalysis;
|
||||
using System.Linq;
|
||||
using Prometheus;
|
||||
using Robust.Shared.Log;
|
||||
using Robust.Shared.Map;
|
||||
using Robust.Shared.Prototypes;
|
||||
using Robust.Shared.Timing;
|
||||
@@ -350,9 +349,10 @@ namespace Robust.Shared.GameObjects
|
||||
private protected Entity AllocEntity(string? prototypeName, EntityUid? uid = null)
|
||||
{
|
||||
EntityPrototype? prototype = null;
|
||||
if(!string.IsNullOrWhiteSpace(prototypeName) && !PrototypeManager.TryIndex<EntityPrototype>(prototypeName, out prototype))
|
||||
if (!string.IsNullOrWhiteSpace(prototypeName))
|
||||
{
|
||||
Logger.Error($"Invalid prototypeId '{prototypeName}' passed to {nameof(AllocEntity)}.");
|
||||
// If the prototype doesn't exist then we throw BEFORE we allocate the entity.
|
||||
prototype = PrototypeManager.Index<EntityPrototype>(prototypeName);
|
||||
}
|
||||
|
||||
var entity = AllocEntity(uid);
|
||||
@@ -405,7 +405,7 @@ namespace Robust.Shared.GameObjects
|
||||
/// </summary>
|
||||
private protected virtual Entity CreateEntity(string? prototypeName, EntityUid? uid = null)
|
||||
{
|
||||
if (!string.IsNullOrWhiteSpace(prototypeName))
|
||||
if (prototypeName == null)
|
||||
return AllocEntity(uid);
|
||||
|
||||
var entity = AllocEntity(prototypeName, uid);
|
||||
|
||||
Reference in New Issue
Block a user