cleanup: fix all the non todo errors

pull/1/head
Bronwen 2023-01-03 03:57:31 -05:00
parent ea713fd3b5
commit 79733c969a
18 changed files with 36 additions and 72 deletions

View File

@ -13,6 +13,7 @@ public class CustomObjectDeserializer extends ObjectInputStream {
super(in);
}
@SuppressWarnings("rawtypes")
protected ObjectStreamClass readClassDescriptor() throws IOException, ClassNotFoundException {
ObjectStreamClass resultClassDescriptor = super.readClassDescriptor(); // initially streams descriptor
Class localClass; // the class in the local JVM that this descriptor represents.

View File

@ -153,14 +153,14 @@ public abstract class SceneGraph implements IScene {
}
private void dump(List<GameObject> objects) {
Map<Class, Integer> count = new HashMap<Class, Integer>();
Map<Class<? extends GameObject>, Integer> count = new HashMap<Class<? extends GameObject>, Integer>();
for(GameObject go : objects) {
Class clazz = go.getClass();
Class<? extends GameObject> clazz = go.getClass();
if(!count.containsKey(clazz))
count.put(clazz, 0);
count.put(clazz, count.get(clazz) + 1);
}
for(Entry<Class, Integer> entry : count.entrySet()) {
for(Entry<Class<? extends GameObject>, Integer> entry : count.entrySet()) {
System.out.println("" + entry.getValue() + "x " + entry.getKey().getSimpleName());
}
}
@ -190,6 +190,7 @@ public abstract class SceneGraph implements IScene {
saveFlag = false;
}
@SuppressWarnings("unchecked")
private void load() {
try {
FileInputStream file = new FileInputStream("SAVE_DATA.TXT");

View File

@ -11,7 +11,6 @@ import xyz.valnet.engine.math.Vector4f;
import xyz.valnet.hadean.scenes.GameScene;
import xyz.valnet.hadean.util.Assets;
public class HadeanGame extends Game {
public static final HadeanGame Hadean = new HadeanGame();

View File

@ -4,7 +4,6 @@ import java.io.Serializable;
import java.util.ArrayList;
import java.util.List;
import xyz.valnet.engine.math.Vector2f;
import xyz.valnet.engine.math.Vector2i;
import xyz.valnet.engine.scenegraph.GameObject;
import xyz.valnet.hadean.gameobjects.worldobjects.Stockpile;
@ -64,6 +63,7 @@ public class Job extends GameObject {
}
}
// TODO find the _best_ place to dropoff, instead of just the top left place.
public class DropoffAtStockpile extends JobStep {
public Item item;
public DropoffAtStockpile(Item item) {

View File

@ -1,7 +1,6 @@
package xyz.valnet.hadean.gameobjects;
import java.util.ArrayList;
import java.util.Comparator;
import java.util.HashMap;
import java.util.HashSet;
import java.util.List;

View File

@ -87,8 +87,6 @@ public class Tile extends WorldObject implements IWorkable {
}
thing.onPlaced(this);
if(thing instanceof FarmPlot) {
desiredTill = true;
get(JobBoard.class).postSimpleWorkJob("Till Soil", this);
}
}
@ -140,13 +138,8 @@ public class Tile extends WorldObject implements IWorkable {
return true;
}
private boolean desiredTill = false;
private float tillLevel = 0;
public void setTill(boolean till) {
desiredTill = till;
}
@Override
public Vector2i[] getWorkablePositions() {
return new Vector2i[] {

View File

@ -70,7 +70,6 @@ public class BuildLayer extends GameObject implements IMouseCaptureArea, ITransi
}
private int x, y;
private int screenX, screenY;
private boolean mouseDown = false;
@Override
@ -80,8 +79,6 @@ public class BuildLayer extends GameObject implements IMouseCaptureArea, ITransi
} else if(button == 0 && active && hovered) {
Vector2i worldcoords = camera.screen2world(App.mouseX, App.mouseY).asInt();
mouseDown = true;
screenX = App.mouseX;
screenY = App.mouseY;
x = worldcoords.x;
y = worldcoords.y;
}

View File

@ -62,17 +62,18 @@ public class BuildTab extends Tab implements ISelectionChangeListener, IMouseCap
}
@SuppressWarnings("unchecked")
private void calculateBuildables() {
try {
Class<? extends IBuildable>[] maybeBuildables = getClasses("xyz.valnet.hadean");
Class<?>[] maybeBuildables = getClasses("xyz.valnet.hadean");
for(Class<? extends IBuildable> clazz : maybeBuildables) {
for(Class<?> clazz : maybeBuildables) {
if(clazz.isAnonymousClass()) continue;
if(!IBuildable.class.isAssignableFrom(clazz)) continue;
if(clazz.isInterface()) continue;
if(Modifier.isAbstract(clazz.getModifiers())) continue;
Constructor<? extends IBuildable> constructor = clazz.getConstructor();
Constructor<? extends IBuildable> constructor = (Constructor<? extends IBuildable>) clazz.getConstructor();
if(constructor.getParameterCount() != 0) {
System.out.println(clazz + " has no default constructor (no params)");
continue;
@ -315,7 +316,8 @@ public class BuildTab extends Tab implements ISelectionChangeListener, IMouseCap
}
}
private static Class[] getClasses(String packageName) throws ClassNotFoundException, IOException {
@SuppressWarnings("rawtypes")
private static Class<?>[] getClasses(String packageName) throws ClassNotFoundException, IOException {
ClassLoader classLoader = Thread.currentThread().getContextClassLoader();
assert classLoader != null;
String path = packageName.replace('.', '/');
@ -329,9 +331,10 @@ public class BuildTab extends Tab implements ISelectionChangeListener, IMouseCap
for (File directory : dirs) {
classes.addAll(findClasses(directory, packageName));
}
return classes.toArray(new Class[classes.size()]);
return (Class<?>[]) classes.toArray(new Class[classes.size()]);
}
@SuppressWarnings("rawtypes")
private static List<Class> findClasses(File directory, String packageName) throws ClassNotFoundException {
List<Class> classes = new ArrayList<Class>();
if (!directory.exists()) {

View File

@ -1,5 +1,7 @@
package xyz.valnet.hadean.gameobjects.worldobjects;
import static xyz.valnet.engine.util.Math.lerp;
import xyz.valnet.engine.math.Vector2i;
import xyz.valnet.engine.math.Vector4f;
import xyz.valnet.hadean.gameobjects.Job;
@ -16,10 +18,9 @@ import xyz.valnet.hadean.util.Assets;
import xyz.valnet.hadean.util.Layers;
import xyz.valnet.hadean.util.detail.BooleanDetail;
import xyz.valnet.hadean.util.detail.Detail;
import xyz.valnet.hadean.util.detail.ObjectDetail;
import xyz.valnet.hadean.util.detail.PercentDetail;
import static xyz.valnet.engine.util.Math.lerp;
@BuildableMetadata(category = "Furniture", name = "Bed", type = BuildableMetadata.SINGLE)
public class Bed extends WorldObject implements IBuildable, IItemReceiver, IWorkable, ISelectable {
@ -76,6 +77,7 @@ public class Bed extends WorldObject implements IBuildable, IItemReceiver, IWork
@Override
public boolean receive(Item item) {
remove(item);
logs ++;
return true;
}
@ -133,6 +135,7 @@ public class Bed extends WorldObject implements IBuildable, IItemReceiver, IWork
return new Detail[] {
new BooleanDetail("Built", isBuilt()),
new PercentDetail("Work", work / maxWork),
new ObjectDetail<Integer>("Logs", logs),
};
}

View File

@ -2,39 +2,14 @@ package xyz.valnet.hadean.gameobjects.worldobjects;
import xyz.valnet.engine.math.Vector2f;
import xyz.valnet.engine.math.Vector4f;
import xyz.valnet.hadean.gameobjects.JobBoard;
import xyz.valnet.hadean.gameobjects.worldobjects.items.Item;
import xyz.valnet.hadean.interfaces.ISelectable;
import xyz.valnet.hadean.interfaces.ITileThing;
import xyz.valnet.hadean.util.Action;
import xyz.valnet.hadean.util.Assets;
import xyz.valnet.hadean.util.Layers;
import xyz.valnet.hadean.util.detail.Detail;
public class Rice extends Item implements ITileThing, ISelectable {
public class Rice extends Item {
// private SmartBoolean haul;
private JobBoard jobboard;
@Override
public void start() {
super.start();
jobboard = get(JobBoard.class);
Rice that = this;
// haul = new SmartBoolean(false, new IListener() {
// @Override
// public void rise() {
// jobboard.postJob(that);
// }
// @Override
// public void fall() {
// jobboard.rescindJob(that);
// }
// });
}
public Rice(int x, int y) {
this.x = x;

View File

@ -113,7 +113,6 @@ public class Stockpile extends WorldObject implements ISelectable, ITileThing, I
@Override
public String getName() {
// TODO Auto-generated method stub
return "Stockpile";
}

View File

@ -135,8 +135,5 @@ public class Tree extends WorldObject implements ITileThing, ISelectable, IWorka
}
@Override
public void onPlaced(Tile tile) {
// TODO Auto-generated method stub
}
public void onPlaced(Tile tile) {}
}

View File

@ -1,6 +1,5 @@
package xyz.valnet.hadean.gameobjects.worldobjects.items;
import xyz.valnet.engine.math.Vector2f;
import xyz.valnet.engine.math.Vector4f;
import xyz.valnet.hadean.gameobjects.Job;
import xyz.valnet.hadean.gameobjects.JobBoard;

View File

@ -4,6 +4,11 @@ import xyz.valnet.hadean.util.Assets;
import xyz.valnet.hadean.util.Layers;
import xyz.valnet.hadean.util.detail.Detail;
// TODO haul on placed in non stockpile. we could have a situation
// where the job gets cancelled, because a pawn has the item
// while it wants to be hauled. thats fine, but what if the pawn then drops
// the item? it should still be hauled. ergo, we should autohaul
// when placed in a non stockpile, not just on create.
public class Log extends Item {
public Log(int x, int y) {

View File

@ -73,7 +73,7 @@ public class Pawn extends Agent {
super.start();
activities.add(new JobActivity(this, get(JobBoard.class)));
activities.add(new SleepActivity(this, needs, get(Clock.class)));
activities.add(new SleepActivity(needs, get(Clock.class)));
}
protected void create() {
@ -172,10 +172,6 @@ public class Pawn extends Agent {
currentActivity.begin(a -> endActivity(a));
}
private void endActivity() {
endActivity(currentActivity);
}
private void endActivity(Activity activity) {
activity.end();
stopPathing();

View File

@ -3,23 +3,17 @@ package xyz.valnet.hadean.gameobjects.worldobjects.pawn;
import xyz.valnet.engine.math.Vector2i;
import xyz.valnet.engine.util.Math.WeightedAverage;
import xyz.valnet.hadean.gameobjects.Clock;
import xyz.valnet.hadean.gameobjects.worldobjects.agents.Agent;
import static xyz.valnet.engine.util.Math.lerp;
public class SleepActivity extends Activity {
private Agent agent;
private Needs needs;
private Clock clock;
private float circadianStrength = (float)Math.random() * 5f;
private int stage;
public SleepActivity(Agent agent, Needs needs, Clock clock) {
public SleepActivity(Needs needs, Clock clock) {
this.needs = needs;
this.agent = agent;
this.clock = clock;
}

View File

@ -3,9 +3,12 @@ package xyz.valnet.hadean.gameobjects.worldobjects.pawn;
import xyz.valnet.engine.math.Vector2i;
import xyz.valnet.hadean.gameobjects.worldobjects.agents.Agent;
// TODO actually implement this activity.
public class WanderActivity extends Activity {
@SuppressWarnings("unused")
private Agent agent;
@SuppressWarnings("unused")
private Needs needs;
public WanderActivity(Agent agent, Needs needs) {

View File

@ -1,6 +1,5 @@
package xyz.valnet.hadean.scenes;
import xyz.valnet.engine.App;
import xyz.valnet.engine.math.Vector4f;
import xyz.valnet.engine.scenegraph.IScene;
import xyz.valnet.hadean.input.Button;
@ -10,6 +9,7 @@ import xyz.valnet.hadean.util.Layers;
import static xyz.valnet.hadean.HadeanGame.Hadean;
// TODO convert this to a scenegraph
public class MenuScene implements IScene, IButtonListener {
private Button btnNewGame = new Button(Assets.frame, "New Game", 50, 200, 128, 32, Layers.GENERAL_UI);
@ -44,10 +44,10 @@ public class MenuScene implements IScene, IButtonListener {
@Override
public void update(float dTime) {
btnNewGame.setMouseCoords(App.mouseX, App.mouseY);
btnLoadGame.setMouseCoords(App.mouseX, App.mouseY);
btnOptions.setMouseCoords(App.mouseX, App.mouseY);
btnQuit.setMouseCoords(App.mouseX, App.mouseY);
// btnNewGame.setMouseCoords(App.mouseX, App.mouseY);
// btnLoadGame.setMouseCoords(App.mouseX, App.mouseY);
// btnOptions.setMouseCoords(App.mouseX, App.mouseY);
// btnQuit.setMouseCoords(App.mouseX, App.mouseY);
btnNewGame.update();
btnLoadGame.update();
btnOptions.update();