Exemplo n.º 1
0
 protected virtual void EnteredRenderSet(object sender, RenderSetChangeEventArgs e)
 {
     if (Body != null)
     {
         Body.Enabled = (Set.Scene == e.To.Scene);
     }
 }
Exemplo n.º 2
0
 public virtual void OnRenderSetTransfer(object sender, RenderSetChangeEventArgs e)
 {
     if (RenderSetTransfer != null)
     {
         RenderSetTransfer(sender, e);
     }
 }
Exemplo n.º 3
0
 public virtual void OnRenderSetEntry(object sender, RenderSetChangeEventArgs e)
 {
     if (RenderSetEntry != null)
     {
         RenderSetEntry(sender, e);
     }
 }
Exemplo n.º 4
0
 protected override void EnteredRenderSet(object sender, RenderSetChangeEventArgs e)
 {
     if (Body != null)
     {
         Body.Enabled = (Set.Scene == e.To.Scene) && !_State;
     }
     PlayAnimation(_State ? Open : Close);
 }
Exemplo n.º 5
0
 protected void HandlerenderSetTransfer(object sender, RenderSetChangeEventArgs e)
 {
     this._RenderSet = e.To;
 }
Exemplo n.º 6
0
 public virtual void OnRenderSetTransfer(object sender, RenderSetChangeEventArgs e)
 {
     if(RenderSetTransfer != null)
         RenderSetTransfer(sender, e);
 }
Exemplo n.º 7
0
 public virtual void OnRenderSetEntry(object sender, RenderSetChangeEventArgs e)
 {
     if(RenderSetEntry != null)
         RenderSetEntry(sender, e);
 }
Exemplo n.º 8
0
 protected virtual void EnteredRenderSet(object sender, RenderSetChangeEventArgs e)
 {
     if(Body != null)
         Body.Enabled = (Set.Scene == e.To.Scene);
 }
Exemplo n.º 9
0
 public virtual void SetChange(object sender, RenderSetChangeEventArgs e)
 {
     this._RenderSet = e.To;
 }
Exemplo n.º 10
0
        protected void ChangeScene(Scene next_scene)
        {
            if (_CurrentScene == next_scene || next_scene == null)
                return;
            SceneChangeEventArgs scea = new SceneChangeEventArgs (_CurrentScene, next_scene);
            IEnumerable<RenderSet> next_sets = next_scene.AllRenderSetsInOrder ();
            IEnumerator<RenderSet> next_set_enum = next_sets.GetEnumerator ();
            IEnumerable<RenderSet> current_sets = null;
            IEnumerator<RenderSet> current_set_enum = null;
            RenderSetChangeEventArgs rscea;
            if (_CurrentScene != null) {
                // Get the enumerable for the render sets; these need to be in the same order!
                current_sets = _CurrentScene.AllRenderSetsInOrder ();
                current_set_enum = current_sets.GetEnumerator ();					// Enumerate from the beginning of the set enumerable
                foreach (RenderSet render_set in current_sets) {
                    if (!next_set_enum.MoveNext ())
                        break;
                    rscea = new RenderSetChangeEventArgs (render_set, next_set_enum.Current);
                    // Process this scene
                    for (int i = 0; i < render_set.Count;) {						// For each renderable in render set
                        var renderable = render_set [i];
                        if (renderable is ISceneElement) {							// If object also implements scene object
                            ISceneElement scene_object = (ISceneElement)renderable;	// Cast to scene object
                            if (scene_object is IWorldObject) {
                                IWorldObject world_object = (IWorldObject)scene_object;
                                // Disable the body object is not preserved
                                world_object.Body.Enabled &= world_object.Preserve;
                            }
                            if (scene_object.Preserve) { 							// If scene object is preserved
                                next_set_enum.Current.Add (renderable);				// Add in this object
                                render_set.RemoveAt (i);							// Remove from previous
                                scene_object.OnRenderSetTransfer (this, rscea);
                                continue;
                            }
                        }
                        i++;
                    }
                }
                foreach (RenderSet render_set in next_scene.AllRenderSetsInOrder()) {
                    if (!current_set_enum.MoveNext ())
                        break;
                    // Process next scene, PART 1
                    foreach (IRenderable renderable in render_set) {
                        if (renderable is ISceneElement) {							// If object also implements scene object
                            if (renderable is IWorldObject) {
                                IWorldObject world_object = (IWorldObject)renderable;
                                // HACK: temporarily enable all bodies in this renderset
                                // in order to allow deferred updates to affect bodies
                                if(world_object.Body != null)
                                    world_object.Body.Enabled = true;
                            }
                        }
                    }
                }
            }

            if (_CurrentScene != null)
                _CurrentScene.OnSceneExit (this, scea);

            // Enumerate from the beginning of the set enumerable
            if (_CurrentScene != null)
                current_set_enum = current_sets.GetEnumerator ();
            // Process next scene, PART 2
            foreach (RenderSet render_set in next_scene.AllRenderSetsInOrder()) {
                if (current_set_enum != null) {
                    if (!current_set_enum.MoveNext ())
                        break;
                    rscea = new RenderSetChangeEventArgs (current_set_enum.Current, render_set);
                } else
                    rscea = new RenderSetChangeEventArgs (null, render_set);
                foreach (IRenderable renderable in render_set) {
                    if (renderable is ISceneElement) {
                        ISceneElement scene_element = (ISceneElement)renderable;
                        // Body.Enabled should be updated with a RenderSetEntry event handler
                        scene_element.OnRenderSetEntry (this, rscea);
                    }
                }
            }
            var last_scene = _CurrentScene;
            if (last_scene != null) {
                if(last_scene.FollowTarget == null)
                    next_scene.Follow (null);
                else if(last_scene.FollowTarget.Preserve)
                    next_scene.Follow (last_scene.FollowTarget, true);
            }
            next_scene.OnSceneEntry (next_scene, scea);
            _CurrentScene = next_scene; // Update the scene reference
            GC.Collect();
        }
Exemplo n.º 11
0
Arquivo: Line.cs Projeto: qwook/hungry
 public virtual void SetChange(object sender, RenderSetChangeEventArgs e)
 {
     this._RenderSet = e.To;
 }
Exemplo n.º 12
0
 protected override void EnteredRenderSet(object sender, RenderSetChangeEventArgs e)
 {
     Body.Enabled = (Set.Scene == e.To.Scene) && _State;
 }
Exemplo n.º 13
0
        protected void ChangeScene(Scene next_scene)
        {
            if (_CurrentScene == next_scene || next_scene == null)
            {
                return;
            }
            SceneChangeEventArgs     scea             = new SceneChangeEventArgs(_CurrentScene, next_scene);
            IEnumerable <RenderSet>  next_sets        = next_scene.AllRenderSetsInOrder();
            IEnumerator <RenderSet>  next_set_enum    = next_sets.GetEnumerator();
            IEnumerable <RenderSet>  current_sets     = null;
            IEnumerator <RenderSet>  current_set_enum = null;
            RenderSetChangeEventArgs rscea;

            if (_CurrentScene != null)
            {
                // Get the enumerable for the render sets; these need to be in the same order!
                current_sets     = _CurrentScene.AllRenderSetsInOrder();
                current_set_enum = current_sets.GetEnumerator();                                        // Enumerate from the beginning of the set enumerable
                foreach (RenderSet render_set in current_sets)
                {
                    if (!next_set_enum.MoveNext())
                    {
                        break;
                    }
                    rscea = new RenderSetChangeEventArgs(render_set, next_set_enum.Current);
                    // Process this scene
                    for (int i = 0; i < render_set.Count;)                                              // For each renderable in render set
                    {
                        var renderable = render_set [i];
                        if (renderable is ISceneElement)                                // If object also implements scene object
                        {
                            ISceneElement scene_object = (ISceneElement)renderable;     // Cast to scene object
                            if (scene_object is IWorldObject)
                            {
                                IWorldObject world_object = (IWorldObject)scene_object;
                                // Disable the body object is not preserved
                                world_object.Body.Enabled &= world_object.Preserve;
                            }
                            if (scene_object.Preserve)                                          // If scene object is preserved
                            {
                                next_set_enum.Current.Add(renderable);                          // Add in this object
                                render_set.RemoveAt(i);                                         // Remove from previous
                                scene_object.OnRenderSetTransfer(this, rscea);
                                continue;
                            }
                        }
                        i++;
                    }
                }
                foreach (RenderSet render_set in next_scene.AllRenderSetsInOrder())
                {
                    if (!current_set_enum.MoveNext())
                    {
                        break;
                    }
                    // Process next scene, PART 1
                    foreach (IRenderable renderable in render_set)
                    {
                        if (renderable is ISceneElement)                                                        // If object also implements scene object
                        {
                            if (renderable is IWorldObject)
                            {
                                IWorldObject world_object = (IWorldObject)renderable;
                                // HACK: temporarily enable all bodies in this renderset
                                // in order to allow deferred updates to affect bodies
                                if (world_object.Body != null)
                                {
                                    world_object.Body.Enabled = true;
                                }
                            }
                        }
                    }
                }
            }

            if (_CurrentScene != null)
            {
                _CurrentScene.OnSceneExit(this, scea);
            }

            // Enumerate from the beginning of the set enumerable
            if (_CurrentScene != null)
            {
                current_set_enum = current_sets.GetEnumerator();
            }
            // Process next scene, PART 2
            foreach (RenderSet render_set in next_scene.AllRenderSetsInOrder())
            {
                if (current_set_enum != null)
                {
                    if (!current_set_enum.MoveNext())
                    {
                        break;
                    }
                    rscea = new RenderSetChangeEventArgs(current_set_enum.Current, render_set);
                }
                else
                {
                    rscea = new RenderSetChangeEventArgs(null, render_set);
                }
                foreach (IRenderable renderable in render_set)
                {
                    if (renderable is ISceneElement)
                    {
                        ISceneElement scene_element = (ISceneElement)renderable;
                        // Body.Enabled should be updated with a RenderSetEntry event handler
                        scene_element.OnRenderSetEntry(this, rscea);
                    }
                }
            }
            var last_scene = _CurrentScene;

            if (last_scene != null)
            {
                if (last_scene.FollowTarget == null)
                {
                    next_scene.Follow(null);
                }
                else if (last_scene.FollowTarget.Preserve)
                {
                    next_scene.Follow(last_scene.FollowTarget, true);
                }
            }
            next_scene.OnSceneEntry(next_scene, scea);
            _CurrentScene = next_scene; // Update the scene reference
            GC.Collect();
        }
Exemplo n.º 14
0
 protected void HandlerenderSetTransfer(object sender, RenderSetChangeEventArgs e)
 {
     this._RenderSet = e.To;
 }