mirror of
https://github.com/overte-org/overte.git
synced 2025-04-21 06:24:43 +02:00
code review
This commit is contained in:
parent
2086a25f93
commit
eb912892dc
6 changed files with 14 additions and 17 deletions
|
@ -1,5 +1,5 @@
|
|||
//
|
||||
// EntityItem.h
|
||||
// EntityActionInterface.cpp
|
||||
// libraries/entities/src
|
||||
//
|
||||
// Created by Seth Alves on 2015-6-4
|
||||
|
|
|
@ -1,5 +1,5 @@
|
|||
//
|
||||
// EntityItem.h
|
||||
// EntityActionInterface.h
|
||||
// libraries/entities/src
|
||||
//
|
||||
// Created by Seth Alves on 2015-6-2
|
||||
|
@ -24,7 +24,7 @@ enum EntityActionType {
|
|||
|
||||
|
||||
class EntityActionInterface {
|
||||
public:
|
||||
public:
|
||||
EntityActionInterface() { }
|
||||
virtual ~EntityActionInterface() { }
|
||||
virtual const QUuid& getID() const = 0;
|
||||
|
@ -38,7 +38,7 @@ class EntityActionInterface {
|
|||
static EntityActionType actionTypeFromString(QString actionTypeString);
|
||||
static QString actionTypeToString(EntityActionType actionType);
|
||||
|
||||
protected:
|
||||
protected:
|
||||
|
||||
static glm::vec3 extractVec3Argument(QString objectName, QVariantMap arguments, QString argumentName, bool& ok);
|
||||
static float extractFloatArgument(QString objectName, QVariantMap arguments, QString argumentName, bool& ok);
|
||||
|
|
|
@ -1351,7 +1351,7 @@ bool EntityItem::addAction(EntitySimulation* simulation, EntityActionPointer act
|
|||
return false;
|
||||
}
|
||||
|
||||
bool EntityItem::updateAction(EntitySimulation* simulation, const QUuid actionID, QVariantMap arguments) {
|
||||
bool EntityItem::updateAction(EntitySimulation* simulation, const QUuid& actionID, QVariantMap& arguments) {
|
||||
if (!_objectActions.contains(actionID)) {
|
||||
return false;
|
||||
}
|
||||
|
@ -1359,7 +1359,7 @@ bool EntityItem::updateAction(EntitySimulation* simulation, const QUuid actionID
|
|||
return action->updateArguments(arguments);
|
||||
}
|
||||
|
||||
bool EntityItem::removeAction(EntitySimulation* simulation, const QUuid actionID) {
|
||||
bool EntityItem::removeAction(EntitySimulation* simulation, const QUuid& actionID) {
|
||||
if (_objectActions.contains(actionID)) {
|
||||
EntityActionPointer action = _objectActions[actionID];
|
||||
_objectActions.remove(actionID);
|
||||
|
|
|
@ -178,9 +178,7 @@ public:
|
|||
EntityTypes::EntityType getType() const { return _type; }
|
||||
const glm::vec3& getPosition() const { return _position; } /// get position in meters
|
||||
|
||||
void setPosition(const glm::vec3& value) {
|
||||
_position = value;
|
||||
}
|
||||
void setPosition(const glm::vec3& value) { _position = value; }
|
||||
|
||||
glm::vec3 getCenter() const;
|
||||
|
||||
|
@ -355,8 +353,8 @@ public:
|
|||
void getAllTerseUpdateProperties(EntityItemProperties& properties) const;
|
||||
|
||||
bool addAction(EntitySimulation* simulation, EntityActionPointer action);
|
||||
bool updateAction(EntitySimulation* simulation, const QUuid actionID, QVariantMap arguments);
|
||||
bool removeAction(EntitySimulation* simulation, const QUuid actionID);
|
||||
bool updateAction(EntitySimulation* simulation, const QUuid& actionID, QVariantMap& arguments);
|
||||
bool removeAction(EntitySimulation* simulation, const QUuid& actionID);
|
||||
void clearActions(EntitySimulation* simulation);
|
||||
|
||||
protected:
|
||||
|
|
|
@ -451,7 +451,7 @@ bool EntityScriptingInterface::setAllVoxels(QUuid entityID, int value) {
|
|||
}
|
||||
|
||||
|
||||
bool EntityScriptingInterface::actionWorker(QUuid entityID, std::function<bool(EntitySimulation*, EntityItemPointer)> actor) {
|
||||
bool EntityScriptingInterface::actionWorker(QUuid& entityID, std::function<bool(EntitySimulation*, EntityItemPointer)> actor) {
|
||||
if (!_entityTree) {
|
||||
return false;
|
||||
}
|
||||
|
@ -478,10 +478,9 @@ bool EntityScriptingInterface::actionWorker(QUuid entityID, std::function<bool(E
|
|||
}
|
||||
|
||||
|
||||
|
||||
QUuid EntityScriptingInterface::addAction(QString actionTypeString, QUuid entityID, QVariantMap arguments) {
|
||||
QUuid actionID = QUuid::createUuid();
|
||||
bool success = actionWorker(entityID, [actionID, actionTypeString, entityID, arguments](EntitySimulation* simulation,
|
||||
bool success = actionWorker(entityID, [&](EntitySimulation* simulation,
|
||||
EntityItemPointer entity) {
|
||||
EntityActionType actionType = EntityActionInterface::actionTypeFromString(actionTypeString);
|
||||
if (actionType == ACTION_TYPE_NONE) {
|
||||
|
@ -500,14 +499,14 @@ QUuid EntityScriptingInterface::addAction(QString actionTypeString, QUuid entity
|
|||
|
||||
|
||||
bool EntityScriptingInterface::updateAction(QUuid entityID, QUuid actionID, QVariantMap arguments) {
|
||||
return actionWorker(entityID, [entityID, actionID,arguments](EntitySimulation* simulation, EntityItemPointer entity) {
|
||||
return actionWorker(entityID, [&](EntitySimulation* simulation, EntityItemPointer entity) {
|
||||
return entity->updateAction(simulation, actionID, arguments);
|
||||
});
|
||||
}
|
||||
|
||||
|
||||
bool EntityScriptingInterface::deleteAction(QUuid entityID, QUuid actionID) {
|
||||
return actionWorker(entityID, [entityID, actionID](EntitySimulation* simulation, EntityItemPointer entity) {
|
||||
return actionWorker(entityID, [&](EntitySimulation* simulation, EntityItemPointer entity) {
|
||||
return entity->removeAction(simulation, actionID);
|
||||
});
|
||||
}
|
||||
|
|
|
@ -155,7 +155,7 @@ signals:
|
|||
void clearingEntities();
|
||||
|
||||
private:
|
||||
bool actionWorker(QUuid entityID, std::function<bool(EntitySimulation*, EntityItemPointer)> actor);
|
||||
bool actionWorker(QUuid& entityID, std::function<bool(EntitySimulation*, EntityItemPointer)> actor);
|
||||
bool setVoxels(QUuid entityID, std::function<void(PolyVoxEntityItem&)> actor);
|
||||
void queueEntityMessage(PacketType packetType, EntityItemID entityID, const EntityItemProperties& properties);
|
||||
|
||||
|
|
Loading…
Reference in a new issue