diff --git a/docs/src/progress/renderertodo.md b/docs/src/progress/renderertodo.md index f09000ee..7d851a19 100644 --- a/docs/src/progress/renderertodo.md +++ b/docs/src/progress/renderertodo.md @@ -1874,6 +1874,9 @@ Update hometown storage on characters Filter test scenes out of level selection Visualize interaction engine collidables AIs build structures based on their character's race +Scaffolding jobs assigned by town to characters + + diff --git a/src/main/java/electrosphere/server/macro/town/Town.java b/src/main/java/electrosphere/server/macro/town/Town.java index a9f98a4e..92f269f4 100644 --- a/src/main/java/electrosphere/server/macro/town/Town.java +++ b/src/main/java/electrosphere/server/macro/town/Town.java @@ -45,6 +45,11 @@ public class Town implements MacroAreaObject { */ private List residents = new LinkedList(); + /** + * The list of jobs queued in the town + */ + private List jobs = new LinkedList(); + /** * Constructor */ @@ -98,6 +103,30 @@ public class Town implements MacroAreaObject { return residents; } + /** + * Adds a job to the town + * @param job The job + */ + public void addJob(TownJob job){ + this.jobs.add(job); + } + + /** + * Gets the jobs in the town + * @return The list of jobs + */ + public List getJobs(){ + return jobs; + } + + /** + * Removes a job from the town + * @param job The job + */ + public void removeJob(TownJob job){ + this.jobs.remove(job); + } + @Override public Vector3d getPos() { return this.position; diff --git a/src/main/java/electrosphere/server/macro/town/TownJob.java b/src/main/java/electrosphere/server/macro/town/TownJob.java new file mode 100644 index 00000000..0513d715 --- /dev/null +++ b/src/main/java/electrosphere/server/macro/town/TownJob.java @@ -0,0 +1,66 @@ +package electrosphere.server.macro.town; + +import electrosphere.server.macro.structure.VirtualStructure; + +/** + * A job that a town has queued + */ +public class TownJob { + + /** + * Types of jobs + */ + public static enum TownJobType { + /** + * Build a structure + */ + BUILD_STRUCTURE, + } + + /** + * The type of the job + */ + private TownJobType type; + + /** + * The structure to target + */ + private VirtualStructure structureTarget; + + /** + * Private constructor + */ + private TownJob(){ } + + /** + * Creates a job to build a structure + * @param structureTarget The virtual structure + * @return The job + */ + public static TownJob createBuildStructure(VirtualStructure structureTarget){ + if(structureTarget == null){ + throw new Error("Target is null!"); + } + TownJob rVal = new TownJob(); + rVal.type = TownJobType.BUILD_STRUCTURE; + rVal.structureTarget = structureTarget; + return rVal; + } + + /** + * Gets the type of job + * @return The type of job + */ + public TownJobType getType() { + return type; + } + + /** + * Gets the structure that is the target of the job + * @return The structure + */ + public VirtualStructure getStructureTarget() { + return structureTarget; + } + +} diff --git a/src/main/java/electrosphere/server/macro/town/TownSimulator.java b/src/main/java/electrosphere/server/macro/town/TownSimulator.java new file mode 100644 index 00000000..0d451a19 --- /dev/null +++ b/src/main/java/electrosphere/server/macro/town/TownSimulator.java @@ -0,0 +1,19 @@ +package electrosphere.server.macro.town; + +/** + * Simulates town + */ +public class TownSimulator { + + /** + * Simulates a town + * @param town The town + */ + public static void simualte(Town town){ + //add a job if none exists + if(town.getJobs().size() < 1){ + + } + } + +} diff --git a/src/main/java/electrosphere/server/simulation/MacroSimulation.java b/src/main/java/electrosphere/server/simulation/MacroSimulation.java index ccbab94b..3a98db31 100644 --- a/src/main/java/electrosphere/server/simulation/MacroSimulation.java +++ b/src/main/java/electrosphere/server/simulation/MacroSimulation.java @@ -5,6 +5,8 @@ import java.util.List; import electrosphere.engine.Globals; import electrosphere.server.datacell.Realm; import electrosphere.server.macro.character.Character; +import electrosphere.server.macro.town.Town; +import electrosphere.server.macro.town.TownSimulator; import electrosphere.server.service.CharacterService; import electrosphere.server.simulation.chara.CharaSimulation; @@ -36,6 +38,10 @@ public class MacroSimulation { } } } + List towns = realm.getMacroData().getTowns(); + for(Town town : towns){ + TownSimulator.simualte(town); + } } /**