Development Merge 2025.10.18 #4
							
								
								
									
										6
									
								
								Engine.Core/Systems/Abstract/ILastFrameUpdate.cs
									
									
									
									
									
										Normal file
									
								
							
							
						
						
									
										6
									
								
								Engine.Core/Systems/Abstract/ILastFrameUpdate.cs
									
									
									
									
									
										Normal file
									
								
							@@ -0,0 +1,6 @@
 | 
			
		||||
namespace Syntriax.Engine.Core;
 | 
			
		||||
 | 
			
		||||
public interface ILastFrameUpdate : IBehaviour
 | 
			
		||||
{
 | 
			
		||||
    void LastActiveFrame();
 | 
			
		||||
}
 | 
			
		||||
@@ -8,6 +8,7 @@ public class UpdateManager : Behaviour
 | 
			
		||||
    private static Comparer<IBehaviour> SortByAscendingPriority() => Comparer<IBehaviour>.Create((x, y) => x.Priority.CompareTo(y.Priority));
 | 
			
		||||
 | 
			
		||||
    private readonly ActiveBehaviourCollectorSorted<IFirstFrameUpdate> firstFrameUpdates = new() { SortBy = SortByAscendingPriority() };
 | 
			
		||||
    private readonly ActiveBehaviourCollector<ILastFrameUpdate> lastFrameUpdates = new();
 | 
			
		||||
    private readonly ActiveBehaviourCollectorSorted<IPreUpdate> preUpdateEntities = new() { SortBy = SortByAscendingPriority() };
 | 
			
		||||
    private readonly ActiveBehaviourCollectorSorted<IUpdate> updateEntities = new() { SortBy = SortByAscendingPriority() };
 | 
			
		||||
    private readonly ActiveBehaviourCollectorSorted<IPostUpdate> postUpdateEntities = new() { SortBy = SortByAscendingPriority() };
 | 
			
		||||
@@ -17,6 +18,7 @@ public class UpdateManager : Behaviour
 | 
			
		||||
    protected override void OnEnteredUniverse(IUniverse universe)
 | 
			
		||||
    {
 | 
			
		||||
        firstFrameUpdates.Assign(universe);
 | 
			
		||||
        lastFrameUpdates.Assign(universe);
 | 
			
		||||
        preUpdateEntities.Assign(universe);
 | 
			
		||||
        updateEntities.Assign(universe);
 | 
			
		||||
        postUpdateEntities.Assign(universe);
 | 
			
		||||
@@ -29,6 +31,7 @@ public class UpdateManager : Behaviour
 | 
			
		||||
    protected override void OnExitedUniverse(IUniverse universe)
 | 
			
		||||
    {
 | 
			
		||||
        firstFrameUpdates.Unassign();
 | 
			
		||||
        lastFrameUpdates.Unassign();
 | 
			
		||||
        preUpdateEntities.Unassign();
 | 
			
		||||
        updateEntities.Unassign();
 | 
			
		||||
        postUpdateEntities.Unassign();
 | 
			
		||||
@@ -67,8 +70,14 @@ public class UpdateManager : Behaviour
 | 
			
		||||
        toCallFirstFrameUpdates.Add(args.BehaviourCollected);
 | 
			
		||||
    }
 | 
			
		||||
 | 
			
		||||
    private void OnLastFrameRemoved(IBehaviourCollector<ILastFrameUpdate> sender, IBehaviourCollector<ILastFrameUpdate>.BehaviourRemovedArguments args)
 | 
			
		||||
    {
 | 
			
		||||
        args.BehaviourRemoved.LastActiveFrame();
 | 
			
		||||
    }
 | 
			
		||||
 | 
			
		||||
    public UpdateManager()
 | 
			
		||||
    {
 | 
			
		||||
        firstFrameUpdates.OnCollected.AddListener(OnFirstFrameCollected);
 | 
			
		||||
        lastFrameUpdates.OnRemoved.AddListener(OnLastFrameRemoved);
 | 
			
		||||
    }
 | 
			
		||||
}
 | 
			
		||||
 
 | 
			
		||||
		Reference in New Issue
	
	Block a user