script work, player weapon on level edit
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
719999b6aa
commit
4c65b59b1b
@ -1,4 +1,3 @@
|
|||||||
import { ClientInventory, onEquipItem, onMoveItemContainer, onUnequipItem } from "/Scripts/client/entity/inventory";
|
|
||||||
import { Namespace } from "/Scripts/types/namespace";
|
import { Namespace } from "/Scripts/types/namespace";
|
||||||
|
|
||||||
|
|
||||||
@ -6,17 +5,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/engine/entity/entity"
|
import { Entity } from "/Scripts/types/host/entity/entity"
|
||||||
|
|
||||||
|
|
||||||
/**
|
/**
|
||||||
|
|||||||
@ -631,6 +631,10 @@ 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,6 +11,7 @@ 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;
|
||||||
@ -166,6 +167,7 @@ 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());
|
||||||
|
|||||||
@ -5,13 +5,19 @@ 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
|
||||||
@ -36,6 +42,24 @@ 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