Beispiel #1
0
        public IWorld CreateWorld(Identifier name)
        {
            if (_worlds.TryGetValue(name, out var world))
            {
                return(world);
            }

            world = new World(this, _globalPalette);
            WorldCreated?.Invoke(this, new WorldEventArgs(world));
            return(_worlds[name] = world);
        }
Beispiel #2
0
        protected WorldBase(IWorldOptions options, IWorldCreator worldCreator)
        {
            if (worldCreator is null)
            {
                throw new ArgumentNullException(nameof(worldCreator));
            }

            Options = options ?? throw new ArgumentNullException(nameof(options));

            WorldCreator = worldCreator;

            worldCreator.WorldCreated += () => WorldCreated?.Invoke();

            WorldCreated += OnWorldCreated;

            if (Options.CreateWorldOnInstantiate)
            {
                CreateWorld();
            }
        }