Exemplo n.º 1
0
        private void LoadEntNode(IMap map, GridId gridId, YamlSequenceNode entNode)
        {
            foreach (var yamlNode in entNode.Children)
            {
                var yamlEnt = (YamlMappingNode)yamlNode;

                var protoName = yamlEnt["id"].ToString();
                var entity    = _entityMan.SpawnEntity(protoName);

                _protoMan.LoadData(entity, yamlEnt);

                // overwrite local position in the BP to the new map/grid ID
                var transform = entity.GetComponent <IServerTransformComponent>();
                transform.LocalPosition = new LocalCoordinates(transform.LocalPosition.Position, gridId, map.Index);
            }
        }
Exemplo n.º 2
0
        private void LoadEntNode(IMap map, GridId?gridId, YamlSequenceNode entNode)
        {
            foreach (var yamlNode in entNode.Children)
            {
                var yamlEnt = (YamlMappingNode)yamlNode;

                var protoName = yamlEnt["id"].ToString();

                try
                {
                    var entity = _entityMan.SpawnEntity(protoName);

                    _protoMan.LoadData(entity, yamlEnt);

                    // overwrite local position in the BP to the new map/grid ID
                    var transform = entity.GetComponent <IServerTransformComponent>();
                    transform.LocalPosition = new GridLocalCoordinates(transform.LocalPosition.Position, gridId.Value);
                }
                catch (Exception e)
                {
                    Logger.ErrorS("map", $"Error creating entity \"{protoName}\": {e.Message}");
                }
            }
        }