protected override bool TryGetLayers(ContainerModifiedMessage msg, ItemMapperComponent itemMapper, out IReadOnlyList <string> showLayers) { if (EntityManager.TryGetComponent(msg.Container.Owner, out ServerStorageComponent? component)) { var containedLayers = component.StoredEntities ?? new List <EntityUid>(); var list = new List <string>(); foreach (var mapLayerData in itemMapper.MapLayers.Values) { foreach (var entity in containedLayers) { if (mapLayerData.Whitelist.IsValid(entity)) { list.Add(mapLayerData.Layer); break; } } } showLayers = list; return(true); } showLayers = new List <string>(); return(false); }
private void InitLayers(EntityUid uid, ItemMapperComponent component, ComponentInit args) { if (EntityManager.TryGetComponent(component.Owner, out AppearanceComponent? appearanceComponent)) { var list = new List <string>(component.MapLayers.Keys); appearanceComponent.SetData(StorageMapVisuals.InitLayers, new ShowLayerData(list)); } }
private void MapperEntityInserted(EntityUid uid, ItemMapperComponent itemMapper, EntInsertedIntoContainerMessage args) { if (EntityManager.TryGetComponent(itemMapper.Owner, out AppearanceComponent? appearanceComponent) && TryGetLayers(args, itemMapper, out var containedLayers)) { appearanceComponent.SetData(StorageMapVisuals.LayerChanged, new ShowLayerData(containedLayers)); } }
private void MapperEntityRemoved(EntityUid uid, ItemMapperComponent itemMapper, EntRemovedFromContainerMessage args) { if (itemMapper.Owner.TryGetComponent(out SharedAppearanceComponent? appearanceComponent) && TryGetLayers(args, itemMapper, out var containedLayers)) { appearanceComponent.SetData(StorageMapVisuals.LayerChanged, new ShowLayerData(containedLayers)); } }
protected override bool TryGetLayers(ContainerModifiedMessage msg, ItemMapperComponent itemMapper, out IReadOnlyList <string> showLayers) { var containedLayers = _containerSystem.GetAllContainers(msg.Container.Owner) .SelectMany(cont => cont.ContainedEntities).ToArray(); var list = new List <string>(); foreach (var mapLayerData in itemMapper.MapLayers.Values) { var count = containedLayers.Count(uid => mapLayerData.ServerWhitelist.IsValid(uid)); if (count >= mapLayerData.MinCount && count <= mapLayerData.MaxCount) { list.Add(mapLayerData.Layer); } } showLayers = list; return(true); }
protected abstract bool TryGetLayers(ContainerModifiedMessage msg, ItemMapperComponent itemMapper, out IReadOnlyList <string> containedLayers);