job data work
Some checks failed
studiorailgun/Renderer/pipeline/head There was a failure building this commit
Some checks failed
studiorailgun/Renderer/pipeline/head There was a failure building this commit
This commit is contained in:
parent
2d20e2d389
commit
7a36c56c57
@ -2048,6 +2048,9 @@ Farmland voxel type
|
||||
Farm plots place farmland
|
||||
More verbose loading display
|
||||
|
||||
(05/29/2025)
|
||||
Scaffolding towns and character jobs data
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
@ -1,6 +1,7 @@
|
||||
package electrosphere.server.macro.town;
|
||||
|
||||
import java.util.List;
|
||||
import java.util.Random;
|
||||
|
||||
import org.joml.Vector3d;
|
||||
|
||||
@ -27,12 +28,17 @@ public class TownPopulator {
|
||||
*/
|
||||
public static void populateTown(Realm realm, MacroData macroData, Town town){
|
||||
List<VirtualStructure> structs = town.getStructures(macroData);
|
||||
Random rand = new Random(town.getId());
|
||||
for(VirtualStructure struct : structs){
|
||||
ObjectTemplate template = ObjectTemplate.create(EntityType.CREATURE, "human");
|
||||
Character chara = Globals.serverState.characterService.createCharacter(template, CharacterService.NO_PLAYER);
|
||||
Race.setRace(chara, Globals.gameConfigCurrent.getRaceMap().getRace("human"));
|
||||
CharacterUtils.addShelter(chara, struct);
|
||||
CharacterUtils.addHometown(chara, town);
|
||||
chara.setPos(new Vector3d(struct.getPos()).add(1,1,1));
|
||||
if(rand.nextInt(5) == 0){
|
||||
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
@ -13,6 +13,7 @@ import electrosphere.server.macro.character.data.CharacterDataStrings;
|
||||
import electrosphere.server.macro.character.goal.CharacterGoal;
|
||||
import electrosphere.server.macro.character.goal.CharacterGoal.CharacterGoalType;
|
||||
import electrosphere.server.macro.structure.VirtualStructure;
|
||||
import electrosphere.server.macro.town.Town;
|
||||
import electrosphere.server.macro.utils.StructurePlacementUtils;
|
||||
import electrosphere.server.macro.utils.StructureRepairUtils;
|
||||
import electrosphere.util.FileUtils;
|
||||
@ -22,6 +23,10 @@ import electrosphere.util.FileUtils;
|
||||
*/
|
||||
public class CharaSimulation {
|
||||
|
||||
/**
|
||||
* Maximum attempts to place a structure
|
||||
*/
|
||||
static final int MAX_PLACE_ATTEMPTS = 10;
|
||||
|
||||
/**
|
||||
* Sets the goal of the character
|
||||
@ -29,20 +34,20 @@ public class CharaSimulation {
|
||||
* @param chara The character
|
||||
*/
|
||||
public static void setGoal(Realm realm, Character chara){
|
||||
CharaSimulation.checkForShelter(realm, chara);
|
||||
if(CharaSimulation.checkForShelter(realm, chara)){
|
||||
return;
|
||||
}
|
||||
if(CharaSimulation.checkTownGoals(realm, chara)){
|
||||
return;
|
||||
}
|
||||
}
|
||||
|
||||
/**
|
||||
* Maximum attempts to place a structure
|
||||
*/
|
||||
static final int MAX_PLACE_ATTEMPTS = 10;
|
||||
|
||||
/**
|
||||
* Checks if the character has shelter
|
||||
* @param realm The realm
|
||||
* @param chara The character
|
||||
*/
|
||||
protected static void checkForShelter(Realm realm, Character chara){
|
||||
protected static boolean checkForShelter(Realm realm, Character chara){
|
||||
MacroData macroData = realm.getMacroData();
|
||||
/*
|
||||
If doesn’t have shelter, check if in town
|
||||
@ -60,8 +65,10 @@ public class CharaSimulation {
|
||||
String repairMat = StructureRepairUtils.getNextRepairMat(realm, shelter);
|
||||
if(CharaInventoryUtils.containsItem(chara, repairMat)){
|
||||
CharacterGoal.setCharacterGoal(chara, new CharacterGoal(CharacterGoalType.BUILD_STRUCTURE, shelter));
|
||||
return true;
|
||||
} else {
|
||||
CharacterGoal.setCharacterGoal(chara, new CharacterGoal(CharacterGoalType.ACQUIRE_ITEM, repairMat));
|
||||
return true;
|
||||
}
|
||||
} else {
|
||||
shelter.setRepairable(false);
|
||||
@ -82,7 +89,9 @@ public class CharaSimulation {
|
||||
|
||||
//target the struct
|
||||
CharacterGoal.setCharacterGoal(chara, new CharacterGoal(CharacterGoalType.BUILD_STRUCTURE, struct));
|
||||
return true;
|
||||
}
|
||||
return false;
|
||||
}
|
||||
|
||||
protected static void checkTownMembership(Character chara){
|
||||
@ -134,12 +143,23 @@ public class CharaSimulation {
|
||||
}
|
||||
// }
|
||||
}
|
||||
|
||||
// private static void checkInitCombat(){
|
||||
// for(Character chara : Globals.macroData.getAliveCharacters()){
|
||||
// // Vector2i position = CharacterUtils.getDiscretePosition(chara);
|
||||
// }
|
||||
// }
|
||||
|
||||
/**
|
||||
* Checks if the town has a job that the character can reserve
|
||||
* @param realm The realm
|
||||
* @param chara The character
|
||||
*/
|
||||
protected static boolean checkTownGoals(Realm realm, Character chara){
|
||||
MacroData macroData = realm.getMacroData();
|
||||
if(CharacterUtils.getHometown(macroData, chara) == null){
|
||||
return false;
|
||||
}
|
||||
Town hometown = CharacterUtils.getHometown(macroData, chara);
|
||||
if(hometown.getJobs().size() > 0){
|
||||
return true;
|
||||
}
|
||||
return false;
|
||||
}
|
||||
|
||||
|
||||
/**
|
||||
|
||||
Loading…
Reference in New Issue
Block a user