use of io.xol.chunkstories.input.InputVirtual in project chunkstories by Hugobros3.
the class PacketInput method process.
public void process(PacketSender sender, DataInputStream in, PacketReceptionContext processor) throws IOException {
long code = in.readLong();
boolean pressed = in.readBoolean();
if (processor instanceof ServerPlayerPacketsProcessor) {
ServerPlayerPacketsProcessor sppc = (ServerPlayerPacketsProcessor) processor;
// Look for the controller handling this buisness
EntityControllable entity = (EntityControllable) sppc.getPlayer().getControlledEntity();
if (entity != null) {
// Get input of the client
input = sppc.getPlayer().getInputsManager().getInputFromHash(code);
if (input == null)
throw new NullPointerException("Unknown input hash : " + code);
// System.out.println(processor.getServerClient().getProfile() +
// " "+input + " "+pressed);
// Update it's state
((InputVirtual) input).setPressed(pressed);
// Fire appropriate event
if (pressed) {
PlayerInputPressedEvent event = new PlayerInputPressedEvent(sppc.getPlayer(), input);
entity.getWorld().getGameLogic().getPluginsManager().fireEvent(event);
if (!event.isCancelled())
entity.onControllerInput(input, entity.getControllerComponent().getController());
} else {
PlayerInputReleasedEvent event = new PlayerInputReleasedEvent(sppc.getPlayer(), input);
entity.getWorld().getGameLogic().getPluginsManager().fireEvent(event);
}
// TODO why is this disabled and still there ?
// If we pressed the input, apply game logic
// if(pressed)
// entity.handleInteraction(input,
// entity.getControllerComponent().getController());
}
}
}
use of io.xol.chunkstories.input.InputVirtual in project chunkstories by Hugobros3.
the class Lwjgl3ClientInputsManager method insertInput.
public void insertInput(String type, String name, String value, Collection<String> arguments) {
Input input;
if (type.equals("keyBind")) {
Lwjgl3KeyBind key = new Lwjgl3KeyBind(this, name, value);
input = key;
if (arguments.contains("hidden"))
key.editable = false;
if (arguments.contains("repeat"))
key.repeat = true;
// keyboardInputs.add(key);
} else if (type.equals("virtual")) {
input = new InputVirtual(name);
} else if (type.equals("keyBindCompound")) {
Lwjgl3KeyBindCompound keyCompound = new Lwjgl3KeyBindCompound(this, name, value);
input = keyCompound;
} else
return;
inputs.add(input);
inputsMap.put(input.getHash(), input);
}
use of io.xol.chunkstories.input.InputVirtual in project chunkstories by Hugobros3.
the class ServerInputsManager method insertInput.
public void insertInput(String type, String name, String value, Collection<String> arguments) {
Input input;
// 2deep4me
if (type.equals("keyBind") || type.equals("virtual")) {
input = new InputVirtual(name);
} else
return;
inputs.add(input);
inputsMap.put(input.getHash(), input);
}
use of io.xol.chunkstories.input.InputVirtual in project chunkstories by Hugobros3.
the class ServerInputsManager method reload.
public void reload() {
inputs.clear();
inputsMap.clear();
// Load all keys as virtual ones
InputsLoaderHelper.loadKeyBindsIntoManager(this, player.getContext().getContent().modsManager());
// Add virtual mouse buttons
InputVirtual mouseLeft = new InputVirtual("mouse.left", 0);
inputs.add(mouseLeft);
inputsMap.put(mouseLeft.getHash(), mouseLeft);
InputVirtual mouseRight = new InputVirtual("mouse.right", 1);
inputs.add(mouseRight);
inputsMap.put(mouseRight.getHash(), mouseRight);
InputVirtual mouseMiddle = new InputVirtual("mouse.middle", 2);
inputs.add(mouseMiddle);
inputsMap.put(mouseMiddle.getHash(), mouseMiddle);
}
Aggregations