add entity events: on_aim_on, on_aim_off
This commit is contained in:
@@ -357,6 +357,7 @@ voxel* PlayerController::updateSelection(float maxDistance) {
|
||||
if (vox) {
|
||||
maxDistance = glm::distance(camera->position, end);
|
||||
}
|
||||
auto prevEntity = selection.entity;
|
||||
selection.entity = ENTITY_NONE;
|
||||
selection.actualPosition = iend;
|
||||
if (auto result = level->entities->rayCast(
|
||||
@@ -367,6 +368,18 @@ voxel* PlayerController::updateSelection(float maxDistance) {
|
||||
selection.actualPosition = selection.position;
|
||||
selection.normal = result->normal;
|
||||
}
|
||||
if (selection.entity != prevEntity) {
|
||||
if (prevEntity != ENTITY_NONE) {
|
||||
if (auto pentity = level->entities->get(prevEntity)) {
|
||||
scripting::on_aim_off(*pentity, player.get());
|
||||
}
|
||||
}
|
||||
if (selection.entity != ENTITY_NONE) {
|
||||
if (auto pentity = level->entities->get(selection.entity)) {
|
||||
scripting::on_aim_on(*pentity, player.get());
|
||||
}
|
||||
}
|
||||
}
|
||||
if (vox == nullptr || selection.entity) {
|
||||
selection.vox = {BLOCK_VOID, {}};
|
||||
return nullptr;
|
||||
|
||||
Reference in New Issue
Block a user