macro sim triggers acquire item tree
Some checks reported errors
studiorailgun/Renderer/pipeline/head Something is wrong with the build of this commit
Some checks reported errors
studiorailgun/Renderer/pipeline/head Something is wrong with the build of this commit
This commit is contained in:
parent
6692e9261f
commit
fa9bc77638
@ -1711,6 +1711,7 @@ Goal macro data work
|
||||
Shuffle where macro data is stored
|
||||
Structures are stored in character data as IDs into macro data now
|
||||
Item acquisition tree can be triggered by setting macro goal correctly
|
||||
Macro sim triggers character to try to get mats to build structure
|
||||
|
||||
|
||||
|
||||
|
||||
@ -258,7 +258,7 @@ public class Realm {
|
||||
//
|
||||
//macro data simulation
|
||||
if(this.macroData != null){
|
||||
MacroSimulation.simulate(this.macroData);
|
||||
MacroSimulation.simulate(this);
|
||||
}
|
||||
|
||||
//
|
||||
|
||||
@ -4,7 +4,10 @@ import org.joml.Vector3d;
|
||||
import org.joml.Vector3i;
|
||||
|
||||
import electrosphere.client.block.BlockChunkData;
|
||||
import electrosphere.engine.Globals;
|
||||
import electrosphere.game.data.block.BlockFab;
|
||||
import electrosphere.game.data.block.BlockType;
|
||||
import electrosphere.game.data.item.Item;
|
||||
import electrosphere.server.datacell.Realm;
|
||||
import electrosphere.server.datacell.ServerWorldData;
|
||||
import electrosphere.server.datacell.gridded.GriddedDataCellManager;
|
||||
@ -52,6 +55,24 @@ public class StructureRepairUtils {
|
||||
return null;
|
||||
}
|
||||
|
||||
/**
|
||||
* Gets the item id of the material to use for the next repair to perform on a structure
|
||||
* @param realm The realm
|
||||
* @param struct The structure
|
||||
* @return The id of the item to use to repair
|
||||
*/
|
||||
public static String getNextRepairMat(Realm realm, Structure struct){
|
||||
Vector3i repairPos = StructureRepairUtils.getRepairablePosition(realm, struct);
|
||||
|
||||
//get the id of item entity type for the block we need
|
||||
BlockFab fab = struct.getFab();
|
||||
short blockTypeId = fab.getType(repairPos.x, repairPos.y, repairPos.z);
|
||||
BlockType blockType = Globals.gameConfigCurrent.getBlockData().getTypeFromId(blockTypeId);
|
||||
String itemId = Item.getBlockTypeId(blockType);
|
||||
|
||||
return itemId;
|
||||
}
|
||||
|
||||
/**
|
||||
* Solves for whether the structure can be repaired or not
|
||||
* @param realm The realm the structure is within
|
||||
|
||||
@ -7,6 +7,7 @@ import org.joml.Vector3d;
|
||||
import electrosphere.engine.Globals;
|
||||
import electrosphere.game.data.block.BlockFab;
|
||||
import electrosphere.game.data.struct.StructureData;
|
||||
import electrosphere.server.datacell.Realm;
|
||||
import electrosphere.server.macro.MacroData;
|
||||
import electrosphere.server.macro.character.Character;
|
||||
import electrosphere.server.macro.character.CharacterUtils;
|
||||
@ -15,6 +16,7 @@ import electrosphere.server.macro.character.goal.CharacterGoal;
|
||||
import electrosphere.server.macro.character.goal.CharacterGoal.CharacterGoalType;
|
||||
import electrosphere.server.macro.structure.Structure;
|
||||
import electrosphere.server.macro.utils.StructurePlacementUtils;
|
||||
import electrosphere.server.macro.utils.StructureRepairUtils;
|
||||
import electrosphere.util.FileUtils;
|
||||
|
||||
/**
|
||||
@ -30,12 +32,12 @@ public class MacroSimulation {
|
||||
/**
|
||||
* Iterates the macro simulation
|
||||
*/
|
||||
public static void simulate(MacroData macroData){
|
||||
public static void simulate(Realm realm){
|
||||
List<Character> characters = Globals.characterService.getAllCharacters();
|
||||
if(characters != null && characters.size() > 0){
|
||||
for(Character character : Globals.characterService.getAllCharacters()){
|
||||
//do something
|
||||
MacroSimulation.checkForShelter(macroData, character);
|
||||
MacroSimulation.checkForShelter(realm, character);
|
||||
MacroSimulation.checkTownMembership(character);
|
||||
}
|
||||
}
|
||||
@ -62,7 +64,8 @@ public class MacroSimulation {
|
||||
*/
|
||||
static final int MAX_PLACE_ATTEMPTS = 10;
|
||||
|
||||
protected static void checkForShelter(MacroData macroData, Character chara){
|
||||
protected static void checkForShelter(Realm realm, Character chara){
|
||||
MacroData macroData = realm.getMacroData();
|
||||
// for(Character chara : Globals.macroData.getAliveCharacters()){
|
||||
/*
|
||||
If doesn’t have shelter, check if in town
|
||||
@ -74,6 +77,11 @@ public class MacroSimulation {
|
||||
fashion makeshift shelter
|
||||
*/
|
||||
if(CharacterUtils.getShelter(macroData,chara) != null){
|
||||
Structure shelter = CharacterUtils.getShelter(macroData,chara);
|
||||
if(shelter.isRepairable()){
|
||||
String repairMat = StructureRepairUtils.getNextRepairMat(realm, shelter);
|
||||
CharacterGoal.setCharacterGoal(chara, new CharacterGoal(CharacterGoalType.ACQUIRE_ITEM, repairMat));
|
||||
}
|
||||
// Vector2i charPos = CharacterUtils.getDiscretePosition(chara);
|
||||
// Town nearbyTown = Town.getTownAtPosition(charPos.x,charPos.y);
|
||||
// if(nearbyTown != null){
|
||||
|
||||
Loading…
Reference in New Issue
Block a user