mirror of
				https://github.com/DarkflameUniverse/DarkflameServer.git
				synced 2025-11-04 14:42:02 +00:00 
			
		
		
		
	Use new logic for applying speed changes in ApplyBuff (#919)
This commit is contained in:
		@@ -170,17 +170,10 @@ void BuffComponent::ApplyBuffEffect(int32_t id) {
 | 
				
			|||||||
 | 
					
 | 
				
			||||||
			destroyable->SetMaxImagination(destroyable->GetMaxImagination() + maxImagination);
 | 
								destroyable->SetMaxImagination(destroyable->GetMaxImagination() + maxImagination);
 | 
				
			||||||
		} else if (parameter.name == "speed") {
 | 
							} else if (parameter.name == "speed") {
 | 
				
			||||||
			const auto speed = parameter.value;
 | 
					 | 
				
			||||||
 | 
					 | 
				
			||||||
			auto* controllablePhysicsComponent = this->GetParent()->GetComponent<ControllablePhysicsComponent>();
 | 
								auto* controllablePhysicsComponent = this->GetParent()->GetComponent<ControllablePhysicsComponent>();
 | 
				
			||||||
 | 
								if (!controllablePhysicsComponent) return;
 | 
				
			||||||
			if (controllablePhysicsComponent == nullptr) return;
 | 
								const auto speed = parameter.value;
 | 
				
			||||||
 | 
								controllablePhysicsComponent->AddSpeedboost(speed);
 | 
				
			||||||
			const auto current = controllablePhysicsComponent->GetSpeedMultiplier();
 | 
					 | 
				
			||||||
 | 
					 | 
				
			||||||
			controllablePhysicsComponent->SetSpeedMultiplier(current + ((speed - 500.0f) / 500.0f));
 | 
					 | 
				
			||||||
 | 
					 | 
				
			||||||
			EntityManager::Instance()->SerializeEntity(this->GetParent());
 | 
					 | 
				
			||||||
		}
 | 
							}
 | 
				
			||||||
	}
 | 
						}
 | 
				
			||||||
}
 | 
					}
 | 
				
			||||||
@@ -213,17 +206,10 @@ void BuffComponent::RemoveBuffEffect(int32_t id) {
 | 
				
			|||||||
 | 
					
 | 
				
			||||||
			destroyable->SetMaxImagination(destroyable->GetMaxImagination() - maxImagination);
 | 
								destroyable->SetMaxImagination(destroyable->GetMaxImagination() - maxImagination);
 | 
				
			||||||
		} else if (parameter.name == "speed") {
 | 
							} else if (parameter.name == "speed") {
 | 
				
			||||||
			const auto speed = parameter.value;
 | 
					 | 
				
			||||||
 | 
					 | 
				
			||||||
			auto* controllablePhysicsComponent = this->GetParent()->GetComponent<ControllablePhysicsComponent>();
 | 
								auto* controllablePhysicsComponent = this->GetParent()->GetComponent<ControllablePhysicsComponent>();
 | 
				
			||||||
 | 
								if (!controllablePhysicsComponent) return;
 | 
				
			||||||
			if (controllablePhysicsComponent == nullptr) return;
 | 
								const auto speed = parameter.value;
 | 
				
			||||||
 | 
								controllablePhysicsComponent->RemoveSpeedboost(speed);
 | 
				
			||||||
			const auto current = controllablePhysicsComponent->GetSpeedMultiplier();
 | 
					 | 
				
			||||||
 | 
					 | 
				
			||||||
			controllablePhysicsComponent->SetSpeedMultiplier(current - ((speed - 500.0f) / 500.0f));
 | 
					 | 
				
			||||||
 | 
					 | 
				
			||||||
			EntityManager::Instance()->SerializeEntity(this->GetParent());
 | 
					 | 
				
			||||||
		}
 | 
							}
 | 
				
			||||||
	}
 | 
						}
 | 
				
			||||||
}
 | 
					}
 | 
				
			||||||
 
 | 
				
			|||||||
		Reference in New Issue
	
	Block a user