public void reset() { list = new ArrayList<>(); for (int i = 0; i < 2; i++) { list.add(new DirectionAndOriginPosRecorder()); } }
@ReceiveEvent(components = LocationComponent.class, netFilter = RegisterMode.AUTHORITY) public void onAttackRequest(AttackRequest event, EntityRef character, CharacterComponent characterComponent) { // if an item is used, make sure this entity is allowed to attack with it if (event.getItem().exists()) { if (!character.equals(event.getItem().getOwner())) { return; } } OnItemUseEvent onItemUseEvent = new OnItemUseEvent(); character.send(onItemUseEvent); if (!onItemUseEvent.isConsumed()) { EntityRef gazeEntity = GazeAuthoritySystem.getGazeEntityForCharacter(character); LocationComponent gazeLocation = gazeEntity.getComponent(LocationComponent.class); Vector3f direction = gazeLocation.getWorldDirection(); Vector3f originPos = gazeLocation.getWorldPosition(); if (recordAndReplayCurrentStatus.getStatus() == RecordAndReplayStatus.RECORDING) { directionAndOriginPosRecorderList.getAttackEventDirectionAndOriginPosRecorder().add(direction, originPos); } else if (recordAndReplayCurrentStatus.getStatus() == RecordAndReplayStatus.REPLAYING) { Vector3f[] data = directionAndOriginPosRecorderList.getAttackEventDirectionAndOriginPosRecorder().poll(); direction = data[0]; originPos = data[1]; } HitResult result = physics.rayTrace(originPos, direction, characterComponent.interactionRange, Sets.newHashSet(character), DEFAULTPHYSICSFILTER); if (result.isHit()) { result.getEntity().send(new AttackEvent(character, event.getItem())); } } }
Vector3f originPos = getViewPosition(); if (recordAndReplayCurrentStatus.getStatus() == RecordAndReplayStatus.RECORDING) { this.directionAndOriginPosRecorderList.getTargetOrOwnedEntityDirectionAndOriginPosRecorder().add(direction, originPos); } else if (recordAndReplayCurrentStatus.getStatus() == RecordAndReplayStatus.REPLAYING) { Vector3f[] data = this.directionAndOriginPosRecorderList.getTargetOrOwnedEntityDirectionAndOriginPosRecorder().poll(); direction = data[0]; originPos = data[1];
public DirectionAndOriginPosRecorderList() { list = new ArrayList<>(); for (int i = 0; i < 2; i++) { list.add(new DirectionAndOriginPosRecorder()); } }