Compare commits
No commits in common. "4c65b59b1b0d3905518bf91b7b2eccb61f2b01bf" and "3682497060cadabd0f403626f48340cca4ac3938" have entirely different histories.
4c65b59b1b
...
3682497060
@ -1,3 +1,4 @@
|
|||||||
|
import { ClientInventory, onEquipItem, onMoveItemContainer, onUnequipItem } from "/Scripts/client/entity/inventory";
|
||||||
import { Namespace } from "/Scripts/types/namespace";
|
import { Namespace } from "/Scripts/types/namespace";
|
||||||
|
|
||||||
|
|
||||||
@ -5,17 +6,17 @@ import { Namespace } from "/Scripts/types/namespace";
|
|||||||
* The client namespace type
|
* The client namespace type
|
||||||
*/
|
*/
|
||||||
export interface NamespaceClient extends Namespace {
|
export interface NamespaceClient extends Namespace {
|
||||||
// inventory: ClientInventory,
|
inventory: ClientInventory,
|
||||||
}
|
}
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* The client namespace (should contain all client callbacks, data, etc)
|
* The client namespace (should contain all client callbacks, data, etc)
|
||||||
*/
|
*/
|
||||||
export const Client: NamespaceClient = {
|
export const Client: NamespaceClient = {
|
||||||
// inventory: {
|
inventory: {
|
||||||
// onMoveItemContainer: onMoveItemContainer,
|
onMoveItemContainer: onMoveItemContainer,
|
||||||
// onEquipItem: onEquipItem,
|
onEquipItem: onEquipItem,
|
||||||
// onUnequipItem: onUnequipItem,
|
onUnequipItem: onUnequipItem,
|
||||||
// },
|
},
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|||||||
@ -1,4 +1,4 @@
|
|||||||
import { Entity } from "/Scripts/types/host/entity/entity"
|
import { Entity } from "/Scripts/engine/entity/entity"
|
||||||
|
|
||||||
|
|
||||||
/**
|
/**
|
||||||
|
|||||||
10
assets/Scripts/engine/entity/entity.ts
Normal file
10
assets/Scripts/engine/entity/entity.ts
Normal file
@ -0,0 +1,10 @@
|
|||||||
|
|
||||||
|
|
||||||
|
/**
|
||||||
|
* An entity
|
||||||
|
*/
|
||||||
|
export interface Entity {
|
||||||
|
id: number,
|
||||||
|
}
|
||||||
|
|
||||||
|
|
||||||
@ -1,16 +0,0 @@
|
|||||||
|
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
/**
|
|
||||||
* An entity
|
|
||||||
*/
|
|
||||||
export interface Entity {
|
|
||||||
|
|
||||||
/**
|
|
||||||
* Gets the id of the entity
|
|
||||||
* @returns The id
|
|
||||||
*/
|
|
||||||
getId: () => number,
|
|
||||||
|
|
||||||
}
|
|
||||||
@ -1,6 +1,4 @@
|
|||||||
import { Entity } from "/Scripts/types/host/entity/entity";
|
|
||||||
import { TutorialUtils } from "/Scripts/types/host/renderer/ui/tutorial";
|
import { TutorialUtils } from "/Scripts/types/host/renderer/ui/tutorial";
|
||||||
import { Vector } from "/Scripts/types/spatial";
|
|
||||||
|
|
||||||
|
|
||||||
/**
|
/**
|
||||||
@ -23,11 +21,6 @@ export interface StaticClasses {
|
|||||||
*/
|
*/
|
||||||
readonly tutorialUtils?: Class<TutorialUtils>,
|
readonly tutorialUtils?: Class<TutorialUtils>,
|
||||||
|
|
||||||
/**
|
|
||||||
* Utilities for performing actions on the server
|
|
||||||
*/
|
|
||||||
readonly serverUtils?: Class<ServerUtils>,
|
|
||||||
|
|
||||||
|
|
||||||
}
|
}
|
||||||
|
|
||||||
@ -57,31 +50,3 @@ export interface SimulationClass {
|
|||||||
readonly setFramestep: (value: number) => void,
|
readonly setFramestep: (value: number) => void,
|
||||||
|
|
||||||
}
|
}
|
||||||
|
|
||||||
/**
|
|
||||||
* Utilities for core functionality on the server
|
|
||||||
*/
|
|
||||||
export interface ServerUtils {
|
|
||||||
|
|
||||||
/**
|
|
||||||
* Spawns a creature
|
|
||||||
* @param creatureType The type of creature
|
|
||||||
* @returns The entity created on the server
|
|
||||||
*/
|
|
||||||
readonly spawnCreature: (sceneInstanceId: number, creatureType: string, position: Vector) => Entity
|
|
||||||
|
|
||||||
/**
|
|
||||||
* Gets the position of an entity
|
|
||||||
* @param entity The entity
|
|
||||||
* @returns The position
|
|
||||||
*/
|
|
||||||
readonly getPosition: (entity: Entity) => Vector
|
|
||||||
|
|
||||||
/**
|
|
||||||
* Sets the position of an entity
|
|
||||||
* @param entity The entity
|
|
||||||
* @param position The position
|
|
||||||
*/
|
|
||||||
readonly setPosition: (entity: Entity, position: Vector) => void
|
|
||||||
|
|
||||||
}
|
|
||||||
|
|||||||
@ -631,10 +631,6 @@ Return to main menu from ingame
|
|||||||
Tagging threads in manager
|
Tagging threads in manager
|
||||||
Quitting to main menu
|
Quitting to main menu
|
||||||
|
|
||||||
(08/25/2024)
|
|
||||||
Server utilities provided to scripting engine
|
|
||||||
Spawn player character with weapon when testing levels
|
|
||||||
|
|
||||||
|
|
||||||
# TODO
|
# TODO
|
||||||
|
|
||||||
|
|||||||
@ -11,7 +11,6 @@ import org.joml.Vector3i;
|
|||||||
import electrosphere.auth.AuthenticationManager;
|
import electrosphere.auth.AuthenticationManager;
|
||||||
import electrosphere.engine.Globals;
|
import electrosphere.engine.Globals;
|
||||||
import electrosphere.engine.threads.LabeledThread.ThreadLabel;
|
import electrosphere.engine.threads.LabeledThread.ThreadLabel;
|
||||||
import electrosphere.entity.types.creature.CreatureEquipData.EquippedItem;
|
|
||||||
import electrosphere.entity.types.creature.CreatureTemplate;
|
import electrosphere.entity.types.creature.CreatureTemplate;
|
||||||
import electrosphere.game.data.creature.type.CreatureData;
|
import electrosphere.game.data.creature.type.CreatureData;
|
||||||
import electrosphere.game.data.creature.type.visualattribute.VisualAttribute;
|
import electrosphere.game.data.creature.type.visualattribute.VisualAttribute;
|
||||||
@ -167,7 +166,6 @@ public class LoadingUtils {
|
|||||||
template.putAttributeValue(attribute.getAttributeId(), attribute.getVariants().get(0).getId());
|
template.putAttributeValue(attribute.getAttributeId(), attribute.getVariants().get(0).getId());
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
template.getCreatureEquipData().setSlotItem("handsCombined",new EquippedItem(71, "Katana2H"));
|
|
||||||
//set player character template
|
//set player character template
|
||||||
serverPlayerConnection.setCreatureTemplate(template);
|
serverPlayerConnection.setCreatureTemplate(template);
|
||||||
Globals.clientConnection.queueOutgoingMessage(CharacterMessage.constructRequestSpawnCharacterMessage());
|
Globals.clientConnection.queueOutgoingMessage(CharacterMessage.constructRequestSpawnCharacterMessage());
|
||||||
|
|||||||
@ -2,8 +2,6 @@ package electrosphere.entity;
|
|||||||
|
|
||||||
import java.util.HashMap;
|
import java.util.HashMap;
|
||||||
|
|
||||||
import org.graalvm.polyglot.HostAccess.Export;
|
|
||||||
|
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* An entity
|
* An entity
|
||||||
@ -31,7 +29,6 @@ public class Entity {
|
|||||||
* Gets the id of this entity
|
* Gets the id of this entity
|
||||||
* @return The id
|
* @return The id
|
||||||
*/
|
*/
|
||||||
@Export
|
|
||||||
public int getId() {
|
public int getId() {
|
||||||
return id;
|
return id;
|
||||||
}
|
}
|
||||||
|
|||||||
@ -70,6 +70,12 @@ public class ServerEntityUtils {
|
|||||||
}
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
// //if the server is also a client, update the drawcell manager to know to pull new chunks
|
||||||
|
// if(Globals.RUN_CLIENT){
|
||||||
|
// Globals.drawCellManager.invalidateAllCells();
|
||||||
|
// Globals.drawCellManager.setCellX(Globals.clientPlayerData.getWorldPos().x);
|
||||||
|
// Globals.drawCellManager.setCellY(Globals.clientPlayerData.getWorldPos().z);
|
||||||
|
// }
|
||||||
//reposition entity
|
//reposition entity
|
||||||
CollisionObjUtils.serverPositionCharacter(entity, position);
|
CollisionObjUtils.serverPositionCharacter(entity, position);
|
||||||
}
|
}
|
||||||
|
|||||||
@ -17,7 +17,6 @@ import electrosphere.engine.Globals;
|
|||||||
import electrosphere.engine.Main;
|
import electrosphere.engine.Main;
|
||||||
import electrosphere.logger.LoggerInterface;
|
import electrosphere.logger.LoggerInterface;
|
||||||
import electrosphere.menu.tutorial.TutorialMenus;
|
import electrosphere.menu.tutorial.TutorialMenus;
|
||||||
import electrosphere.script.translation.JSServerUtils;
|
|
||||||
import electrosphere.util.FileUtils;
|
import electrosphere.util.FileUtils;
|
||||||
import electrosphere.util.math.MathUtils;
|
import electrosphere.util.math.MathUtils;
|
||||||
|
|
||||||
@ -86,7 +85,6 @@ public class ScriptEngine {
|
|||||||
{"mathUtils",MathUtils.class},
|
{"mathUtils",MathUtils.class},
|
||||||
{"simulation",Main.class},
|
{"simulation",Main.class},
|
||||||
{"tutorialUtils",TutorialMenus.class},
|
{"tutorialUtils",TutorialMenus.class},
|
||||||
{"serverUtils",JSServerUtils.class},
|
|
||||||
};
|
};
|
||||||
|
|
||||||
//singletons from the host that are provided to the javascript context
|
//singletons from the host that are provided to the javascript context
|
||||||
|
|||||||
@ -1,42 +0,0 @@
|
|||||||
package electrosphere.script.translation;
|
|
||||||
|
|
||||||
import electrosphere.entity.Entity;
|
|
||||||
import electrosphere.entity.EntityUtils;
|
|
||||||
import electrosphere.entity.ServerEntityUtils;
|
|
||||||
import electrosphere.entity.types.creature.CreatureUtils;
|
|
||||||
import electrosphere.script.access.Vector;
|
|
||||||
import electrosphere.script.utils.AccessTransforms;
|
|
||||||
|
|
||||||
/**
|
|
||||||
* Server utilities provided to the js context
|
|
||||||
*/
|
|
||||||
public class JSServerUtils {
|
|
||||||
|
|
||||||
/**
|
|
||||||
* Spawns a creature
|
|
||||||
* @param creatureType The creature
|
|
||||||
*/
|
|
||||||
public static void spawnCreature(int sceneInstanceId, String creatureType, Vector position){
|
|
||||||
//TODO: find realm from scene id
|
|
||||||
CreatureUtils.serverSpawnBasicCreature(null, AccessTransforms.getVector(position), creatureType, null);
|
|
||||||
}
|
|
||||||
|
|
||||||
/**
|
|
||||||
* Gets the position of an entity
|
|
||||||
* @param entity The entity
|
|
||||||
* @return The position of the entity
|
|
||||||
*/
|
|
||||||
public static Vector getPosition(Entity entity){
|
|
||||||
return AccessTransforms.getVector(EntityUtils.getPosition(entity));
|
|
||||||
}
|
|
||||||
|
|
||||||
/**
|
|
||||||
* Sets the position of an entity
|
|
||||||
* @param entity The entity
|
|
||||||
* @param vector THe new position of the entity
|
|
||||||
*/
|
|
||||||
public static void setPosition(Entity entity, Vector vector){
|
|
||||||
ServerEntityUtils.repositionEntity(entity, AccessTransforms.getVector(vector));
|
|
||||||
}
|
|
||||||
|
|
||||||
}
|
|
||||||
@ -15,13 +15,4 @@ public class AccessTransforms {
|
|||||||
return new electrosphere.script.access.Vector(source.x, source.y, source.z);
|
return new electrosphere.script.access.Vector(source.x, source.y, source.z);
|
||||||
}
|
}
|
||||||
|
|
||||||
/**
|
|
||||||
* Converts an access vector into a JOML vector
|
|
||||||
* @param source The access vectpr
|
|
||||||
* @return The JOML vector
|
|
||||||
*/
|
|
||||||
public static org.joml.Vector3d getVector(electrosphere.script.access.Vector source){
|
|
||||||
return new org.joml.Vector3d(source.x,source.y,source.z);
|
|
||||||
}
|
|
||||||
|
|
||||||
}
|
}
|
||||||
|
|||||||
@ -5,19 +5,13 @@ import org.joml.Vector3i;
|
|||||||
|
|
||||||
import electrosphere.engine.Globals;
|
import electrosphere.engine.Globals;
|
||||||
import electrosphere.entity.Entity;
|
import electrosphere.entity.Entity;
|
||||||
import electrosphere.entity.EntityUtils;
|
|
||||||
import electrosphere.entity.state.equip.ServerEquipState;
|
|
||||||
import electrosphere.entity.state.inventory.InventoryUtils;
|
|
||||||
import electrosphere.entity.state.server.ServerPlayerViewDirTree;
|
import electrosphere.entity.state.server.ServerPlayerViewDirTree;
|
||||||
import electrosphere.entity.types.creature.CreatureEquipData.EquippedItem;
|
|
||||||
import electrosphere.entity.types.creature.CreatureTemplate;
|
import electrosphere.entity.types.creature.CreatureTemplate;
|
||||||
import electrosphere.entity.types.creature.CreatureUtils;
|
import electrosphere.entity.types.creature.CreatureUtils;
|
||||||
import electrosphere.entity.types.item.ItemUtils;
|
|
||||||
import electrosphere.logger.LoggerInterface;
|
import electrosphere.logger.LoggerInterface;
|
||||||
import electrosphere.net.server.ServerConnectionHandler;
|
import electrosphere.net.server.ServerConnectionHandler;
|
||||||
import electrosphere.net.server.player.Player;
|
import electrosphere.net.server.player.Player;
|
||||||
import electrosphere.server.datacell.Realm;
|
import electrosphere.server.datacell.Realm;
|
||||||
import electrosphere.server.datacell.utils.EntityLookupUtils;
|
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* Deals with spawning player characters
|
* Deals with spawning player characters
|
||||||
@ -42,24 +36,6 @@ public class PlayerCharacterCreation {
|
|||||||
Vector3d spawnPoint = realm.getSpawnPoint();
|
Vector3d spawnPoint = realm.getSpawnPoint();
|
||||||
Entity newPlayerEntity = CreatureUtils.serverSpawnBasicCreature(realm,new Vector3d(spawnPoint.x,spawnPoint.y,spawnPoint.z),raceName,template);
|
Entity newPlayerEntity = CreatureUtils.serverSpawnBasicCreature(realm,new Vector3d(spawnPoint.x,spawnPoint.y,spawnPoint.z),raceName,template);
|
||||||
|
|
||||||
//
|
|
||||||
//now that creature has been spawned, need to create all attached items
|
|
||||||
if(template != null && template.getCreatureEquipData() != null && template.getCreatureEquipData().getSlots() != null){
|
|
||||||
for(String equipSlotId : template.getCreatureEquipData().getSlots()){
|
|
||||||
|
|
||||||
//spawn the item in the world
|
|
||||||
EquippedItem itemDefinition = template.getCreatureEquipData().getSlotItem(equipSlotId);
|
|
||||||
Entity itemInWorld = ItemUtils.serverSpawnBasicItem(realm, EntityUtils.getPosition(newPlayerEntity), itemDefinition.getItemType());
|
|
||||||
|
|
||||||
//add the item to the creature's inventory
|
|
||||||
Entity itemInInventory = InventoryUtils.serverAttemptStoreItem(newPlayerEntity, EntityLookupUtils.getEntityById(itemInWorld.getId()));
|
|
||||||
|
|
||||||
//equip the item to the slot defined in the template
|
|
||||||
ServerEquipState serverEquipState = ServerEquipState.getEquipState(newPlayerEntity);
|
|
||||||
serverEquipState.commandAttemptEquip(itemInInventory,serverEquipState.getEquipPoint(equipSlotId));
|
|
||||||
}
|
|
||||||
}
|
|
||||||
|
|
||||||
//
|
//
|
||||||
//attach entity to player object
|
//attach entity to player object
|
||||||
LoggerInterface.loggerEngine.INFO("Spawned entity for player. Entity id: " + newPlayerEntity.getId() + " Player id: " + playerObject.getId());
|
LoggerInterface.loggerEngine.INFO("Spawned entity for player. Entity id: " + newPlayerEntity.getId() + " Player id: " + playerObject.getId());
|
||||||
|
|||||||
Loading…
Reference in New Issue
Block a user