From 4449813f9952bd1bf148be32092892eed6d73947 Mon Sep 17 00:00:00 2001 From: Brent De Weerdt Date: Fri, 13 Nov 2015 19:07:21 +0100 Subject: [PATCH 1/2] Expose the interval in IntervalSystem This change makes it possible for subclasses to access the interval directly, without having to create a custom constructor. --- .../com/badlogic/ashley/systems/IntervalSystem.java | 10 +++++++--- 1 file changed, 7 insertions(+), 3 deletions(-) diff --git a/ashley/src/com/badlogic/ashley/systems/IntervalSystem.java b/ashley/src/com/badlogic/ashley/systems/IntervalSystem.java index a3dd4095..09659df2 100644 --- a/ashley/src/com/badlogic/ashley/systems/IntervalSystem.java +++ b/ashley/src/com/badlogic/ashley/systems/IntervalSystem.java @@ -1,12 +1,12 @@ /******************************************************************************* * Copyright 2014 See AUTHORS file. - * + * * Licensed under the Apache License, Version 2.0 (the "License"); * you may not use this file except in compliance with the License. * You may obtain a copy of the License at - * + * * http://www.apache.org/licenses/LICENSE-2.0 - * + * * Unless required by applicable law or agreed to in writing, software * distributed under the License is distributed on an "AS IS" BASIS, * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. @@ -44,6 +44,10 @@ public IntervalSystem (float interval, int priority) { this.accumulator = 0; } + public float getInterval() { + return interval; + } + @Override public final void update (float deltaTime) { accumulator += deltaTime; From 0fc1a06245649da24ca60fba96f01cd5f0e69424 Mon Sep 17 00:00:00 2001 From: Brent De Weerdt Date: Fri, 13 Nov 2015 23:17:05 +0100 Subject: [PATCH 2/2] Add unit test for IntervalSystem.getInterval() --- .../badlogic/ashley/systems/IntervalSystemTest.java | 12 +++++++++--- 1 file changed, 9 insertions(+), 3 deletions(-) diff --git a/ashley/tests/com/badlogic/ashley/systems/IntervalSystemTest.java b/ashley/tests/com/badlogic/ashley/systems/IntervalSystemTest.java index afac5172..0ea236c0 100644 --- a/ashley/tests/com/badlogic/ashley/systems/IntervalSystemTest.java +++ b/ashley/tests/com/badlogic/ashley/systems/IntervalSystemTest.java @@ -1,12 +1,12 @@ /******************************************************************************* * Copyright 2014 See AUTHORS file. - * + * * Licensed under the Apache License, Version 2.0 (the "License"); * you may not use this file except in compliance with the License. * You may obtain a copy of the License at - * + * * http://www.apache.org/licenses/LICENSE-2.0 - * + * * Unless required by applicable law or agreed to in writing, software * distributed under the License is distributed on an "AS IS" BASIS, * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. @@ -50,4 +50,10 @@ public void intervalSystem () { assertEquals(i / 2, intervalSystemSpy.numUpdates); } } + + @Test + public void testGetInterval () { + IntervalSystemSpy intervalSystemSpy = new IntervalSystemSpy(); + assertEquals(intervalSystemSpy.getInterval(), deltaTime * 2.0f, 0); + } }