split onHit / onNearMiss / onArmorEmpty (with common base)
This commit is contained in:
parent
e6afd27440
commit
ee2facb427
@ -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));
|
||||
|
@ -0,0 +1,14 @@
|
||||
<?php
|
||||
|
||||
namespace ManiaControl\Callbacks\Structures\ShootMania;
|
||||
|
||||
/**
|
||||
* Structure Class for the OnArmorEmpty Structure Callback
|
||||
*
|
||||
* @author ManiaControl Team <mail@maniacontrol.com>
|
||||
* @copyright 2014-2017 ManiaControl Team
|
||||
* @license http://www.gnu.org/licenses/ GNU General Public License, Version 3
|
||||
*/
|
||||
class OnArmorEmptyStructure extends OnHitNearMissArmorEmptyBaseStructure {
|
||||
|
||||
}
|
@ -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 <mail@maniacontrol.com>
|
||||
* @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;
|
||||
}
|
||||
|
||||
|
||||
}
|
33
core/Callbacks/Structures/ShootMania/OnHitStructure.php
Normal file
33
core/Callbacks/Structures/ShootMania/OnHitStructure.php
Normal file
@ -0,0 +1,33 @@
|
||||
<?php
|
||||
|
||||
namespace ManiaControl\Callbacks\Structures\ShootMania;
|
||||
|
||||
|
||||
use ManiaControl\ManiaControl;
|
||||
|
||||
/**
|
||||
* Structure Class for the OnHit Structure Callback
|
||||
*
|
||||
* @author ManiaControl Team <mail@maniacontrol.com>
|
||||
* @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;
|
||||
}
|
||||
}
|
32
core/Callbacks/Structures/ShootMania/OnNearMissStructure.php
Normal file
32
core/Callbacks/Structures/ShootMania/OnNearMissStructure.php
Normal file
@ -0,0 +1,32 @@
|
||||
<?php
|
||||
|
||||
namespace ManiaControl\Callbacks\Structures\ShootMania;
|
||||
|
||||
|
||||
use ManiaControl\ManiaControl;
|
||||
|
||||
/**
|
||||
* Structure Class for the OnNearMiss Structure Callback
|
||||
*
|
||||
* @author ManiaControl Team <mail@maniacontrol.com>
|
||||
* @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;
|
||||
}
|
||||
}
|
Loading…
Reference in New Issue
Block a user