diff --git a/core/Callbacks/ShootManiaCallbacks.php b/core/Callbacks/ShootManiaCallbacks.php index 73db33ed..93ccbba7 100644 --- a/core/Callbacks/ShootManiaCallbacks.php +++ b/core/Callbacks/ShootManiaCallbacks.php @@ -6,10 +6,12 @@ use ManiaControl\Callbacks\Models\RecordCallback; use ManiaControl\Callbacks\Structures\EliteBeginTurnStructure; use ManiaControl\Callbacks\Structures\ShootMania\OnActionCustomEventStructure; use ManiaControl\Callbacks\Structures\ShootMania\OnActionEvent; +use ManiaControl\Callbacks\Structures\ShootMania\OnArmorEmptyStructure; use ManiaControl\Callbacks\Structures\ShootMania\OnCaptureStructure; use ManiaControl\Callbacks\Structures\ShootMania\OnCommandStructure; use ManiaControl\Callbacks\Structures\ShootMania\OnDefaultEventStructure; -use ManiaControl\Callbacks\Structures\ShootMania\OnHitNearMissArmorEmptyStructure; +use ManiaControl\Callbacks\Structures\ShootMania\OnHitStructure; +use ManiaControl\Callbacks\Structures\ShootMania\OnNearMissStructure; use ManiaControl\Callbacks\Structures\ShootMania\OnPlayerObjectStructure; use ManiaControl\Callbacks\Structures\ShootMania\OnPlayerRequestActionChange; use ManiaControl\Callbacks\Structures\ShootMania\OnPlayerRequestRespawnStructure; @@ -77,13 +79,13 @@ class ShootManiaCallbacks implements CallbackListener { $this->maniaControl->getCallbackManager()->triggerCallback(Callbacks::SM_ONSHOOT, new OnShootStructure($this->maniaControl, $data)); break; case Callbacks::SM_ONHIT: - $this->maniaControl->getCallbackManager()->triggerCallback(Callbacks::SM_ONHIT, new OnHitNearMissArmorEmptyStructure($this->maniaControl, $data)); + $this->maniaControl->getCallbackManager()->triggerCallback(Callbacks::SM_ONHIT, new OnHitStructure($this->maniaControl, $data)); break; case Callbacks::SM_ONNEARMISS: - $this->maniaControl->getCallbackManager()->triggerCallback(Callbacks::SM_ONNEARMISS, new OnHitNearMissArmorEmptyStructure($this->maniaControl, $data)); + $this->maniaControl->getCallbackManager()->triggerCallback(Callbacks::SM_ONNEARMISS, new OnNearMissStructure($this->maniaControl, $data)); break; case Callbacks::SM_ONARMOREMPTY: - $this->maniaControl->getCallbackManager()->triggerCallback(Callbacks::SM_ONARMOREMPTY, new OnHitNearMissArmorEmptyStructure($this->maniaControl, $data)); + $this->maniaControl->getCallbackManager()->triggerCallback(Callbacks::SM_ONARMOREMPTY, new OnArmorEmptyStructure($this->maniaControl, $data)); break; case Callbacks::SM_ONCAPTURE: $this->maniaControl->getCallbackManager()->triggerCallback(Callbacks::SM_ONCAPTURE, new OnCaptureStructure($this->maniaControl, $data)); diff --git a/core/Callbacks/Structures/ShootMania/OnArmorEmptyStructure.php b/core/Callbacks/Structures/ShootMania/OnArmorEmptyStructure.php new file mode 100644 index 00000000..e6dd43e1 --- /dev/null +++ b/core/Callbacks/Structures/ShootMania/OnArmorEmptyStructure.php @@ -0,0 +1,14 @@ + + * @copyright 2014-2017 ManiaControl Team + * @license http://www.gnu.org/licenses/ GNU General Public License, Version 3 + */ +class OnArmorEmptyStructure extends OnHitNearMissArmorEmptyBaseStructure { + +} \ No newline at end of file diff --git a/core/Callbacks/Structures/ShootMania/OnHitNearMissArmorEmptyStructure.php b/core/Callbacks/Structures/ShootMania/OnHitNearMissArmorEmptyBaseStructure.php similarity index 77% rename from core/Callbacks/Structures/ShootMania/OnHitNearMissArmorEmptyStructure.php rename to core/Callbacks/Structures/ShootMania/OnHitNearMissArmorEmptyBaseStructure.php index f0b56e2c..d100f84e 100644 --- a/core/Callbacks/Structures/ShootMania/OnHitNearMissArmorEmptyStructure.php +++ b/core/Callbacks/Structures/ShootMania/OnHitNearMissArmorEmptyBaseStructure.php @@ -10,17 +10,15 @@ use ManiaControl\Players\Player; /** - * Structure Class for the OnHit Structure Callback + * Structure Base Class for the OnHit/OnNearMiss/OnArmorEmpty Structure Callback * * @author ManiaControl Team * @copyright 2014-2017 ManiaControl Team * @license http://www.gnu.org/licenses/ GNU General Public License, Version 3 */ -class OnHitNearMissArmorEmptyStructure extends BaseStructure { +class OnHitNearMissArmorEmptyBaseStructure extends BaseStructure { private $time; private $weapon; - private $damage; - private $distance = 0; //Note no distance on the OnHit and ArmorEmpty yet private $shooterPosition; private $victimPosition; @@ -54,14 +52,6 @@ class OnHitNearMissArmorEmptyStructure extends BaseStructure { $this->victimPosition->setY($jsonObj->victimposition->y); $this->victimPosition->setZ($jsonObj->victimposition->z); - if (property_exists($this->getPlainJsonObject(), 'distance')) { - $this->distance = $this->getPlainJsonObject()->distance; - } - - if (property_exists($this->getPlainJsonObject(), 'damage')) { - $this->damage = $this->getPlainJsonObject()->damage; - } - $this->shooter = $this->maniaControl->getPlayerManager()->getPlayer($this->getPlainJsonObject()->shooter); $this->victim = $this->maniaControl->getPlayerManager()->getPlayer($this->getPlainJsonObject()->victim); } @@ -85,16 +75,6 @@ class OnHitNearMissArmorEmptyStructure extends BaseStructure { return $this->weapon; } - /** - * < Amount of Damage done by the hit (only on onHit) - * TODO base class and extend properties) - * - * @return int - */ - public function getDamage() { - return $this->damage; - } - /** * < Position of the Shooter at the time * @@ -131,11 +111,6 @@ class OnHitNearMissArmorEmptyStructure extends BaseStructure { return $this->victim; } - /** - * @return mixed - */ - public function getDistance() { - return $this->distance; - } + } \ No newline at end of file diff --git a/core/Callbacks/Structures/ShootMania/OnHitStructure.php b/core/Callbacks/Structures/ShootMania/OnHitStructure.php new file mode 100644 index 00000000..94395dea --- /dev/null +++ b/core/Callbacks/Structures/ShootMania/OnHitStructure.php @@ -0,0 +1,33 @@ + + * @copyright 2014-2017 ManiaControl Team + * @license http://www.gnu.org/licenses/ GNU General Public License, Version 3 + */ +class OnHitStructure extends OnHitNearMissArmorEmptyBaseStructure { + private $damage; + + + public function __construct(ManiaControl $maniaControl, array $data) { + parent::__construct($maniaControl, $data); + + $this->damage = $this->getPlainJsonObject()->damage; + } + + /** + * < Amount of Damage done by the hit (only on onHit) + * + * @return int + */ + public function getDamage() { + return $this->damage; + } +} \ No newline at end of file diff --git a/core/Callbacks/Structures/ShootMania/OnNearMissStructure.php b/core/Callbacks/Structures/ShootMania/OnNearMissStructure.php new file mode 100644 index 00000000..4f74bd28 --- /dev/null +++ b/core/Callbacks/Structures/ShootMania/OnNearMissStructure.php @@ -0,0 +1,32 @@ + + * @copyright 2014-2017 ManiaControl Team + * @license http://www.gnu.org/licenses/ GNU General Public License, Version 3 + */ +class OnNearMissStructure extends OnHitNearMissArmorEmptyBaseStructure { + private $distance; + + public function __construct(ManiaControl $maniaControl, array $data) { + parent::__construct($maniaControl, $data); + + $this->distance = $this->getPlainJsonObject()->distance; + } + + /** + * Returns the distance + * + * @return float + */ + public function getDistance() { + return $this->distance; + } +} \ No newline at end of file