Exemplo n.º 1
0
        /// <summary>
        /// Adds a new scene to the scenemanager.
        /// </summary>
        /// <param name="scene">The scene.</param>
        public void AddScene(Scene scene)
        {
            if (scene == null)
            {
                return;
            }

            if (!scenes.ContainsKey(scene.Name))
            {
                scenes.Add(scene.Name, scene);
                SceneAdded?.Invoke(this, new SceneEventArgs(scene));
            }
            else
            {
                throw new Exception("The scene '" + scene.Name + "' is already in the scene manager.");
            }
        }
Exemplo n.º 2
0
        /// <summary>
        /// Adds a new scene with the provided <paramref name="sceneId"/>.
        /// </summary>
        /// <param name="sceneId">The identifier of the scene to add.</param>
        /// <param name="parentId">The identifier of an existing parent scene, or <see cref="Guid.Empty"/>.</param>
        public void AddScene(Guid sceneId, Guid parentId)
        {
            if (sceneId == Guid.Empty)
            {
                throw new InvalidOperationException($"{nameof(sceneId)} cannot be {nameof(Guid.Empty)}.");
            }
            if (scenes.ContainsKey(sceneId))
            {
                throw new InvalidOperationException($"A scene matching the given {sceneId}, already exists.");
            }

            EnsureContentScene();

            var scene = new Scene {
                Id = sceneId
            };
            var parent = parentId != Guid.Empty ? GetScene(parentId) : ContentScene;

            AddSceneToParent(scene, parent);
            scenes.Add(sceneId, scene);
            SceneAdded?.Invoke(scene);
        }