diff --git a/src/main/java/de/welterde/em/Entity.java b/src/main/java/de/welterde/em/Entity.java
index 062735c..09d62c3 100644
--- a/src/main/java/de/welterde/em/Entity.java
+++ b/src/main/java/de/welterde/em/Entity.java
@@ -20,16 +20,7 @@ package de.welterde.em;
*
* @author welterde
*/
-public abstract class Entity {
- protected final EntityStorage ctx;
- protected final int id;
-
- public Entity(EntityStorage ctx, int id) {
- this.id = id;
- this.ctx = ctx;
- }
-
- public int getEntityId() {
- return this.id;
- }
+public interface Entity {
+ public int getEntityId();
+ public void initEntity(EntityStorage ctx, int id);
}
diff --git a/src/main/java/de/welterde/em/EntityBase.java b/src/main/java/de/welterde/em/EntityBase.java
new file mode 100644
index 0000000..7b41bf4
--- /dev/null
+++ b/src/main/java/de/welterde/em/EntityBase.java
@@ -0,0 +1,64 @@
+/*
+ * Copyright (C) 2026 welterde
+ *
+ * This program is free software: you can redistribute it and/or modify
+ * it under the terms of the GNU General Public License as published by
+ * the Free Software Foundation, either version 3 of the License, or
+ * (at your option) any later version.
+ *
+ * This program is distributed in the hope that it will be useful,
+ * but WITHOUT ANY WARRANTY; without even the implied warranty of
+ * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
+ * GNU General Public License for more details.
+ *
+ * You should have received a copy of the GNU General Public License
+ * along with this program. If not, see .
+ */
+package de.welterde.em;
+
+import de.welterde.em.io.EntityRecord;
+
+/**
+ *
+ * @author welterde
+ */
+public abstract class EntityBase implements Entity {
+ protected EntityStorage ctx;
+ protected int id;
+
+ public EntityBase() {
+ this.id = -1;
+ this.ctx = null;
+ }
+
+ public EntityBase(EntityStorage ctx, int id) {
+ this.id = id;
+ this.ctx = ctx;
+ }
+
+ public EntityBase(EntityRecord r) {
+ this.id = r.getID();
+ this.ctx = r.getContext();
+ }
+
+ public int getEntityId() {
+ if(this.id == -1)
+ throw new IllegalStateException("Entity not initialized");
+ return this.id;
+ }
+ public void initEntity(EntityStorage ctx, int id) {
+ if((this.id != -1) && (this.ctx != null))
+ throw new IllegalStateException("Entity already initialized");
+ if(id == -1)
+ throw new IllegalArgumentException("Invalid ID -1");
+ if(ctx == null)
+ throw new NullPointerException("Context is null");
+ this.id = id;
+ this.ctx = ctx;
+ }
+
+ public boolean isEntityInitialized() {
+ return this.id != -1;
+ }
+
+}
diff --git a/src/main/java/de/welterde/em/EntityRef.java b/src/main/java/de/welterde/em/EntityRef.java
index cda120c..16d050f 100644
--- a/src/main/java/de/welterde/em/EntityRef.java
+++ b/src/main/java/de/welterde/em/EntityRef.java
@@ -24,6 +24,10 @@ import java.lang.ref.WeakReference;
* @param
*/
public class EntityRef {
+
+ static Location maybeGet(EntityRef currentLocation) {
+ throw new UnsupportedOperationException("Not supported yet."); // Generated from nbfs://nbhost/SystemFileSystem/Templates/Classes/Code/GeneratedMethodBody
+ }
protected final EntityStorage ctx;
protected WeakReference ref;
diff --git a/src/main/java/de/welterde/em/EntityStorage.java b/src/main/java/de/welterde/em/EntityStorage.java
index 7aec1b4..d75586d 100644
--- a/src/main/java/de/welterde/em/EntityStorage.java
+++ b/src/main/java/de/welterde/em/EntityStorage.java
@@ -21,5 +21,5 @@ package de.welterde.em;
* @author welterde
*/
public interface EntityStorage {
- public Entity getEntity(int entityId);
+ public EntityBase getEntity(int entityId);
}
diff --git a/src/main/java/de/welterde/em/LocatedEntity.java b/src/main/java/de/welterde/em/LocatedEntity.java
new file mode 100644
index 0000000..a2a1ee0
--- /dev/null
+++ b/src/main/java/de/welterde/em/LocatedEntity.java
@@ -0,0 +1,32 @@
+/*
+ * Copyright (C) 2026 welterde
+ *
+ * This program is free software: you can redistribute it and/or modify
+ * it under the terms of the GNU General Public License as published by
+ * the Free Software Foundation, either version 3 of the License, or
+ * (at your option) any later version.
+ *
+ * This program is distributed in the hope that it will be useful,
+ * but WITHOUT ANY WARRANTY; without even the implied warranty of
+ * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
+ * GNU General Public License for more details.
+ *
+ * You should have received a copy of the GNU General Public License
+ * along with this program. If not, see .
+ */
+package de.welterde.em;
+
+/**
+ *
+ * @author welterde
+ */
+public class LocatedEntity extends EntityBase {
+ protected EntityRef currentLocation;
+
+ public Location getLocation() {
+ if(this.currentLocation == null)
+ return null;
+ else
+ return this.currentLocation.get();
+ }
+}
diff --git a/src/main/java/de/welterde/em/data/Location.java b/src/main/java/de/welterde/em/Location.java
similarity index 88%
rename from src/main/java/de/welterde/em/data/Location.java
rename to src/main/java/de/welterde/em/Location.java
index e391732..44add0d 100644
--- a/src/main/java/de/welterde/em/data/Location.java
+++ b/src/main/java/de/welterde/em/Location.java
@@ -14,13 +14,13 @@
* You should have received a copy of the GNU General Public License
* along with this program. If not, see .
*/
-package de.welterde.em.data;
+package de.welterde.em;
/**
*
* @author welterde
*/
-public sealed interface Location permits LocationBase, Corridor, Room {
+public interface Location extends Entity {
public short getSecurityLevel();
public Location setSecurityLevel(short newLevel);
}
diff --git a/src/main/java/de/welterde/em/PositionTracker.java b/src/main/java/de/welterde/em/PositionTracker.java
new file mode 100644
index 0000000..71ac737
--- /dev/null
+++ b/src/main/java/de/welterde/em/PositionTracker.java
@@ -0,0 +1,40 @@
+/*
+ * Copyright (C) 2026 welterde
+ *
+ * This program is free software: you can redistribute it and/or modify
+ * it under the terms of the GNU General Public License as published by
+ * the Free Software Foundation, either version 3 of the License, or
+ * (at your option) any later version.
+ *
+ * This program is distributed in the hope that it will be useful,
+ * but WITHOUT ANY WARRANTY; without even the implied warranty of
+ * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
+ * GNU General Public License for more details.
+ *
+ * You should have received a copy of the GNU General Public License
+ * along with this program. If not, see .
+ */
+package de.welterde.em;
+
+import de.welterde.em.data.Direction;
+import de.welterde.em.data.MapCoord;
+
+/**
+ *
+ * @author welterde
+ */
+public interface PositionTracker {
+ /**
+ * Get current position of entity if managed by this Position Tracker
+ * (Otherwise null)
+ * @param e
+ * @return
+ */
+ public MapCoord getPosition(Entity e);
+
+ public void teleportEntity(Entity e, MapCoord destination);
+
+ public void moveEntityCardinal(Entity e, Direction dir);
+
+ public void enrollEntity(Entity e, MapCoord startCoord);
+}
diff --git a/src/main/java/de/welterde/em/PositionTrackerImpl.java b/src/main/java/de/welterde/em/PositionTrackerImpl.java
new file mode 100644
index 0000000..f802b57
--- /dev/null
+++ b/src/main/java/de/welterde/em/PositionTrackerImpl.java
@@ -0,0 +1,32 @@
+/*
+ * Copyright (C) 2026 welterde
+ *
+ * This program is free software: you can redistribute it and/or modify
+ * it under the terms of the GNU General Public License as published by
+ * the Free Software Foundation, either version 3 of the License, or
+ * (at your option) any later version.
+ *
+ * This program is distributed in the hope that it will be useful,
+ * but WITHOUT ANY WARRANTY; without even the implied warranty of
+ * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
+ * GNU General Public License for more details.
+ *
+ * You should have received a copy of the GNU General Public License
+ * along with this program. If not, see .
+ */
+package de.welterde.em;
+
+import de.welterde.em.data.MapCoord;
+
+/**
+ *
+ * @author welterde
+ */
+public class PositionTrackerImpl implements PositionTracker {
+
+ @Override
+ public MapCoord getPosition(Entity e) {
+ throw new UnsupportedOperationException("Not supported yet."); // Generated from nbfs://nbhost/SystemFileSystem/Templates/Classes/Code/GeneratedMethodBody
+ }
+
+}
diff --git a/src/main/java/de/welterde/em/Positioned.java b/src/main/java/de/welterde/em/Positioned.java
new file mode 100644
index 0000000..b8f4f36
--- /dev/null
+++ b/src/main/java/de/welterde/em/Positioned.java
@@ -0,0 +1,26 @@
+/*
+ * Copyright (C) 2026 welterde
+ *
+ * This program is free software: you can redistribute it and/or modify
+ * it under the terms of the GNU General Public License as published by
+ * the Free Software Foundation, either version 3 of the License, or
+ * (at your option) any later version.
+ *
+ * This program is distributed in the hope that it will be useful,
+ * but WITHOUT ANY WARRANTY; without even the implied warranty of
+ * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
+ * GNU General Public License for more details.
+ *
+ * You should have received a copy of the GNU General Public License
+ * along with this program. If not, see .
+ */
+package de.welterde.em;
+
+/**
+ *
+ * @author welterde
+ */
+public interface Positioned {
+ public PositionTracker getPositionTracker();
+ public void setPositionTracker();
+}
diff --git a/src/main/java/de/welterde/em/Thing.java b/src/main/java/de/welterde/em/Thing.java
new file mode 100644
index 0000000..f80f3c5
--- /dev/null
+++ b/src/main/java/de/welterde/em/Thing.java
@@ -0,0 +1,36 @@
+/*
+ * Copyright (C) 2026 welterde
+ *
+ * This program is free software: you can redistribute it and/or modify
+ * it under the terms of the GNU General Public License as published by
+ * the Free Software Foundation, either version 3 of the License, or
+ * (at your option) any later version.
+ *
+ * This program is distributed in the hope that it will be useful,
+ * but WITHOUT ANY WARRANTY; without even the implied warranty of
+ * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
+ * GNU General Public License for more details.
+ *
+ * You should have received a copy of the GNU General Public License
+ * along with this program. If not, see .
+ */
+package de.welterde.em;
+
+/**
+ * Something that has some location
+ * @author welterde
+ */
+public class Thing extends EntityBase {
+
+ protected EntityRef currentLocation;
+
+ public Location getLocation() {
+ return EntityRef.maybeGet(this.currentLocation);
+ }
+
+ public void setLocation(Location loc) {
+ this.currentLocation = new EntityRef<>(this.ctx, loc);
+ }
+
+
+}
diff --git a/src/main/java/de/welterde/em/data/Corridor.java b/src/main/java/de/welterde/em/data/Corridor.java
index b283407..259c6e7 100644
--- a/src/main/java/de/welterde/em/data/Corridor.java
+++ b/src/main/java/de/welterde/em/data/Corridor.java
@@ -16,6 +16,8 @@
*/
package de.welterde.em.data;
+import de.welterde.em.Location;
+
/**
*
* @author welterde
diff --git a/src/main/java/de/welterde/em/data/Entity.java b/src/main/java/de/welterde/em/data/Entity.java
index b4db73d..6f509a7 100644
--- a/src/main/java/de/welterde/em/data/Entity.java
+++ b/src/main/java/de/welterde/em/data/Entity.java
@@ -16,6 +16,8 @@
*/
package de.welterde.em.data;
+import de.welterde.em.Location;
+
/**
*
* @author welterde
diff --git a/src/main/java/de/welterde/em/data/LocationBase.java b/src/main/java/de/welterde/em/data/LocationBase.java
index ed48df9..ad056ad 100644
--- a/src/main/java/de/welterde/em/data/LocationBase.java
+++ b/src/main/java/de/welterde/em/data/LocationBase.java
@@ -16,6 +16,8 @@
*/
package de.welterde.em.data;
+import de.welterde.em.Location;
+
/**
*
* @author welterde
diff --git a/src/main/java/de/welterde/em/data/MapCoord.java b/src/main/java/de/welterde/em/data/MapCoord.java
index b7f711e..feca9f5 100644
--- a/src/main/java/de/welterde/em/data/MapCoord.java
+++ b/src/main/java/de/welterde/em/data/MapCoord.java
@@ -4,6 +4,9 @@
*/
package de.welterde.em.data;
+import de.welterde.em.data.CoordVector;
+import de.welterde.em.data.Direction;
+
/**
* z coordinate goes from 65km to 0, where ground-level is at 50km
* @author welterde
diff --git a/src/main/java/de/welterde/em/data/OutpostMap.java b/src/main/java/de/welterde/em/data/OutpostMap.java
index 3e334df..8c4fcb2 100644
--- a/src/main/java/de/welterde/em/data/OutpostMap.java
+++ b/src/main/java/de/welterde/em/data/OutpostMap.java
@@ -4,6 +4,7 @@
*/
package de.welterde.em.data;
+import de.welterde.em.Location;
import java.util.EnumMap;
import java.util.HashMap;
import java.util.Map;
diff --git a/src/main/java/de/welterde/em/data/Room.java b/src/main/java/de/welterde/em/data/Room.java
index ecc74e8..1ff20df 100644
--- a/src/main/java/de/welterde/em/data/Room.java
+++ b/src/main/java/de/welterde/em/data/Room.java
@@ -16,6 +16,8 @@
*/
package de.welterde.em.data;
+import de.welterde.em.Location;
+
/**
*
* @author welterde
diff --git a/src/main/java/de/welterde/em/data/Tile.java b/src/main/java/de/welterde/em/data/Tile.java
index 49af1eb..0dcf655 100644
--- a/src/main/java/de/welterde/em/data/Tile.java
+++ b/src/main/java/de/welterde/em/data/Tile.java
@@ -16,6 +16,8 @@
*/
package de.welterde.em.data;
+import de.welterde.em.Location;
+
/**
*
* @author welterde
diff --git a/src/main/java/de/welterde/em/data/TileImpl.java b/src/main/java/de/welterde/em/data/TileImpl.java
index b34291a..05a52d0 100644
--- a/src/main/java/de/welterde/em/data/TileImpl.java
+++ b/src/main/java/de/welterde/em/data/TileImpl.java
@@ -16,6 +16,7 @@
*/
package de.welterde.em.data;
+import de.welterde.em.Location;
import de.welterde.em.CollisionException;
/**
diff --git a/src/main/java/de/welterde/em/e/Employee.java b/src/main/java/de/welterde/em/e/Employee.java
index 26d3677..35b1b97 100644
--- a/src/main/java/de/welterde/em/e/Employee.java
+++ b/src/main/java/de/welterde/em/e/Employee.java
@@ -16,13 +16,20 @@
*/
package de.welterde.em.e;
+import de.welterde.em.EntityBase;
+import de.welterde.em.EntityRef;
+import de.welterde.em.Location;
+import de.welterde.em.w.Org;
+
/**
*
* @author welterde
*/
-public class Employee {
+public class Employee extends EntityBase {
protected String name;
+ protected EntityRef employer;
+
public Employee(String name) {
this.name = name;
diff --git a/src/main/java/de/welterde/em/entity/ItemBase.java b/src/main/java/de/welterde/em/entity/ItemBase.java
index 3ab7cf8..a5f14fe 100644
--- a/src/main/java/de/welterde/em/entity/ItemBase.java
+++ b/src/main/java/de/welterde/em/entity/ItemBase.java
@@ -16,12 +16,16 @@
*/
package de.welterde.em.entity;
-import de.welterde.em.data.Entity;
+import de.welterde.em.EntityBase;
+import de.welterde.em.EntityStorage;
/**
*
* @author welterde
*/
-public abstract class ItemBase implements Entity {
+public abstract class ItemBase extends EntityBase {
+ public ItemBase(EntityStorage ctx, int id) {
+ super(ctx, id);
+ }
}
diff --git a/src/main/java/de/welterde/em/io/EntityLoader.java b/src/main/java/de/welterde/em/io/EntityLoader.java
new file mode 100644
index 0000000..64721a4
--- /dev/null
+++ b/src/main/java/de/welterde/em/io/EntityLoader.java
@@ -0,0 +1,49 @@
+/*
+ * Copyright (C) 2026 welterde
+ *
+ * This program is free software: you can redistribute it and/or modify
+ * it under the terms of the GNU General Public License as published by
+ * the Free Software Foundation, either version 3 of the License, or
+ * (at your option) any later version.
+ *
+ * This program is distributed in the hope that it will be useful,
+ * but WITHOUT ANY WARRANTY; without even the implied warranty of
+ * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
+ * GNU General Public License for more details.
+ *
+ * You should have received a copy of the GNU General Public License
+ * along with this program. If not, see .
+ */
+package de.welterde.em.io;
+
+import de.welterde.em.EntityBase;
+import java.lang.reflect.InvocationTargetException;
+
+/**
+ *
+ * @author welterde
+ */
+public class EntityLoader {
+
+
+
+ protected EntityBase loadEntity(EntityRecord r, String entityClassName) {
+ try {
+ var c = Class.forName(entityClassName);
+ var cc = c.getConstructor(EntityRecord.class);
+ return (EntityBase) cc.newInstance(r);
+ } catch (ClassNotFoundException ex) {
+ throw new RuntimeException("Could not find class: " + entityClassName);
+ } catch (NoSuchMethodException ex) {
+ throw new RuntimeException("Entity class " + entityClassName + " does not support loading (missing EntityRecord constructor)");
+ } catch (InstantiationException ex) {
+ throw new RuntimeException(ex);
+ } catch (IllegalAccessException ex) {
+ throw new RuntimeException(ex);
+ } catch (IllegalArgumentException ex) {
+ throw new RuntimeException(ex);
+ } catch (InvocationTargetException ex) {
+ throw new RuntimeException(ex);
+ }
+ }
+}
diff --git a/src/main/java/de/welterde/em/io/EntityRecord.java b/src/main/java/de/welterde/em/io/EntityRecord.java
new file mode 100644
index 0000000..8f54d17
--- /dev/null
+++ b/src/main/java/de/welterde/em/io/EntityRecord.java
@@ -0,0 +1,28 @@
+/*
+ * Copyright (C) 2026 welterde
+ *
+ * This program is free software: you can redistribute it and/or modify
+ * it under the terms of the GNU General Public License as published by
+ * the Free Software Foundation, either version 3 of the License, or
+ * (at your option) any later version.
+ *
+ * This program is distributed in the hope that it will be useful,
+ * but WITHOUT ANY WARRANTY; without even the implied warranty of
+ * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
+ * GNU General Public License for more details.
+ *
+ * You should have received a copy of the GNU General Public License
+ * along with this program. If not, see .
+ */
+package de.welterde.em.io;
+
+import de.welterde.em.EntityStorage;
+
+/**
+ *
+ * @author welterde
+ */
+public interface EntityRecord {
+ public int getID();
+ public EntityStorage getContext();
+}
diff --git a/src/main/java/de/welterde/em/w/Area.java b/src/main/java/de/welterde/em/w/Area.java
index 6d8b46e..1c8f557 100644
--- a/src/main/java/de/welterde/em/w/Area.java
+++ b/src/main/java/de/welterde/em/w/Area.java
@@ -16,7 +16,9 @@
*/
package de.welterde.em.w;
-import de.welterde.em.data.Location;
+import de.welterde.em.EntityBase;
+import de.welterde.em.EntityStorage;
+import de.welterde.em.Location;
import de.welterde.em.data.TerrainGen;
import java.util.HashMap;
import java.util.Map;
@@ -27,15 +29,14 @@ import java.util.concurrent.locks.ReentrantReadWriteLock;
*
* @author welterde
*/
-public class Area {
- protected final int id;
+public class Area extends EntityBase {
protected final ReadWriteLock structLock;
protected final AreaMap map;
protected final Map locations;
- public Area(int id, TerrainGen gen) {
- this.id = id;
+ public Area(EntityStorage ctx, int id, TerrainGen gen) {
+ super(ctx, id);
this.structLock = new ReentrantReadWriteLock();
this.map = new AreaMap(gen);
diff --git a/src/main/java/de/welterde/em/w/City.java b/src/main/java/de/welterde/em/w/City.java
index f0d075f..27e499e 100644
--- a/src/main/java/de/welterde/em/w/City.java
+++ b/src/main/java/de/welterde/em/w/City.java
@@ -16,10 +16,15 @@
*/
package de.welterde.em.w;
+import de.welterde.em.EntityBase;
+import de.welterde.em.EntityStorage;
+
/**
*
* @author welterde
*/
-public class City {
-
+public class City extends EntityBase {
+ public City(EntityStorage ctx, int id) {
+ super(ctx, id);
+ }
}
diff --git a/src/main/java/de/welterde/em/w/Country.java b/src/main/java/de/welterde/em/w/Country.java
index 991ed6d..5a409b5 100644
--- a/src/main/java/de/welterde/em/w/Country.java
+++ b/src/main/java/de/welterde/em/w/Country.java
@@ -16,14 +16,14 @@
*/
package de.welterde.em.w;
-import de.welterde.em.Entity;
+import de.welterde.em.EntityBase;
import de.welterde.em.EntityStorage;
/**
*
* @author welterde
*/
-public class Country extends Entity {
+public class Country extends EntityBase {
public Country(EntityStorage ctx, int id) {
super(ctx, id);
diff --git a/src/main/java/de/welterde/em/w/Dimension.java b/src/main/java/de/welterde/em/w/Dimension.java
index 44178b5..978d6d7 100644
--- a/src/main/java/de/welterde/em/w/Dimension.java
+++ b/src/main/java/de/welterde/em/w/Dimension.java
@@ -16,7 +16,7 @@
*/
package de.welterde.em.w;
-import de.welterde.em.Entity;
+import de.welterde.em.EntityBase;
import de.welterde.em.data.CounterName;
import de.welterde.em.data.TerrainGen;
import java.util.HashMap;
@@ -28,7 +28,7 @@ import java.util.concurrent.locks.ReentrantReadWriteLock;
*
* @author welterde
*/
-public class Dimension extends Entity {
+public class Dimension extends EntityBase {
protected final ReadWriteLock structLock;
protected final Map areas;
diff --git a/src/main/java/de/welterde/em/w/Org.java b/src/main/java/de/welterde/em/w/Org.java
index ade2034..ca95ecb 100644
--- a/src/main/java/de/welterde/em/w/Org.java
+++ b/src/main/java/de/welterde/em/w/Org.java
@@ -16,10 +16,26 @@
*/
package de.welterde.em.w;
+import de.welterde.em.EntityBase;
+import de.welterde.em.EntityRef;
+import de.welterde.em.e.Employee;
+import java.util.ArrayList;
+import java.util.List;
+
/**
* Organization
* @author welterde
*/
-public class Org {
+public class Org extends EntityBase {
+ protected String name;
+ protected EntityRef hqOutpost;
+ protected final List> outposts;
+ protected final List> employees;
+
+ public Org(String name) {
+ this.name = name;
+ this.outposts = new ArrayList<>();
+ this.employees = new ArrayList<>();
+ }
}
diff --git a/src/main/java/de/welterde/em/w/Outpost.java b/src/main/java/de/welterde/em/w/Outpost.java
index 5bea1fb..c77ff55 100644
--- a/src/main/java/de/welterde/em/w/Outpost.java
+++ b/src/main/java/de/welterde/em/w/Outpost.java
@@ -16,16 +16,38 @@
*/
package de.welterde.em.w;
+import de.welterde.em.EntityBase;
+import de.welterde.em.EntityRef;
+import de.welterde.em.EntityStorage;
import java.util.EnumSet;
/**
*
* @author welterde
*/
-public class Outpost {
+public class Outpost extends EntityBase {
protected final EnumSet flags;
+ protected final OutpostLocationType locationType;
+ protected EntityRef city;
- public Outpost() {
+ public Outpost(EntityStorage ctx, int id, OutpostLocationType locationType) {
+ super(ctx, id);
this.flags = EnumSet.noneOf(OutpostFlags.class);
+ this.locationType = locationType;
+ }
+
+ public EnumSet getFlags() {
+ return flags.clone();
+ }
+
+ public OutpostLocationType getLocationType() {
+ return locationType;
+ }
+
+ public City getCity() {
+ if(this.city != null)
+ return this.city.get();
+ else
+ return null;
}
}
diff --git a/src/main/java/de/welterde/em/w/World.java b/src/main/java/de/welterde/em/w/World.java
index 47b40ea..0a0a349 100644
--- a/src/main/java/de/welterde/em/w/World.java
+++ b/src/main/java/de/welterde/em/w/World.java
@@ -16,7 +16,7 @@
*/
package de.welterde.em.w;
-import de.welterde.em.Entity;
+import de.welterde.em.EntityBase;
import de.welterde.em.EntityRef;
import de.welterde.em.EntityStorage;
import de.welterde.em.data.CounterName;
@@ -25,6 +25,7 @@ import java.util.EnumMap;
import java.util.HashMap;
import java.util.List;
import java.util.Map;
+import java.util.concurrent.atomic.AtomicReference;
import java.util.concurrent.locks.ReadWriteLock;
import java.util.concurrent.locks.ReentrantReadWriteLock;
@@ -33,19 +34,27 @@ import java.util.concurrent.locks.ReentrantReadWriteLock;
* @author welterde
*/
public class World implements EntityStorage {
- protected final ArrayList entities;
+ protected final ArrayList entities;
protected final EnumMap counters;
- protected final ArrayList> dimensions;
- protected final Map> countries;
+
+ protected final ArrayList dimensions;
+ protected final Map countries;
+ protected final Map orgs;
+ protected final Map outposts;
+
protected final ReadWriteLock structLock;
+ protected final AtomicReference state;
public World() {
this.counters = new EnumMap<>(CounterName.class);
this.dimensions = new ArrayList<>();
this.countries = new HashMap<>();
this.entities = new ArrayList<>();
+ this.orgs = new HashMap<>();
+ this.outposts = new HashMap<>();
this.structLock = new ReentrantReadWriteLock();
+ this.state = new AtomicReference<>(WorldState.INIT);
}
@@ -81,7 +90,46 @@ public class World implements EntityStorage {
}
@Override
- public Entity getEntity(int entityId) {
+ public EntityBase getEntity(int entityId) {
return this.entities.get(entityId);
}
+
+
+ public void addEntity(EntityBase e) {
+ if(e.isEntityInitialized())
+ throw new IllegalStateException("Entity already initialized");
+
+ int id;
+ this.structLock.writeLock().lock();
+ try {
+ id = this.entities.size();
+ e.initEntity(this, id);
+ this.entities.add(e);
+ } finally {
+ this.structLock.writeLock().unlock();
+ }
+
+ // TODO: Add to queue for new entity listeners?
+ this.handleNewEntity(e);
+ }
+
+ public void handleNewEntity(EntityBase e) {
+ switch(e) {
+ case Dimension d -> {
+
+ }
+ case Country c -> {
+
+ }
+ case Org o -> {
+
+ }
+ case Outpost o -> {
+
+ }
+ default -> {
+ // dont care..
+ }
+ }
+ }
}
diff --git a/src/main/java/de/welterde/em/w/WorldState.java b/src/main/java/de/welterde/em/w/WorldState.java
new file mode 100644
index 0000000..7e39484
--- /dev/null
+++ b/src/main/java/de/welterde/em/w/WorldState.java
@@ -0,0 +1,28 @@
+/*
+ * Copyright (C) 2026 welterde
+ *
+ * This program is free software: you can redistribute it and/or modify
+ * it under the terms of the GNU General Public License as published by
+ * the Free Software Foundation, either version 3 of the License, or
+ * (at your option) any later version.
+ *
+ * This program is distributed in the hope that it will be useful,
+ * but WITHOUT ANY WARRANTY; without even the implied warranty of
+ * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
+ * GNU General Public License for more details.
+ *
+ * You should have received a copy of the GNU General Public License
+ * along with this program. If not, see .
+ */
+package de.welterde.em.w;
+
+/**
+ *
+ * @author welterde
+ */
+public enum WorldState {
+ READY,
+ LOADING,
+ DUMPING,
+ INIT
+}