Sync work
This commit is contained in:
parent
16cc8ebbb6
commit
b0dfee6be0
25
Terrain
Normal file
25
Terrain
Normal file
@ -0,0 +1,25 @@
|
||||
Terrain:
|
||||
|
||||
generate 200 x 200
|
||||
interpolate x 10 in each direction
|
||||
this map will be 1 km resolution
|
||||
Useful for macro sim
|
||||
|
||||
pick points to place mountains at
|
||||
use curves to generate rivers in data
|
||||
|
||||
for gameplay,
|
||||
interpolate x 100 in each direction in memory for local areas to player
|
||||
finally chunks are 16 x 16 x 16
|
||||
|
||||
|
||||
sines going in x
|
||||
cosines going in z
|
||||
at different frequencies, with modifiers based on the percentage of each biome in the current coordinate
|
||||
add the sines + cosines to the current interpolated height
|
||||
Have a couple different instances of simplex noise at different frequencies and amplitudes that get phased in/out based on biome
|
||||
|
||||
2d perlin noise where "activation zone" is only values >0.9
|
||||
when in activation zone x,z, have 3d perlin noise down to a given point that carves cavities
|
||||
^should generate earthen pillars
|
||||
|
||||
@ -0,0 +1,65 @@
|
||||
package electrosphere.net.sync;
|
||||
|
||||
import java.util.HashMap;
|
||||
import java.util.LinkedList;
|
||||
import java.util.List;
|
||||
import java.util.Map;
|
||||
|
||||
import electrosphere.entity.Entity;
|
||||
|
||||
/**
|
||||
* A service that tracks entities which have behavior trees that need to be looked up in list
|
||||
* Principally used by the synchronization logic to iterate over all networked behavior trees on either server or client
|
||||
*/
|
||||
public class EntityValueTrackingService {
|
||||
|
||||
//The main map that contains all the entities that are tracked and their respective behavior tree ids
|
||||
Map<Entity,List<Integer>> treeMap = new HashMap<Entity,List<Integer>>();
|
||||
|
||||
|
||||
/**
|
||||
* Gets the list of tree ids attached to a given entity
|
||||
* @param entity The entity to check
|
||||
* @return If the entity is tracked and has attached trees, will return the list of attached trees. If the entity is not tracked or has no attached trees, will return null.
|
||||
*/
|
||||
public List<Integer> getEntityTrees(Entity entity){
|
||||
return treeMap.get(entity);
|
||||
}
|
||||
|
||||
/**
|
||||
* Attaches a behavior tree id to an entity
|
||||
* @param entity The entity ot attach to
|
||||
* @param treeId The numeric id of the behavior tree type
|
||||
*/
|
||||
public void attachTreeToEntity(Entity entity, int treeId){
|
||||
if(treeMap.containsKey(entity)){
|
||||
if(!treeMap.get(entity).contains(treeId)){
|
||||
treeMap.get(entity).add(treeId);
|
||||
}
|
||||
} else {
|
||||
List<Integer> treeList = new LinkedList<Integer>();
|
||||
treeList.add(treeId);
|
||||
treeMap.put(entity,treeList);
|
||||
}
|
||||
}
|
||||
|
||||
/**
|
||||
* Removes a behavior tree id from an entity
|
||||
* @param entity The entity
|
||||
* @param treeId The numeric id of the behavior tree type
|
||||
*/
|
||||
public void detatchTreeFromEntity(Entity entity, int treeId){
|
||||
if(treeMap.containsKey(entity)){
|
||||
treeMap.get(entity).remove((Object)treeId);
|
||||
}
|
||||
}
|
||||
|
||||
/**
|
||||
* Deregisters the entity from the tracking service
|
||||
* @param entity The entity
|
||||
*/
|
||||
public void deregisterEntity(Entity entity){
|
||||
treeMap.remove(entity);
|
||||
}
|
||||
|
||||
}
|
||||
30
src/main/java/electrosphere/net/sync/TypeTranslator.java
Normal file
30
src/main/java/electrosphere/net/sync/TypeTranslator.java
Normal file
@ -0,0 +1,30 @@
|
||||
package electrosphere.net.sync;
|
||||
|
||||
import electrosphere.entity.state.idle.IdleTree.IdleTreeState;
|
||||
|
||||
public class TypeTranslator {
|
||||
|
||||
|
||||
public static short getIdleStateEnumAsShort(IdleTreeState enumVal){
|
||||
switch(enumVal){
|
||||
case IDLE:
|
||||
return 0;
|
||||
case NOT_IDLE:
|
||||
return 1;
|
||||
default:
|
||||
return 0;
|
||||
}
|
||||
}
|
||||
|
||||
public static IdleTreeState getIdleStateShortAsEnum(short rawValue){
|
||||
switch(rawValue){
|
||||
case 0:
|
||||
return IdleTreeState.IDLE;
|
||||
case 1:
|
||||
return IdleTreeState.NOT_IDLE;
|
||||
default:
|
||||
return IdleTreeState.IDLE;
|
||||
}
|
||||
}
|
||||
|
||||
}
|
||||
Loading…
Reference in New Issue
Block a user