mirror of
https://github.com/overte-org/overte.git
synced 2025-07-26 01:36:55 +02:00
adjust avatar-energy code to avoid editing local tree and then not telling the entity-server about it
This commit is contained in:
parent
784dc2b538
commit
af1640ac4e
1 changed files with 19 additions and 18 deletions
|
@ -133,11 +133,8 @@ QUuid EntityScriptingInterface::addEntity(const EntityItemProperties& properties
|
|||
float cost = calculateCost(density * volume, 0, newVelocity);
|
||||
cost *= costMultiplier;
|
||||
|
||||
if(cost > _currentAvatarEnergy) {
|
||||
if (cost > _currentAvatarEnergy) {
|
||||
return QUuid();
|
||||
} else {
|
||||
//debit the avatar energy and continue
|
||||
emit debitEnergySource(cost);
|
||||
}
|
||||
|
||||
EntityItemID id = EntityItemID(QUuid::createUuid());
|
||||
|
@ -173,6 +170,7 @@ QUuid EntityScriptingInterface::addEntity(const EntityItemProperties& properties
|
|||
|
||||
// queue the packet
|
||||
if (success) {
|
||||
emit debitEnergySource(cost);
|
||||
queueEntityMessage(PacketType::EntityAdd, id, propertiesWithSimID);
|
||||
}
|
||||
|
||||
|
@ -247,7 +245,7 @@ QUuid EntityScriptingInterface::editEntity(QUuid id, const EntityItemProperties&
|
|||
float cost = calculateCost(density * volume, oldVelocity, newVelocity);
|
||||
cost *= costMultiplier;
|
||||
|
||||
if(cost > _currentAvatarEnergy) {
|
||||
if (cost > _currentAvatarEnergy) {
|
||||
return QUuid();
|
||||
} else {
|
||||
//debit the avatar energy and continue
|
||||
|
@ -284,17 +282,19 @@ QUuid EntityScriptingInterface::editEntity(QUuid id, const EntityItemProperties&
|
|||
}
|
||||
}
|
||||
properties = convertLocationFromScriptSemantics(properties);
|
||||
updatedEntity = _entityTree->updateEntity(entityID, properties);
|
||||
|
||||
float cost = calculateCost(density * volume, oldVelocity, newVelocity);
|
||||
cost *= costMultiplier;
|
||||
|
||||
if(cost > _currentAvatarEnergy) {
|
||||
if (cost > _currentAvatarEnergy) {
|
||||
updatedEntity = false;
|
||||
} else {
|
||||
//debit the avatar energy and continue
|
||||
updatedEntity = _entityTree->updateEntity(entityID, properties);
|
||||
if (updatedEntity) {
|
||||
emit debitEnergySource(cost);
|
||||
}
|
||||
}
|
||||
});
|
||||
|
||||
if (!updatedEntity) {
|
||||
|
@ -378,7 +378,8 @@ void EntityScriptingInterface::deleteEntity(QUuid id) {
|
|||
float cost = calculateCost(density * volume, velocity, 0);
|
||||
cost *= costMultiplier;
|
||||
|
||||
if(cost > _currentAvatarEnergy) {
|
||||
if (cost > _currentAvatarEnergy) {
|
||||
shouldDelete = false;
|
||||
return;
|
||||
} else {
|
||||
//debit the avatar energy and continue
|
||||
|
|
Loading…
Reference in a new issue