mirror of
https://github.com/simon987/Much-Assembly-Required.git
synced 2025-04-19 18:46:43 +00:00
parent
54ed05b86c
commit
3776070689
@ -21,8 +21,7 @@ import java.util.*;
|
|||||||
public class Cubot extends GameObject implements Updatable, ControllableUnit, MessageReceiver,
|
public class Cubot extends GameObject implements Updatable, ControllableUnit, MessageReceiver,
|
||||||
Attackable, Rechargeable, HardwareHost {
|
Attackable, Rechargeable, HardwareHost {
|
||||||
|
|
||||||
private static final char MAP_INFO = 0x0080;
|
private static final char MAP_INFO = 0x0200;
|
||||||
|
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* Hit points
|
* Hit points
|
||||||
|
@ -107,8 +107,8 @@ public class CubotLidar extends CubotHardwareModule {
|
|||||||
|
|
||||||
//Write map data to the location specified by register X
|
//Write map data to the location specified by register X
|
||||||
int i = getCpu().getRegisterSet().getRegister("X").getValue();
|
int i = getCpu().getRegisterSet().getRegister("X").getValue();
|
||||||
for (int y = 0; y < cubot.getWorld().getWorldSize(); y++) {
|
|
||||||
for (int x = 0; x < cubot.getWorld().getWorldSize(); x++) {
|
for (int x = 0; x < cubot.getWorld().getWorldSize(); x++) {
|
||||||
|
for (int y = 0; y < cubot.getWorld().getWorldSize(); y++) {
|
||||||
getCpu().getMemory().set(i++, mapInfo[x][y]);
|
getCpu().getMemory().set(i++, mapInfo[x][y]);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
@ -16,6 +16,7 @@ import java.util.ArrayList;
|
|||||||
*/
|
*/
|
||||||
public class ElectricBox extends GameObject implements Updatable, Attackable {
|
public class ElectricBox extends GameObject implements Updatable, Attackable {
|
||||||
|
|
||||||
|
private static final char MAP_INFO = 0x0301;
|
||||||
/**
|
/**
|
||||||
* Hit points
|
* Hit points
|
||||||
*/
|
*/
|
||||||
@ -98,7 +99,7 @@ public class ElectricBox extends GameObject implements Updatable, Attackable {
|
|||||||
|
|
||||||
@Override
|
@Override
|
||||||
public char getMapInfo() {
|
public char getMapInfo() {
|
||||||
return Obstacle.MAP_INFO;
|
return MAP_INFO;
|
||||||
}
|
}
|
||||||
|
|
||||||
/**
|
/**
|
||||||
|
@ -15,7 +15,7 @@ import java.util.List;
|
|||||||
*/
|
*/
|
||||||
public class Factory extends Structure implements Updatable {
|
public class Factory extends Structure implements Updatable {
|
||||||
|
|
||||||
private static final int MAP_INFO = 0x0200;
|
private static final int MAP_INFO = 0x0401;
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* Maximum number of NonPlayerCharacters assigned to this Factory
|
* Maximum number of NonPlayerCharacters assigned to this Factory
|
||||||
|
@ -12,7 +12,6 @@ public class HarvesterNPC extends NonPlayerCharacter {
|
|||||||
public static final int MAX_HEALTH = GameServer.INSTANCE.getConfig().getInt("harvester_hp_max");
|
public static final int MAX_HEALTH = GameServer.INSTANCE.getConfig().getInt("harvester_hp_max");
|
||||||
public static final int HEAL_RATE = GameServer.INSTANCE.getConfig().getInt("harvester_regen");
|
public static final int HEAL_RATE = GameServer.INSTANCE.getConfig().getInt("harvester_regen");
|
||||||
|
|
||||||
|
|
||||||
public HarvesterNPC() {
|
public HarvesterNPC() {
|
||||||
setTask(new HarvestTask());
|
setTask(new HarvestTask());
|
||||||
|
|
||||||
|
@ -15,7 +15,7 @@ import java.util.ArrayList;
|
|||||||
*/
|
*/
|
||||||
public abstract class NonPlayerCharacter extends GameObject implements Updatable, Attackable {
|
public abstract class NonPlayerCharacter extends GameObject implements Updatable, Attackable {
|
||||||
|
|
||||||
private static final int MAP_INFO = 0x0040;
|
private static final char MAP_INFO = 0x0501;
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* Maximum distance to travel from its factory, in Worlds
|
* Maximum distance to travel from its factory, in Worlds
|
||||||
|
@ -10,7 +10,7 @@ import org.json.simple.JSONObject;
|
|||||||
*/
|
*/
|
||||||
public class Obstacle extends GameObject implements Attackable {
|
public class Obstacle extends GameObject implements Attackable {
|
||||||
|
|
||||||
public static final int MAP_INFO = 0x0400;
|
public static final int MAP_INFO = 0x0701;
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* Style of the obstacle. Will tell the client which sprite to display
|
* Style of the obstacle. Will tell the client which sprite to display
|
||||||
|
@ -17,7 +17,7 @@ public class Portal extends Structure implements Enterable {
|
|||||||
*/
|
*/
|
||||||
private Location destination;
|
private Location destination;
|
||||||
|
|
||||||
public static final int MAP_INFO = 0x0020;
|
public static final int MAP_INFO = 0x0801;
|
||||||
|
|
||||||
public Portal() {
|
public Portal() {
|
||||||
super(1, 1);
|
super(1, 1);
|
||||||
|
@ -12,7 +12,7 @@ import java.util.ArrayList;
|
|||||||
|
|
||||||
public class RadioTower extends Structure implements MessageReceiver, Updatable {
|
public class RadioTower extends Structure implements MessageReceiver, Updatable {
|
||||||
|
|
||||||
private static final int MAP_INFO = 0x1000;
|
private static final int MAP_INFO = 0x0901;
|
||||||
|
|
||||||
public static final int MAX_RANGE = GameServer.INSTANCE.getConfig().getInt("radio_tower_range");
|
public static final int MAX_RANGE = GameServer.INSTANCE.getConfig().getInt("radio_tower_range");
|
||||||
|
|
||||||
|
@ -12,7 +12,7 @@ import java.util.Arrays;
|
|||||||
|
|
||||||
public class VaultDoor extends Structure implements MessageReceiver, Enterable, Updatable {
|
public class VaultDoor extends Structure implements MessageReceiver, Enterable, Updatable {
|
||||||
|
|
||||||
private static final int MAP_INFO = 0x0800;
|
private static final int MAP_INFO = 0x0B00;
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* Password to open the vault door
|
* Password to open the vault door
|
||||||
|
@ -29,9 +29,7 @@ public class VaultExitPortal extends Portal {
|
|||||||
@Override
|
@Override
|
||||||
public boolean enter(GameObject object) {
|
public boolean enter(GameObject object) {
|
||||||
|
|
||||||
|
|
||||||
//TODO: Trigger vault complete event instead
|
//TODO: Trigger vault complete event instead
|
||||||
|
|
||||||
return super.enter(object);
|
return super.enter(object);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
@ -8,7 +8,7 @@ import org.json.simple.JSONObject;
|
|||||||
|
|
||||||
public class BiomassBlob extends GameObject implements InventoryHolder {
|
public class BiomassBlob extends GameObject implements InventoryHolder {
|
||||||
|
|
||||||
private static final char MAP_INFO = 0x4000;
|
private static final char MAP_INFO = 0x0101;
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* Yield of the blob, in biomass units
|
* Yield of the blob, in biomass units
|
||||||
|
@ -9,10 +9,11 @@ import net.simon987.server.game.objects.Radioactive;
|
|||||||
public class RadioactiveObstacle extends GameObject implements Radioactive, Enterable {
|
public class RadioactiveObstacle extends GameObject implements Radioactive, Enterable {
|
||||||
|
|
||||||
private final static int corruptionBlockSize = GameServer.INSTANCE.getConfig().getInt("radioactive_obstacle_corruption_block_size");
|
private final static int corruptionBlockSize = GameServer.INSTANCE.getConfig().getInt("radioactive_obstacle_corruption_block_size");
|
||||||
|
private final static int MAP_INFO = 0x0A01; //10
|
||||||
|
|
||||||
@Override
|
@Override
|
||||||
public char getMapInfo() {
|
public char getMapInfo() {
|
||||||
return 0;
|
return MAP_INFO;
|
||||||
}
|
}
|
||||||
|
|
||||||
@Override
|
@Override
|
||||||
|
@ -4,11 +4,13 @@ import net.simon987.server.game.item.Item;
|
|||||||
import org.bson.Document;
|
import org.bson.Document;
|
||||||
import org.json.simple.JSONObject;
|
import org.json.simple.JSONObject;
|
||||||
|
|
||||||
import java.util.*;
|
import java.util.ArrayList;
|
||||||
|
import java.util.List;
|
||||||
|
import java.util.Optional;
|
||||||
|
|
||||||
public class ItemsContainer extends GameObject implements InventoryHolder {
|
public class ItemsContainer extends GameObject implements InventoryHolder {
|
||||||
|
|
||||||
private static final char MAP_INFO = 0x0240;
|
private static final char MAP_INFO = 0x0601;
|
||||||
|
|
||||||
private final List<Item> items;
|
private final List<Item> items;
|
||||||
private int containerCapacity;
|
private int containerCapacity;
|
||||||
|
@ -126,7 +126,7 @@ public class TileMap implements JSONSerialisable, MongoSerializable {
|
|||||||
|
|
||||||
for (int x = 0; x < width; x++) {
|
for (int x = 0; x < width; x++) {
|
||||||
for (int y = 0; y < height; y++) {
|
for (int y = 0; y < height; y++) {
|
||||||
terrain.add(tiles[y][x].getId());
|
terrain.add(tiles[x][y].getId());
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -25,11 +25,6 @@ public class World implements MongoSerializable {
|
|||||||
*/
|
*/
|
||||||
private int worldSize;
|
private int worldSize;
|
||||||
|
|
||||||
//TODO: This info should be pulled from the Tile class
|
|
||||||
private static final char INFO_BLOCKED = 0x8000;
|
|
||||||
private static final char INFO_IRON = 0x0200;
|
|
||||||
private static final char INFO_COPPER = 0x0100;
|
|
||||||
|
|
||||||
private int x;
|
private int x;
|
||||||
private int y;
|
private int y;
|
||||||
|
|
||||||
@ -115,20 +110,6 @@ public class World implements MongoSerializable {
|
|||||||
return matchingObjects;
|
return matchingObjects;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
public ArrayList<GameObject> findObjects(int mapInfo) {
|
|
||||||
|
|
||||||
ArrayList<GameObject> matchingObjects = new ArrayList<>(2);
|
|
||||||
|
|
||||||
for (GameObject obj : gameObjects.values()) {
|
|
||||||
if ((obj.getMapInfo() & mapInfo) == mapInfo) {
|
|
||||||
matchingObjects.add(obj);
|
|
||||||
}
|
|
||||||
}
|
|
||||||
|
|
||||||
return matchingObjects;
|
|
||||||
}
|
|
||||||
|
|
||||||
public ArrayList<GameObject> findGameObjects(String type) {
|
public ArrayList<GameObject> findGameObjects(String type) {
|
||||||
|
|
||||||
ArrayList<GameObject> matchingObjects = new ArrayList<>(2);
|
ArrayList<GameObject> matchingObjects = new ArrayList<>(2);
|
||||||
@ -209,11 +190,13 @@ public class World implements MongoSerializable {
|
|||||||
@Override
|
@Override
|
||||||
public String toString() {
|
public String toString() {
|
||||||
|
|
||||||
StringBuilder str = new StringBuilder("World (" + x + ", " + y + ")\n");
|
StringBuilder str = new StringBuilder(String.format("World (%04X, %04X)\n", x, y));
|
||||||
|
|
||||||
|
char[][] mapInfo = getMapInfo();
|
||||||
|
|
||||||
for (int x = 0; x < worldSize; x++) {
|
|
||||||
for (int y = 0; y < worldSize; y++) {
|
for (int y = 0; y < worldSize; y++) {
|
||||||
str.append(tileMap.getTileIdAt(x, y)).append(" ");
|
for (int x = 0; x < worldSize; x++) {
|
||||||
|
str.append(String.format("%04X ", (int) mapInfo[x][y]));
|
||||||
}
|
}
|
||||||
str.append("\n");
|
str.append("\n");
|
||||||
}
|
}
|
||||||
@ -251,40 +234,30 @@ public class World implements MongoSerializable {
|
|||||||
* Get a binary representation of the map as an array of 16-bit bit fields, one word for each
|
* Get a binary representation of the map as an array of 16-bit bit fields, one word for each
|
||||||
* tile.
|
* tile.
|
||||||
* <p>
|
* <p>
|
||||||
* todo Performance cache this?
|
* Each tile is represented as such: <code>OOOOOOOOTTTTTTTB</code> where O is the object,
|
||||||
|
* T the tile and B if the tile is blocked or not
|
||||||
*/
|
*/
|
||||||
public char[][] getMapInfo() {
|
public char[][] getMapInfo() {
|
||||||
|
|
||||||
char[][] mapInfo = new char[worldSize][worldSize];
|
char[][] mapInfo = new char[worldSize][worldSize];
|
||||||
|
|
||||||
//Tile
|
//Tile
|
||||||
for (int y = 0; y < worldSize; y++) {
|
|
||||||
for (int x = 0; x < worldSize; x++) {
|
for (int x = 0; x < worldSize; x++) {
|
||||||
|
for (int y = 0; y < worldSize; y++) {
|
||||||
|
Tile tile = tileMap.getTileAt(x, y);
|
||||||
|
|
||||||
if (tileMap.getTileIdAt(x, y) == TilePlain.ID) {
|
mapInfo[x][y] = (char) (tile.isBlocked() ? 1 : 0);
|
||||||
mapInfo[x][y] = 0;
|
mapInfo[x][y] |= (char) (tile.getId() << 1);
|
||||||
|
|
||||||
} else if (tileMap.getTileAt(x, y).isBlocked()) {
|
|
||||||
mapInfo[x][y] = INFO_BLOCKED;
|
|
||||||
|
|
||||||
//TODO: Tiles should have their .getMapInfo() method
|
|
||||||
} else if (tileMap.getTileIdAt(x, y) == TileCopper.ID) {
|
|
||||||
mapInfo[x][y] = INFO_COPPER;
|
|
||||||
|
|
||||||
} else if (tileMap.getTileIdAt(x, y) == TileIron.ID) {
|
|
||||||
mapInfo[x][y] = INFO_IRON;
|
|
||||||
}
|
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
//Objects
|
|
||||||
for (GameObject obj : gameObjects.values()) {
|
for (GameObject obj : gameObjects.values()) {
|
||||||
|
//Overwrite, only the last object on a tile is considered but the blocked bit is kept
|
||||||
|
mapInfo[obj.getX()][obj.getY()] &= 0x00FE;
|
||||||
mapInfo[obj.getX()][obj.getY()] |= obj.getMapInfo();
|
mapInfo[obj.getX()][obj.getY()] |= obj.getMapInfo();
|
||||||
|
|
||||||
}
|
}
|
||||||
|
|
||||||
return mapInfo;
|
return mapInfo;
|
||||||
|
|
||||||
}
|
}
|
||||||
|
|
||||||
/**
|
/**
|
||||||
@ -412,31 +385,6 @@ public class World implements MongoSerializable {
|
|||||||
return neighbouringWorlds;
|
return neighbouringWorlds;
|
||||||
}
|
}
|
||||||
|
|
||||||
//Unused
|
|
||||||
// public ArrayList<World> getNeighbouringExistingWorlds(){
|
|
||||||
// ArrayList<World> neighbouringWorlds = new ArrayList<>();
|
|
||||||
//
|
|
||||||
// if (universe == null){
|
|
||||||
// return neighbouringWorlds;
|
|
||||||
// }
|
|
||||||
//
|
|
||||||
// for (int dx=-1; dx<=+1; dx+=2){
|
|
||||||
// World nw = universe.getWorld(x+dx,y,false);
|
|
||||||
// if (nw != null){
|
|
||||||
// neighbouringWorlds.add(nw);
|
|
||||||
// }
|
|
||||||
// }
|
|
||||||
// for (int dy=-1; dy<=+1; dy+=2){
|
|
||||||
// World nw = universe.getWorld(x,y+dy,false);
|
|
||||||
// if (nw != null){
|
|
||||||
// neighbouringWorlds.add(nw);
|
|
||||||
// }
|
|
||||||
// }
|
|
||||||
//
|
|
||||||
// return neighbouringWorlds;
|
|
||||||
// }
|
|
||||||
|
|
||||||
|
|
||||||
public boolean canUnload(){
|
public boolean canUnload(){
|
||||||
return updatable==0;
|
return updatable==0;
|
||||||
}
|
}
|
||||||
|
2
Server/src/main/resources/static/js/mar.js
vendored
2
Server/src/main/resources/static/js/mar.js
vendored
@ -1640,7 +1640,7 @@ var World = (function () {
|
|||||||
}
|
}
|
||||||
for (var x = 0; x < size; x++) {
|
for (var x = 0; x < size; x++) {
|
||||||
for (var y = 0; y < size; y++) {
|
for (var y = 0; y < size; y++) {
|
||||||
var tile = Tile.createTile(terrain[y * size + x], x, y);
|
var tile = Tile.createTile(terrain[x * size + y], x, y);
|
||||||
this.tiles.push(tile);
|
this.tiles.push(tile);
|
||||||
mar.isoGroup.add(tile);
|
mar.isoGroup.add(tile);
|
||||||
}
|
}
|
||||||
|
@ -292,7 +292,7 @@ class World {
|
|||||||
for (let x = 0; x < size; x++) {
|
for (let x = 0; x < size; x++) {
|
||||||
for (let y = 0; y < size; y++) {
|
for (let y = 0; y < size; y++) {
|
||||||
|
|
||||||
let tile: Tile = Tile.createTile(terrain[y * size + x], x, y);
|
let tile: Tile = Tile.createTile(terrain[x * size + y], x, y);
|
||||||
|
|
||||||
this.tiles.push(tile);
|
this.tiles.push(tile);
|
||||||
mar.isoGroup.add(tile);
|
mar.isoGroup.add(tile);
|
||||||
|
Loading…
x
Reference in New Issue
Block a user