From 1a658958d658a5e308b30c2e89aaa3aae223bbad Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?J=C3=A9r=C3=A9my=20Zurcher?= Date: Thu, 31 Mar 2016 19:53:51 +0200 Subject: Ctrl: add private Event getEvent() --- core/src/ch/asynk/rustanddust/game/Ctrl.java | 16 ++++++++++------ 1 file changed, 10 insertions(+), 6 deletions(-) diff --git a/core/src/ch/asynk/rustanddust/game/Ctrl.java b/core/src/ch/asynk/rustanddust/game/Ctrl.java index f7a3ae8..01a3748 100644 --- a/core/src/ch/asynk/rustanddust/game/Ctrl.java +++ b/core/src/ch/asynk/rustanddust/game/Ctrl.java @@ -164,14 +164,20 @@ public abstract class Ctrl implements Disposable // EVENTS + private Event getEvent() + { + Event evt = freeEvents.pop(); + if (evt == null) + evt = new Event(); + return evt; + } + public void postDone() { post(StateType.DONE); } public void postAbort() { post(StateType.ABORT); } public void post(StateType stateType) { - Event evt = freeEvents.pop(); - if (evt == null) - evt = new Event(); + Event evt = getEvent(); evt.type = Event.Type.STATE_CHANGE; evt.data = stateType; events.enqueue(evt); @@ -179,9 +185,7 @@ public abstract class Ctrl implements Disposable public void postAnswer(Hud.OkCancelAction what, boolean status) { - Event evt = freeEvents.pop(); - if (evt == null) - evt = new Event(); + Event evt = getEvent(); evt.type = Event.Type.HUD_ANSWER; evt.data = what; evt.status = status; -- cgit v1.1-2-g2b99