mirror of
https://github.com/space-wizards/RobustToolbox.git
synced 2026-09-07 02:08:17 +02:00
* bubble implementation include contained entities fix line edit crash when clipboard contents are null somehow use CVar for update bubble range remove seenMovers that get NaN'd out of MaxUpdateRange - huge reduction in network traffic from bullets cut default of MaxUpdateRange down to 12.5 for now maybe handle teleported things handle removing player state on disconnect fixed positional audio errors make UpdateEntityTree also update player's last seen ents make net.maxupdaterange cvar tunable at runtime w/o impacting performance back to position nan as means to hide from client revert work pooling as the wrong player was getting the wrong game state ffs needed to think less about *if* something is *seen* and more about *when* it must be *unseen* clean up usings handle parenting and sequencing issues that arise on the client gather needed ents to update recursively applied suggestions from code review fix missing recursively contained ents make assumption that client last saw things on first tick instead of tick zero, as zero would be the "from tick" and first would be he "to tick" add First tick as constant to GameTick due to relevance above renamed includedEnts to checkedEnts to make usage more clear added comments inverted some conditions to flatten parts of the pvs logic fixed sending states when already seen (lastChange < lastSeen to lastChange <= lastSeen) fix sending states when no actual changes (other bugs?) local caching of currentTick, remove priorTick * make TransformComponent's Parent setter call Dirty() to handle replicating network state if AttachParent isn't invoked * fixed parent changed by setting Parent on Transform not updating parent's Children collection and other stuff rotating parent entities now are visible with their orbiting children if one of their children moves into view * break out duplicated code as GetLastSeen * remove unused net.parallelstates introduce net.pvs to configure enabling/disabling PVS
154 lines
4.7 KiB
C#
154 lines
4.7 KiB
C#
using System;
|
|
using System.Collections.Generic;
|
|
using System.Linq;
|
|
using Robust.Shared.GameObjects;
|
|
using Robust.Shared.GameObjects.Components.Containers;
|
|
using Robust.Shared.Interfaces.GameObjects;
|
|
using Robust.Shared.Interfaces.GameObjects.Components;
|
|
using Robust.Shared.ViewVariables;
|
|
|
|
namespace Robust.Client.GameObjects.Components.Containers
|
|
{
|
|
public sealed partial class ContainerManagerComponent : SharedContainerManagerComponent
|
|
{
|
|
[ViewVariables]
|
|
private readonly Dictionary<string, ClientContainer> _containers = new Dictionary<string, ClientContainer>();
|
|
|
|
public override T MakeContainer<T>(string id)
|
|
{
|
|
throw new NotSupportedException("Cannot modify containers on the client.");
|
|
}
|
|
|
|
public override bool Remove(IEntity entity)
|
|
{
|
|
// TODO: This will probably need relaxing if we want to predict things like inventories.
|
|
throw new NotSupportedException("Cannot modify containers on the client.");
|
|
}
|
|
|
|
public override IEnumerable<IContainer> GetAllContainers() =>
|
|
_containers.Values.Where(c => !c.Deleted);
|
|
|
|
public override IContainer GetContainer(string id)
|
|
{
|
|
return _containers[id];
|
|
}
|
|
|
|
public override bool HasContainer(string id)
|
|
{
|
|
return _containers.ContainsKey(id);
|
|
}
|
|
|
|
public override bool TryGetContainer(string id, out IContainer container)
|
|
{
|
|
var ret = _containers.TryGetValue(id, out var cont);
|
|
container = cont;
|
|
return ret;
|
|
}
|
|
|
|
/// <inheritdoc />
|
|
public override bool TryGetContainer(IEntity entity, out IContainer container)
|
|
{
|
|
foreach (var contain in _containers.Values)
|
|
{
|
|
if (!contain.Deleted && contain.Contains(entity))
|
|
{
|
|
container = contain;
|
|
return true;
|
|
}
|
|
}
|
|
|
|
container = default;
|
|
return false;
|
|
}
|
|
|
|
public override bool ContainsEntity(IEntity entity)
|
|
{
|
|
foreach (var container in _containers.Values)
|
|
{
|
|
if (!container.Deleted && container.Contains(entity))
|
|
{
|
|
return true;
|
|
}
|
|
}
|
|
|
|
return false;
|
|
}
|
|
|
|
public override void ForceRemove(IEntity entity)
|
|
{
|
|
throw new NotSupportedException("Cannot modify containers on the client.");
|
|
}
|
|
|
|
public override void HandleComponentState(ComponentState curState, ComponentState nextState)
|
|
{
|
|
if(!(curState is ContainerManagerComponentState cast))
|
|
return;
|
|
|
|
// Delete now-gone containers.
|
|
List<string> toDelete = null;
|
|
foreach (var (id, container) in _containers)
|
|
{
|
|
if (!cast.Containers.ContainsKey(id))
|
|
{
|
|
container.Shutdown();
|
|
toDelete ??= new List<string>();
|
|
toDelete.Add(id);
|
|
}
|
|
}
|
|
|
|
if (toDelete != null)
|
|
{
|
|
foreach (var dead in toDelete)
|
|
{
|
|
_containers.Remove(dead);
|
|
}
|
|
}
|
|
|
|
// Add new containers and update existing contents.
|
|
foreach (var (id, contEnts) in cast.Containers)
|
|
{
|
|
var (show, entities) = contEnts;
|
|
|
|
if (!_containers.TryGetValue(id, out var container))
|
|
{
|
|
container = new ClientContainer(id, this);
|
|
_containers.Add(id, container);
|
|
}
|
|
|
|
// sync show flag
|
|
container.ShowContents = show;
|
|
|
|
// Remove gone entities.
|
|
List<IEntity> toRemove = null;
|
|
foreach (var entity in container.Entities)
|
|
{
|
|
if (!entities.Contains(entity.Uid))
|
|
{
|
|
toRemove ??= new List<IEntity>();
|
|
toRemove.Add(entity);
|
|
}
|
|
}
|
|
|
|
if (toRemove != null)
|
|
{
|
|
foreach (var goner in toRemove)
|
|
{
|
|
container.DoRemove(goner);
|
|
}
|
|
}
|
|
|
|
// Add new entities.
|
|
foreach (var uid in entities)
|
|
{
|
|
var entity = Owner.EntityManager.GetEntity(uid);
|
|
|
|
if (!container.Entities.Contains(entity))
|
|
{
|
|
container.DoInsert(entity);
|
|
}
|
|
}
|
|
}
|
|
}
|
|
}
|
|
}
|