Skip to content

Commit

Permalink
feat: save/load guntower angles
Browse files Browse the repository at this point in the history
  • Loading branch information
vinceh121 committed Oct 5, 2023
1 parent 259e2f6 commit efd03e0
Show file tree
Hide file tree
Showing 2 changed files with 17 additions and 1 deletion.
17 changes: 17 additions & 0 deletions core/src/me/vinceh121/wanderer/guntower/AbstractGuntower.java
Original file line number Diff line number Diff line change
Expand Up @@ -8,6 +8,7 @@
import com.badlogic.gdx.math.Matrix4;
import com.badlogic.gdx.math.Quaternion;
import com.badlogic.gdx.math.Vector3;
import com.fasterxml.jackson.databind.node.ObjectNode;

import me.vinceh121.wanderer.Preferences;
import me.vinceh121.wanderer.Wanderer;
Expand Down Expand Up @@ -143,6 +144,22 @@ public void setPolarAngle(final float polarAngle) {
this.polarAngle = MathUtils.clamp(polarAngle, this.meta.getPolarMin(), this.meta.getPolarMax());
}

@Override
public void writeState(ObjectNode node) {
super.writeState(node);

node.put("azimuth", this.getAzimuth());
node.put("polarAngle", this.getPolarAngle());
}

@Override
public void readState(ObjectNode node) {
super.readState(node);

this.setAzimuth(node.get("azimuth").floatValue());
this.setPolarAngle(node.get("polarAngle").floatValue());
}

@Override
public AbstractGuntowerMeta getMeta() {
return this.meta;
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -111,7 +111,6 @@ public void render(ModelBatch batch, Environment env) {
super.render(batch, env);

if (this.barrelSpinSpeed != 0) {
System.out.println(this.barrelSpinSpeed);
this.animateParts("barrelSpin", trans -> trans.rotateRad(Vector3.Z, this.barrelSpinSpeed));
this.barrelSpinSpeed = Math.max(0, this.barrelSpinSpeed - 0.01f);
}
Expand Down

0 comments on commit efd03e0

Please sign in to comment.