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);
        }
Esempio n. 2
0
 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));
     }
 }
Esempio n. 3
0
 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));
     }
 }
Esempio n. 4
0
 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));
     }
 }
Esempio n. 5
0
        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);
        }
Esempio n. 6
0
 protected abstract bool TryGetLayers(ContainerModifiedMessage msg,
                                      ItemMapperComponent itemMapper,
                                      out IReadOnlyList <string> containedLayers);