mirror of
https://github.com/JulianGro/overte.git
synced 2025-04-25 16:55:07 +02:00
Exposed energy cost multiplier to scripting.
- field: costMultiplier
This commit is contained in:
parent
7dd5bca17f
commit
3cb2f9c4b7
3 changed files with 17 additions and 5 deletions
|
@ -56,7 +56,7 @@ function energyChanged(newValue) {
|
|||
function debitAvatarEnergy(value) {
|
||||
MyAvatar.energy = MyAvatar.energy - value;
|
||||
}
|
||||
|
||||
Entities.costMultiplier = 0.002;
|
||||
Entities.debitEnergySource.connect(debitAvatarEnergy);
|
||||
MyAvatar.energyChanged.connect(energyChanged);
|
||||
Script.update.connect(update);
|
||||
|
|
|
@ -126,7 +126,7 @@ QUuid EntityScriptingInterface::addEntity(const EntityItemProperties& properties
|
|||
auto density = propertiesWithSimID.getDensity();
|
||||
auto newVelocity = propertiesWithSimID.getVelocity().length();
|
||||
double cost = calculateCost(density*volume, 0, newVelocity);
|
||||
cost *= ENTITY_MANIPULATION_MULTIPLIER; //try this as a constant for now
|
||||
cost *= costMultiplier;
|
||||
|
||||
if(cost > _currentAvatarEnergy) {
|
||||
return QUuid();
|
||||
|
@ -231,7 +231,7 @@ QUuid EntityScriptingInterface::editEntity(QUuid id, const EntityItemProperties&
|
|||
auto density = properties.getDensity();
|
||||
auto newVelocity = properties.getVelocity().length();
|
||||
double cost = calculateCost(density*volume, 0, newVelocity);
|
||||
cost *= ENTITY_MANIPULATION_MULTIPLIER;
|
||||
cost *= costMultiplier;
|
||||
|
||||
if(cost > _currentAvatarEnergy) {
|
||||
return QUuid();
|
||||
|
@ -351,7 +351,7 @@ void EntityScriptingInterface::deleteEntity(QUuid id) {
|
|||
auto density = entity->getDensity();
|
||||
auto velocity = entity->getVelocity().length();
|
||||
double cost = calculateCost(density*volume, velocity, 0);
|
||||
cost *= ENTITY_MANIPULATION_MULTIPLIER;
|
||||
cost *= costMultiplier;
|
||||
|
||||
if(cost > _currentAvatarEnergy) {
|
||||
return;
|
||||
|
@ -1045,3 +1045,11 @@ void EntityScriptingInterface::setCurrentAvatarEnergy(float energy) {
|
|||
// qCDebug(entities) << "NEW AVATAR ENERGY IN ENTITY SCRIPTING INTERFACE: " << energy;
|
||||
_currentAvatarEnergy = energy;
|
||||
}
|
||||
|
||||
float EntityScriptingInterface::getCostMultiplier() {
|
||||
return costMultiplier;
|
||||
}
|
||||
|
||||
void EntityScriptingInterface::setCostMultiplier(float value) {
|
||||
costMultiplier = value;
|
||||
}
|
||||
|
|
|
@ -61,6 +61,7 @@ class EntityScriptingInterface : public OctreeScriptingInterface, public Depende
|
|||
Q_OBJECT
|
||||
|
||||
Q_PROPERTY(float currentAvatarEnergy READ getCurrentAvatarEnergy WRITE setCurrentAvatarEnergy)
|
||||
Q_PROPERTY(float costMultiplier READ getCostMultiplier WRITE setCostMultiplier)
|
||||
public:
|
||||
EntityScriptingInterface();
|
||||
|
||||
|
@ -214,7 +215,10 @@ private:
|
|||
float _currentAvatarEnergy = { FLT_MAX };
|
||||
float getCurrentAvatarEnergy() { return _currentAvatarEnergy; }
|
||||
void setCurrentAvatarEnergy(float energy);
|
||||
float ENTITY_MANIPULATION_MULTIPLIER = { 0.01f };
|
||||
|
||||
float costMultiplier = { 0.01f };
|
||||
float getCostMultiplier();
|
||||
void setCostMultiplier(float value);
|
||||
};
|
||||
|
||||
#endif // hifi_EntityScriptingInterface_h
|
||||
|
|
Loading…
Reference in a new issue