Exemplo n.º 1
0
 private void PopulateEntityList()
 {
     foreach (var entity in _serverEntityManager.GetEntities())
     {
         if (IsMapSavable(entity))
         {
             var uid = uidCounter++;
             EntityUidMap.Add(entity.Uid, uid);
             Entities.Add(entity);
         }
     }
 }
Exemplo n.º 2
0
            public override bool TryTypeToNode(object obj, out YamlNode node)
            {
                switch (obj)
                {
                case GridId gridId:
                    if (!GridIDMap.TryGetValue(gridId, out var gridMapped))
                    {
                        Logger.WarningS("map", "Cannot write grid ID '{0}', falling back to nullspace.", gridId);
                        break;
                    }
                    else
                    {
                        node = new YamlScalarNode(gridMapped.ToString(CultureInfo.InvariantCulture));
                        return(true);
                    }

                case EntityUid entityUid:
                    if (!EntityUidMap.TryGetValue(entityUid, out var entityUidMapped))
                    {
                        // Terrible hack to mute this warning on the grids themselves when serializing blueprints.
                        if (!IsBlueprintMode || !CurrentWritingEntity.HasComponent <MapGridComponent>() ||
                            CurrentWritingComponent != "Transform")
                        {
                            Logger.WarningS("map", "Cannot write entity UID '{0}'.", entityUid);
                        }

                        node = new YamlScalarNode("null");
                        return(true);
                    }
                    else
                    {
                        node = new YamlScalarNode(entityUidMapped.ToString(CultureInfo.InvariantCulture));
                        return(true);
                    }

                case IEntity entity:
                    if (!EntityUidMap.TryGetValue(entity.Uid, out var entityMapped))
                    {
                        Logger.WarningS("map", "Cannot write entity UID '{0}'.", entity.Uid);
                        break;
                    }
                    else
                    {
                        node = new YamlScalarNode(entityMapped.ToString(CultureInfo.InvariantCulture));
                        return(true);
                    }
                }
                node = null;
                return(false);
            }