repairability validation check
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
76dcc4540e
commit
fa4fd1e106
@ -1722,6 +1722,7 @@ Character data tracks associated player id
|
|||||||
Player characters not simulated at macro level
|
Player characters not simulated at macro level
|
||||||
Macro simulation inventory utilities
|
Macro simulation inventory utilities
|
||||||
Build structure goal properly working from macro sim
|
Build structure goal properly working from macro sim
|
||||||
|
Repairability check when repairing structure
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
|
|||||||
@ -68,6 +68,11 @@ public class CharacterDataSerializer implements JsonDeserializer<CharacterData>,
|
|||||||
return context.serialize((CharacterAssociatedId)src);
|
return context.serialize((CharacterAssociatedId)src);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
//a structure
|
||||||
|
case CharacterDataStrings.SHELTER: {
|
||||||
|
return context.serialize((CharacterAssociatedId)src);
|
||||||
|
}
|
||||||
|
|
||||||
//a town
|
//a town
|
||||||
case CharacterDataStrings.TOWN: {
|
case CharacterDataStrings.TOWN: {
|
||||||
return context.serialize((Town)src);
|
return context.serialize((Town)src);
|
||||||
|
|||||||
@ -106,4 +106,41 @@ public class StructureRepairUtils {
|
|||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
/**
|
||||||
|
* Validates the repairability status of the structure
|
||||||
|
* @param realm The realm the structure is within
|
||||||
|
* @param struct The structure
|
||||||
|
* @return true if the structure is actaully repairable, false otherwise
|
||||||
|
*/
|
||||||
|
public static boolean validateRepairable(Realm realm, Structure struct){
|
||||||
|
//error checking
|
||||||
|
if(!(realm.getDataCellManager() instanceof GriddedDataCellManager)){
|
||||||
|
throw new Error("Realm is not a gridded realm!");
|
||||||
|
}
|
||||||
|
|
||||||
|
BlockFab fab = struct.getFab();
|
||||||
|
Vector3d structStartPos = struct.getStartPos();
|
||||||
|
GriddedDataCellManager griddedDataCellManager = (GriddedDataCellManager)realm.getDataCellManager();
|
||||||
|
for(int x = 0; x < fab.getDimensions().x; x++){
|
||||||
|
for(int y = 0; y < fab.getDimensions().y; y++){
|
||||||
|
for(int z = 0; z < fab.getDimensions().z; z++){
|
||||||
|
Vector3d offsetPos = new Vector3d(structStartPos).add(
|
||||||
|
x * BlockChunkData.BLOCK_SIZE_MULTIPLIER,
|
||||||
|
y * BlockChunkData.BLOCK_SIZE_MULTIPLIER,
|
||||||
|
z * BlockChunkData.BLOCK_SIZE_MULTIPLIER
|
||||||
|
);
|
||||||
|
Vector3i chunkPos = ServerWorldData.convertRealToChunkSpace(offsetPos);
|
||||||
|
Vector3i blockPos = ServerWorldData.convertRealToLocalBlockSpace(offsetPos);
|
||||||
|
BlockChunkData blockChunkData = griddedDataCellManager.getBlocksAtPosition(chunkPos);
|
||||||
|
short existingBlockType = blockChunkData.getType(blockPos.x, blockPos.y, blockPos.z);
|
||||||
|
short desiredType = fab.getType(x, y, z);
|
||||||
|
if(existingBlockType != desiredType){
|
||||||
|
return true;
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
||||||
|
return false;
|
||||||
|
}
|
||||||
|
|
||||||
}
|
}
|
||||||
|
|||||||
@ -84,12 +84,16 @@ public class MacroSimulation {
|
|||||||
if(CharacterUtils.getShelter(macroData,chara) != null){
|
if(CharacterUtils.getShelter(macroData,chara) != null){
|
||||||
Structure shelter = CharacterUtils.getShelter(macroData,chara);
|
Structure shelter = CharacterUtils.getShelter(macroData,chara);
|
||||||
if(shelter.isRepairable()){
|
if(shelter.isRepairable()){
|
||||||
|
if(StructureRepairUtils.validateRepairable(realm, shelter)){
|
||||||
String repairMat = StructureRepairUtils.getNextRepairMat(realm, shelter);
|
String repairMat = StructureRepairUtils.getNextRepairMat(realm, shelter);
|
||||||
if(CharaInventoryUtils.containsItem(chara, repairMat)){
|
if(CharaInventoryUtils.containsItem(chara, repairMat)){
|
||||||
CharacterGoal.setCharacterGoal(chara, new CharacterGoal(CharacterGoalType.BUILD_STRUCTURE, shelter));
|
CharacterGoal.setCharacterGoal(chara, new CharacterGoal(CharacterGoalType.BUILD_STRUCTURE, shelter));
|
||||||
} else {
|
} else {
|
||||||
CharacterGoal.setCharacterGoal(chara, new CharacterGoal(CharacterGoalType.ACQUIRE_ITEM, repairMat));
|
CharacterGoal.setCharacterGoal(chara, new CharacterGoal(CharacterGoalType.ACQUIRE_ITEM, repairMat));
|
||||||
}
|
}
|
||||||
|
} else {
|
||||||
|
shelter.setRepairable(false);
|
||||||
|
}
|
||||||
}
|
}
|
||||||
// Vector2i charPos = CharacterUtils.getDiscretePosition(chara);
|
// Vector2i charPos = CharacterUtils.getDiscretePosition(chara);
|
||||||
// Town nearbyTown = Town.getTownAtPosition(charPos.x,charPos.y);
|
// Town nearbyTown = Town.getTownAtPosition(charPos.x,charPos.y);
|
||||||
|
|||||||
Loading…
Reference in New Issue
Block a user