示例#1
0
        private static void LoadWorldObjectsLayer(this Layout layout, string spawnPoint, List <OgmoEntity> entities)
        {
            // Filter out any spawn points that don't need to exist.
            if (HasManySpawnPoints(entities))
            {
                // If there are many spawn points and no default was given, just choose the first one.
                if (string.IsNullOrEmpty(spawnPoint))
                {
                    var firstSpawnPoint = entities.First(e => e.Name == "OverworldPlayerSpawnPoint");
                    entities.RemoveAll(e => e.Name == "OverworldPlayerSpawnPoint" && e != firstSpawnPoint);
                }
                else
                {
                    entities.RemoveAll(e => e.Name == "OverworldPlayerSpawnPoint" && spawnPoint != e.Values.SpawnPointName);
                }
            }

            var definitions = DefinitionList.GetDefinitions();

            foreach (var entity in entities)
            {
                var definition  = definitions.Get(entity.Name);
                var worldObject = layout.Objects.Create(definition, new Vector2(entity.X, entity.Y));

                // Default properties for every world object.
                worldObject.IsMirrored = entity.FlippedX;

                Loaders.Load(definition.Guid, worldObject, entity);
            }
        }
 public static void LoadFromOgmo(this WorldObjectDefinition definition, Action <WorldObject, OgmoEntity> loader)
 {
     Loaders.Register(definition.Guid, loader);
 }