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); }
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(); } }