-
Notifications
You must be signed in to change notification settings - Fork 19
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Merge pull request #7 from TheDudeFromCI/quality-of-life-tweaks
Quality of life tweaks
- Loading branch information
Showing
43 changed files
with
1,828 additions
and
934 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file was deleted.
Oops, something went wrong.
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,57 @@ | ||
package net.whg.we.main; | ||
|
||
import java.util.List; | ||
import java.util.concurrent.CopyOnWriteArrayList; | ||
|
||
/** | ||
* The physics pipeline action is an action in charge of triggering physics | ||
* updates each frame based on the physics framerate. | ||
*/ | ||
public class PhysicsPipeline implements IPipelineAction | ||
{ | ||
private final List<IFixedUpdateable> objects = new CopyOnWriteArrayList<>(); | ||
private final Timer timer; | ||
|
||
/** | ||
* Creates a new Physics pipeline action. | ||
* | ||
* @param timer | ||
* - The timer to being this action to. | ||
*/ | ||
public PhysicsPipeline(Timer timer) | ||
{ | ||
this.timer = timer; | ||
} | ||
|
||
@Override | ||
public void run() | ||
{ | ||
while (timer.getPhysicsFrame() < timer.getIdealPhysicsFrame()) | ||
{ | ||
timer.incrementPhysicsFrame(); | ||
|
||
for (IFixedUpdateable obj : objects) | ||
obj.fixedUpdate(); | ||
} | ||
} | ||
|
||
@Override | ||
public void enableBehavior(AbstractBehavior behavior) | ||
{ | ||
if (behavior instanceof IFixedUpdateable) | ||
objects.add((IFixedUpdateable) behavior); | ||
} | ||
|
||
@Override | ||
public void disableBehavior(AbstractBehavior behavior) | ||
{ | ||
if (behavior instanceof IFixedUpdateable) | ||
objects.remove((IFixedUpdateable) behavior); | ||
} | ||
|
||
@Override | ||
public int getPriority() | ||
{ | ||
return PipelineConstants.PHYSICS_UPDATES; | ||
} | ||
} |
Oops, something went wrong.