Skip to content

Commit

Permalink
chore: clean up
Browse files Browse the repository at this point in the history
  • Loading branch information
vinceh121 committed Dec 1, 2023
1 parent 38e2337 commit 6dac92e
Show file tree
Hide file tree
Showing 78 changed files with 632 additions and 589 deletions.
2 changes: 1 addition & 1 deletion core/src/me/vinceh121/wanderer/ApplicationDelegate.java
Original file line number Diff line number Diff line change
Expand Up @@ -5,7 +5,7 @@
public abstract class ApplicationDelegate extends ApplicationAdapter {
protected final ApplicationMultiplexer applicationMultiplexer;

public ApplicationDelegate(ApplicationMultiplexer applicationMultiplexer) {
public ApplicationDelegate(final ApplicationMultiplexer applicationMultiplexer) {
this.applicationMultiplexer = applicationMultiplexer;
}
}
2 changes: 1 addition & 1 deletion core/src/me/vinceh121/wanderer/IPrototype.java
Original file line number Diff line number Diff line change
Expand Up @@ -16,6 +16,6 @@ public interface IPrototype {
* @return A new instance of the entity
*/
AbstractEntity create(Wanderer game);

void getAssetsToLoad(List<AssetDescriptor<?>> descriptors);
}
2 changes: 1 addition & 1 deletion core/src/me/vinceh121/wanderer/InputManager.java
Original file line number Diff line number Diff line change
Expand Up @@ -86,7 +86,7 @@ public void setDefaultBinds() {
this.bindings.put(Input.WALK_BACKWARDS, new Binding(Keys.S, DeviceType.KEYBOARD));
this.bindings.put(Input.JUMP, new Binding(Keys.SPACE, DeviceType.KEYBOARD));
this.bindings.put(Input.JUMP, new Binding(Buttons.RIGHT, DeviceType.MOUSE));

this.bindings.put(Input.FLY_RIGHT, new Binding(Keys.RIGHT, DeviceType.KEYBOARD));
this.bindings.put(Input.FLY_RIGHT, new Binding(Keys.D, DeviceType.KEYBOARD));
this.bindings.put(Input.FLY_LEFT, new Binding(Keys.LEFT, DeviceType.KEYBOARD));
Expand Down
53 changes: 27 additions & 26 deletions core/src/me/vinceh121/wanderer/MainMenu.java
Original file line number Diff line number Diff line change
Expand Up @@ -15,6 +15,7 @@
import com.badlogic.gdx.scenes.scene2d.utils.ClickListener;
import com.badlogic.gdx.utils.viewport.FitViewport;

import me.vinceh121.wanderer.i18n.I18N;
import me.vinceh121.wanderer.platform.audio.Sound3D;
import me.vinceh121.wanderer.platform.audio.SoundEmitter3D;
import me.vinceh121.wanderer.ui.OptionsView;
Expand All @@ -35,16 +36,16 @@ public void create() {
this.stage = new Stage(new FitViewport(1024, 1024));
Gdx.input.setInputProcessor(this.stage);

Skin skin = WandererConstants.getUISkin();
final Skin skin = WandererConstants.getUISkin();

this.tblMain = new TblMain(skin);
this.setView(this.tblMain);

this.tblSingleplayer = new TblSingleplayer(skin);

this.tblOptions = new OptionsView(skin);
this.tblOptions.setOnApply(() -> this.setView(tblMain));
this.tblOptions.setOnClose(() -> this.setView(tblMain));
this.tblOptions.setOnApply(() -> this.setView(this.tblMain));
this.tblOptions.setOnClose(() -> this.setView(this.tblMain));

final String music = "orig/book/music/danger3.wav";
WandererConstants.ASSET_MANAGER.load(music, Sound3D.class);
Expand All @@ -53,14 +54,14 @@ public void create() {
this.musicEmitter = this.music.playGeneral();
}

public void setView(Actor newView) {
public void setView(final Actor newView) {
this.stage.clear();
newView.setBounds(0, 0, 1024, 1024);
this.stage.addActor(newView);
}

@Override
public void resize(int width, int height) {
public void resize(final int width, final int height) {
this.stage.getViewport().update(width, height);
}

Expand All @@ -79,7 +80,7 @@ public void dispose() {
}

private class TblMain extends Table {
public TblMain(Skin skin) {
public TblMain(final Skin skin) {
super(skin);

final int buttonPadding = 12;
Expand All @@ -88,72 +89,72 @@ public TblMain(Skin skin) {
.padBottom(64);
this.row();

TextButton btnSingleplayer = new TextButton(gettext("Single player"), this.getSkin());
final TextButton btnSingleplayer = new TextButton(I18N.gettext("Single player"), this.getSkin());
btnSingleplayer.addListener(new ClickListener() {
@Override
public void clicked(InputEvent event, float x, float y) {
setView(tblSingleplayer);
public void clicked(final InputEvent event, final float x, final float y) {
MainMenu.this.setView(MainMenu.this.tblSingleplayer);
}
});
this.add(btnSingleplayer).padBottom(buttonPadding);
this.row();

this.add(new TextButton(gettext("Multiplayer"), this.getSkin())).padBottom(buttonPadding);
this.add(new TextButton(I18N.gettext("Multiplayer"), this.getSkin())).padBottom(buttonPadding);
this.row();

TextButton btnOptions = new TextButton(gettext("Options"), this.getSkin());
final TextButton btnOptions = new TextButton(I18N.gettext("Options"), this.getSkin());
btnOptions.addListener(new ClickListener() {
@Override
public void clicked(InputEvent event, float x, float y) {
setView(tblOptions);
public void clicked(final InputEvent event, final float x, final float y) {
MainMenu.this.setView(MainMenu.this.tblOptions);
}
});
this.add(btnOptions).padBottom(buttonPadding);
this.row();

TextButton btnQuit = new TextButton(gettext("Quit"), this.getSkin());
final TextButton btnQuit = new TextButton(I18N.gettext("Quit"), this.getSkin());
btnQuit.addListener(new ClickListener() {
@Override
public void clicked(InputEvent event, float x, float y) {
public void clicked(final InputEvent event, final float x, final float y) {
Gdx.app.exit();
}
});
this.add(btnQuit).padBottom(buttonPadding);
this.row();

this.add(new TextButton(gettext("Credits"), this.getSkin())).padBottom(buttonPadding);
this.add(new TextButton(I18N.gettext("Credits"), this.getSkin())).padBottom(buttonPadding);
}
}

private class TblSingleplayer extends Table {

public TblSingleplayer(Skin skin) {
public TblSingleplayer(final Skin skin) {
super(skin);

final int buttonPadding = 12;

TextButton btnNewGame = new TextButton(gettext("New Game"), this.getSkin());
final TextButton btnNewGame = new TextButton(I18N.gettext("New Game"), this.getSkin());
btnNewGame.addListener(new ClickListener() {
@Override
public void clicked(InputEvent event, float x, float y) {
StoryWanderer story = new StoryWanderer(applicationMultiplexer);
public void clicked(final InputEvent event, final float x, final float y) {
final StoryWanderer story = new StoryWanderer(MainMenu.this.applicationMultiplexer);
story.create();
story.resize(Gdx.graphics.getWidth(), Gdx.graphics.getHeight());
applicationMultiplexer.setDelegate(story);
dispose();
MainMenu.this.applicationMultiplexer.setDelegate(story);
MainMenu.this.dispose();
}
});
this.add(btnNewGame).padBottom(buttonPadding);
this.row();

this.add(new TextButton(gettext("Load Game"), this.getSkin())).padBottom(buttonPadding);
this.add(new TextButton(I18N.gettext("Load Game"), this.getSkin())).padBottom(buttonPadding);
this.row();

TextButton btnCancel = new TextButton(gettext("Cancel"), this.getSkin());
final TextButton btnCancel = new TextButton(I18N.gettext("Cancel"), this.getSkin());
btnCancel.addListener(new ClickListener() {
@Override
public void clicked(InputEvent event, float x, float y) {
setView(tblMain);
public void clicked(final InputEvent event, final float x, final float y) {
MainMenu.this.setView(MainMenu.this.tblMain);
}
});
this.add(btnCancel).padBottom(buttonPadding);
Expand Down
3 changes: 2 additions & 1 deletion core/src/me/vinceh121/wanderer/PrototypeRegistry.java
Original file line number Diff line number Diff line change
Expand Up @@ -50,7 +50,8 @@ public void loadDefaults() throws StreamReadException, DatabindException, IOExce
this.readPrototypes(Gdx.files.internal("prototypes/islands.json"), IslandPrototype.class);
this.readPrototypes(Gdx.files.internal("prototypes/characters.json"), CharacterPrototype.class);
this.readPrototypes(Gdx.files.internal("prototypes/props.json"), PropPrototype.class);
this.readPrototypes(Gdx.files.internal("prototypes/machinegunGuntowers.json"), MachineGunGuntowerPrototype.class);
this.readPrototypes(Gdx.files.internal("prototypes/machinegunGuntowers.json"),
MachineGunGuntowerPrototype.class);
this.readPrototypes(Gdx.files.internal("prototypes/machinegunPlanes.json"), MachineGunPlanePrototype.class);
}

Expand Down
8 changes: 4 additions & 4 deletions core/src/me/vinceh121/wanderer/StoryWanderer.java
Original file line number Diff line number Diff line change
Expand Up @@ -22,10 +22,10 @@ public class StoryWanderer extends Wanderer {
private Chapter chapter;
private Part part;

public StoryWanderer(ApplicationMultiplexer applicationMultiplexer) {
public StoryWanderer(final ApplicationMultiplexer applicationMultiplexer) {
super(applicationMultiplexer);
}

@Override
public void create() {
super.create();
Expand Down Expand Up @@ -68,8 +68,8 @@ public void resize(final int width, final int height) {
}

public void startStory(final String name, final int chapter, final int part) {
final Scriptable exports =
this.getScriptManager().loadModule(StoryWanderer.STORY_SCRIPTS_ROOT.child(name + ".js"), StoryWanderer.STORY_SCRIPTS_ROOT);
final Scriptable exports = this.getScriptManager()
.loadModule(StoryWanderer.STORY_SCRIPTS_ROOT.child(name + ".js"), StoryWanderer.STORY_SCRIPTS_ROOT);
this.storyBook = (StoryBook) ((NativeJavaObject) exports.get("storyBook", exports)).unwrap();
this.chapter = this.storyBook.getChapters().get(chapter);
this.part = this.chapter.getParts().get(part);
Expand Down
22 changes: 11 additions & 11 deletions core/src/me/vinceh121/wanderer/Wanderer.java
Original file line number Diff line number Diff line change
Expand Up @@ -105,7 +105,7 @@ public class Wanderer extends ApplicationDelegate {
private float timeOfDay, elapsedTimeOfDay, dayDuration = 15800f;
private float cameraShakeIntensity, cameraShakeTime, cameraShakeRevolutionTime;

public Wanderer(ApplicationMultiplexer applicationMultiplexer) {
public Wanderer(final ApplicationMultiplexer applicationMultiplexer) {
super(applicationMultiplexer);
}

Expand Down Expand Up @@ -325,7 +325,7 @@ public void render() {
}

this.flushEntityQueue();

this.controlledDeathTest();

for (int i = 0; i < this.entities.size; i++) {
Expand Down Expand Up @@ -420,40 +420,40 @@ protected void flushEntityQueue() {
protected void controlledDeathTest() {
if (this.controlledEntity instanceof ILivingEntity && ((ILivingEntity) this.controlledEntity).isDead()) {
final Optional<CharacterW> optChar =
findEntitiesByClass(CharacterW.class).filter(c -> c.getClan() == this.getPlayerClan()).findFirst();
this.findEntitiesByClass(CharacterW.class).filter(c -> c.getClan() == this.getPlayerClan()).findFirst();

if (optChar.isPresent()) {
this.controlEntity(optChar.get());
} else {
LOG.error("No player character to control back after death of controlled vehicle");
Wanderer.LOG.error("No player character to control back after death of controlled vehicle");
}
}
}

public void shakeCamera(float intensity, float time) {
public void shakeCamera(final float intensity, final float time) {
this.shakeCamera(intensity, time, 0.25f);
}

public void shakeCamera(float intensity, float time, float revolutionTime) {
public void shakeCamera(final float intensity, final float time, final float revolutionTime) {
this.cameraShakeIntensity = intensity;
this.cameraShakeTime = time;
this.cameraShakeRevolutionTime = revolutionTime;
}

private void processCameraShake(float delta) {
private void processCameraShake(final float delta) {
// should be a percentage
float cameraShakeModifier = Preferences.getPreferences().getOrElse("a11y.cameraShake", 1.0).floatValue();
final float cameraShakeModifier = Preferences.getPreferences().getOrElse("a11y.cameraShake", 1.0).floatValue();

if (cameraShakeModifier == 0 || this.cameraShakeTime == 0) {
return;
}

final PerspectiveCamera cam = this.graphicsManager.getCamera();

EllipsePath path = new EllipsePath(0f, 0f, 0.5f * this.cameraShakeIntensity, 0.2f * this.cameraShakeIntensity);
final EllipsePath path = new EllipsePath(0f, 0f, 0.5f * this.cameraShakeIntensity, 0.2f * this.cameraShakeIntensity);
path.y = path.height / 2;
Vector2 shakeVec2 = path.valueAt(new Vector2(), this.cameraShakeTime / this.cameraShakeRevolutionTime);
Vector3 shakeVec3 = new Vector3(shakeVec2, 0);
final Vector2 shakeVec2 = path.valueAt(new Vector2(), this.cameraShakeTime / this.cameraShakeRevolutionTime);
final Vector3 shakeVec3 = new Vector3(shakeVec2, 0);
shakeVec3.rot(cam.combined);
cam.position.add(shakeVec3);

Expand Down
16 changes: 8 additions & 8 deletions core/src/me/vinceh121/wanderer/WandererConstants.java
Original file line number Diff line number Diff line change
Expand Up @@ -45,21 +45,21 @@ public static WSkin getUISkin() {
}

public static Model getAudioDebug() {
return getAssetOrHotload("audio-debug.glb", Model.class);
return WandererConstants.getAssetOrHotload("audio-debug.glb", Model.class);
}

public static Model getCircleDebug() {
return getAssetOrHotload("circle-debug.glb", Model.class);
return WandererConstants.getAssetOrHotload("circle-debug.glb", Model.class);
}

public static <T> T getAssetOrHotload(String path, Class<T> type) {
if (!ASSET_MANAGER.isLoaded(path, type)) {
ASSET_MANAGER.load(path, type);
LOG.warn("Hot loading asset {} of type {}", path, type);
ASSET_MANAGER.finishLoadingAsset(path);
public static <T> T getAssetOrHotload(final String path, final Class<T> type) {
if (!WandererConstants.ASSET_MANAGER.isLoaded(path, type)) {
WandererConstants.ASSET_MANAGER.load(path, type);
WandererConstants.LOG.warn("Hot loading asset {} of type {}", path, type);
WandererConstants.ASSET_MANAGER.finishLoadingAsset(path);
}

return ASSET_MANAGER.get(path, type);
return WandererConstants.ASSET_MANAGER.get(path, type);
}

static {
Expand Down
2 changes: 1 addition & 1 deletion core/src/me/vinceh121/wanderer/ai/AIController.java
Original file line number Diff line number Diff line change
Expand Up @@ -7,7 +7,7 @@ public abstract class AIController<T extends IControllableEntity> {
protected final Wanderer game;
protected final T target;

public AIController(Wanderer game, T target) {
public AIController(final Wanderer game, final T target) {
this.game = game;
this.target = target;
}
Expand Down
3 changes: 2 additions & 1 deletion core/src/me/vinceh121/wanderer/animation/AnimationTrack.java
Original file line number Diff line number Diff line change
Expand Up @@ -27,7 +27,8 @@ public AnimationTrack() {
}

@JsonCreator
public AnimationTrack(@JsonProperty("keys") final List<T> list, @JsonProperty("interpolation") final EnumInterpolation inter) {
public AnimationTrack(@JsonProperty("keys") final List<T> list,
@JsonProperty("interpolation") final EnumInterpolation inter) {
for (final T frame : list) {
this.addKeyframe(frame);
}
Expand Down
3 changes: 2 additions & 1 deletion core/src/me/vinceh121/wanderer/animation/KeyFrame.java
Original file line number Diff line number Diff line change
Expand Up @@ -51,7 +51,8 @@ public boolean equals(final Object obj) {
return false;
}
final KeyFrame<?> other = (KeyFrame<?>) obj;
return Float.floatToIntBits(this.time) == Float.floatToIntBits(other.time) && Objects.equals(this.value, other.value);
return Float.floatToIntBits(this.time) == Float.floatToIntBits(other.time)
&& Objects.equals(this.value, other.value);
}

@Override
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -56,8 +56,8 @@ public void setPickupZoneRadius(final float pickupZoneRadius) {
}

@Override
public void getAssetsToLoad(List<AssetDescriptor<?>> descriptors) {
descriptors.add(new AssetDescriptor<>(artifactModel, Model.class));
descriptors.add(new AssetDescriptor<>(artifactTexture, Texture.class));
public void getAssetsToLoad(final List<AssetDescriptor<?>> descriptors) {
descriptors.add(new AssetDescriptor<>(this.artifactModel, Model.class));
descriptors.add(new AssetDescriptor<>(this.artifactTexture, Texture.class));
}
}
4 changes: 2 additions & 2 deletions core/src/me/vinceh121/wanderer/building/AbstractBuilding.java
Original file line number Diff line number Diff line change
Expand Up @@ -43,8 +43,8 @@ public AbstractBuilding(final Wanderer game, final AbstractBuildingPrototype pro
}

this.interactZone = new btGhostObject();
this.interactZone
.setCollisionShape(new btCapsuleShape(prototype.getInteractZoneRadius(), prototype.getInteractZoneHeight()));
this.interactZone.setCollisionShape(
new btCapsuleShape(prototype.getInteractZoneRadius(), prototype.getInteractZoneHeight()));
this.interactZone.setCollisionFlags(CollisionFlags.CF_NO_CONTACT_RESPONSE);
this.interactListener = new ContactListenerAdapter() {
@Override
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -28,7 +28,7 @@ public InputListener createInputProcessor() {
}

@Override
public void tick(float delta) {
public void tick(final float delta) {
super.tick(delta);

if (!this.controlled && this.aiController != null) {
Expand All @@ -51,10 +51,10 @@ public boolean isControlled() {
}

public AIController<?> getAiController() {
return aiController;
return this.aiController;
}

public void setAiController(AIController<?> aiController) {
public void setAiController(final AIController<?> aiController) {
this.aiController = aiController;
}
}
Loading

0 comments on commit 6dac92e

Please sign in to comment.