Skip to content

Commit 85b6df7

Browse files
committed
Added AbstractMovementTarget and a terminate method.
Prepping for a new release.
1 parent 7013845 commit 85b6df7

File tree

6 files changed

+75
-8
lines changed

6 files changed

+75
-8
lines changed

build.gradle

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -14,7 +14,7 @@ buildscript {
1414
apply plugin: 'java'
1515
apply plugin: 'maven'
1616

17-
version='1.4.1-SNAPSHOT'
17+
version='1.5.0'
1818
group='com.simsilica'
1919

2020
ext.jmeVersion = "3.2.1-stable"

release-notes.md

Lines changed: 4 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -1,7 +1,9 @@
1-
Version 1.4.1 (unreleased)
1+
Version 1.5.0 (unreleased)
22
--------------
3-
* Added an initialize method to MovementTarget for the MovementState to
3+
* Added an initialize and terminate methods to MovementTarget for the MovementState to
44
call when the target is set.
5+
* Added an AbstractMovementTarget class to shield subclasses from future interface
6+
changes.
57

68

79
Version 1.4.0 (latest)
Lines changed: 61 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,61 @@
1+
/*
2+
* $Id$
3+
*
4+
* Copyright (c) 2020, Simsilica, LLC
5+
* All rights reserved.
6+
*
7+
* Redistribution and use in source and binary forms, with or without
8+
* modification, are permitted provided that the following conditions
9+
* are met:
10+
*
11+
* 1. Redistributions of source code must retain the above copyright
12+
* notice, this list of conditions and the following disclaimer.
13+
*
14+
* 2. Redistributions in binary form must reproduce the above copyright
15+
* notice, this list of conditions and the following disclaimer in
16+
* the documentation and/or other materials provided with the
17+
* distribution.
18+
*
19+
* 3. Neither the name of the copyright holder nor the names of its
20+
* contributors may be used to endorse or promote products derived
21+
* from this software without specific prior written permission.
22+
*
23+
* THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS
24+
* "AS IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT
25+
* LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS
26+
* FOR A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE
27+
* COPYRIGHT HOLDER OR CONTRIBUTORS BE LIABLE FOR ANY DIRECT,
28+
* INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES
29+
* (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR
30+
* SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION)
31+
* HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT,
32+
* STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE)
33+
* ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED
34+
* OF THE POSSIBILITY OF SUCH DAMAGE.
35+
*/
36+
37+
package com.simsilica.input;
38+
39+
import com.simsilica.mathd.*;
40+
41+
/**
42+
*
43+
*
44+
* @author Paul Speed
45+
*/
46+
public abstract class AbstractMovementTarget implements MovementTarget {
47+
48+
/**
49+
* Default implementation does nothing.
50+
*/
51+
@Override
52+
public void initialize( MovementState state ) {
53+
}
54+
55+
/**
56+
* Default implementation does nothing.
57+
*/
58+
@Override
59+
public void terminate( MovementState state ) {
60+
}
61+
}

src/main/java/com/simsilica/input/CameraMovementTarget.java

Lines changed: 1 addition & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -47,7 +47,7 @@
4747
*
4848
* @author Paul Speed
4949
*/
50-
public class CameraMovementTarget implements MovementTarget {
50+
public class CameraMovementTarget extends AbstractMovementTarget {
5151

5252
private Camera camera;
5353
private boolean relativeForward = true;
@@ -90,10 +90,6 @@ public boolean isRelativeUp() {
9090
return relativeUp;
9191
}
9292

93-
@Override
94-
public void initialize( MovementState state ) {
95-
}
96-
9793
@Override
9894
public void move( Quatd rotation, Vec3d movementForces, double tpf ) {
9995
if( movementForces.lengthSq() == 0 ) {

src/main/java/com/simsilica/input/MovementState.java

Lines changed: 3 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -91,6 +91,9 @@ public MovementState() {
9191
* target has been provided.
9292
*/
9393
public void setMovementTarget( MovementTarget target ) {
94+
if( this.target != null ) {
95+
this.target.terminate(this);
96+
}
9497
this.target = target;
9598
target.initialize(this);
9699
initializeRotation(target.getRotation());

src/main/java/com/simsilica/input/MovementTarget.java

Lines changed: 5 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -49,6 +49,11 @@ public interface MovementTarget {
4949
* Called when the target is first set to the MovementState.
5050
*/
5151
public void initialize( MovementState state );
52+
53+
/**
54+
* Called when the target is removed/replace in the MovementState.
55+
*/
56+
public void terminate( MovementState state );
5257

5358
/**
5459
* Called once per frame to let the target update its position

0 commit comments

Comments
 (0)