Add all files
This commit is contained in:
6
[粒子生成器]DParticle/plugin.yml
Normal file
6
[粒子生成器]DParticle/plugin.yml
Normal file
@@ -0,0 +1,6 @@
|
||||
name: DParticle
|
||||
main: dxp\dpt\DParticle
|
||||
version: 1.0.8
|
||||
api: [1.12.0]
|
||||
load: POSTWORLD
|
||||
author: aabbcc872[dxp]
|
||||
744
[粒子生成器]DParticle/src/dxp/dpt/DParticle.php
Normal file
744
[粒子生成器]DParticle/src/dxp/dpt/DParticle.php
Normal file
@@ -0,0 +1,744 @@
|
||||
<?php
|
||||
namespace dxp\dpt;
|
||||
|
||||
use pocketmine\event\Listener;
|
||||
use pocketmine\level\particle\AngryVillagerParticle;
|
||||
use pocketmine\level\particle\BubbleParticle;
|
||||
use pocketmine\level\particle\BlockForceFieldParticle;
|
||||
use pocketmine\level\particle\CriticalParticle;
|
||||
use pocketmine\level\particle\DustParticle;
|
||||
use pocketmine\level\particle\EnchantmentTableParticle;
|
||||
use pocketmine\level\particle\EnchantParticle;
|
||||
use pocketmine\level\particle\ExplodeParticle;
|
||||
use pocketmine\level\particle\FlameParticle;
|
||||
use pocketmine\level\particle\HappyVillagerParticle;
|
||||
use pocketmine\level\particle\HeartParticle;
|
||||
use pocketmine\level\particle\HugeExplodeParticle;
|
||||
use pocketmine\level\particle\HugeExplodeSeedParticle;
|
||||
use pocketmine\level\particle\InkParticle;
|
||||
use pocketmine\level\particle\InstantEnchantParticle;
|
||||
use pocketmine\level\particle\ItemBreakParticle;
|
||||
use pocketmine\level\particle\LavaDripParticle;
|
||||
use pocketmine\level\particle\LavaParticle;
|
||||
use pocketmine\level\particle\Particle;
|
||||
use pocketmine\level\particle\PortalParticle;
|
||||
use pocketmine\level\particle\RainSplashParticle;
|
||||
use pocketmine\level\particle\RedstoneParticle;
|
||||
use pocketmine\level\particle\SmokeParticle;
|
||||
use pocketmine\level\particle\SplashParticle;
|
||||
use pocketmine\level\particle\SporeParticle;
|
||||
use pocketmine\level\particle\TerrainParticle;
|
||||
use pocketmine\level\particle\WaterDripParticle;
|
||||
use pocketmine\level\particle\WaterParticle;
|
||||
use pocketmine\level\Level;
|
||||
use pocketmine\level\Position;
|
||||
use pocketmine\math\Vector3;
|
||||
use pocketmine\plugin\PluginBase;
|
||||
use pocketmine\utils\Config;
|
||||
use pocketmine\utils\TextFormat;
|
||||
use pocketmine\scheduler\CallbackTask;
|
||||
use pocketmine\scheduler\PluginTask;
|
||||
use pocketmine\Server;
|
||||
|
||||
use dxp\dpt\shape\Square;
|
||||
use dxp\dpt\shape\Circle;
|
||||
use dxp\dpt\shape\Circle1;
|
||||
use dxp\dpt\shape\Circle2;
|
||||
use dxp\dpt\shape\Round as Rd;
|
||||
use dxp\dpt\shape\Round1;
|
||||
use dxp\dpt\shape\Round2;
|
||||
use dxp\dpt\shape\Ball;
|
||||
use dxp\dpt\shape\Ball1;
|
||||
use dxp\dpt\shape\Ball2;
|
||||
use dxp\dpt\shape\Star;
|
||||
use dxp\dpt\shape\Star1;
|
||||
use dxp\dpt\shape\Random;
|
||||
use dxp\dpt\shape\Ring;
|
||||
use dxp\dpt\shape\Triangle;
|
||||
use dxp\dpt\shape\Pentagon;
|
||||
use dxp\dpt\shape\Hexagon;
|
||||
use dxp\dpt\shape\Wing;
|
||||
|
||||
class DParticle extends PluginBase implements Listener{
|
||||
private static $obj = null;
|
||||
public static function getInstance(){
|
||||
return self::$obj;
|
||||
}
|
||||
public function onLoad(){
|
||||
$this->getServer()->getLogger()->info('§e粒子生成器正在加载...');
|
||||
$this->reLoad();
|
||||
}
|
||||
|
||||
public function onEnable(){
|
||||
$this->getServer()->getPluginManager()->registerEvents($this,$this);
|
||||
|
||||
$this->getServer()->getScheduler()->scheduleRepeatingTask(new CallbackTask([$this,'taskManager']),1);
|
||||
|
||||
$this->getServer()->getLogger()->info('§a粒子生成器加载完成!');
|
||||
}
|
||||
|
||||
public function onDisable(){
|
||||
$this->p->save();
|
||||
$this->getServer()->getLogger()->info('§a粒子生成器卸载完成!');
|
||||
}
|
||||
|
||||
public function reLoad(){
|
||||
if(!self::$obj instanceof DParticle){
|
||||
self::$obj = $this;
|
||||
}
|
||||
|
||||
@mkdir($this->getDataFolder(),0777,true);
|
||||
$this->p=new Config($this->getDataFolder().'pos.json',Config::JSON,array());
|
||||
|
||||
$this->shapes=array(
|
||||
//圆
|
||||
'Circle'=>new Circle($this),
|
||||
'Circle1'=>new Circle1($this),
|
||||
//正多边形
|
||||
'Triangle'=>new Triangle($this),
|
||||
'Square'=>new Square($this),
|
||||
'Pentagon'=>new Pentagon($this),
|
||||
'Hexagon'=>new Hexagon($this),
|
||||
//球体
|
||||
'Ball'=>new Ball($this),
|
||||
'Ball1'=>new Ball1($this),
|
||||
//五角星
|
||||
'Star'=>new Star($this),
|
||||
//环绕
|
||||
'Round'=>new Rd($this),
|
||||
'Round1'=>new Round1($this),
|
||||
'Round2'=>new Round2($this),
|
||||
//特殊
|
||||
'Random'=>new Random($this),
|
||||
'Wing'=>new Wing($this)
|
||||
);
|
||||
|
||||
$this->color=array('r'=>255,'g'=>0,'b'=>0,'s'=>1);
|
||||
$this->cf=1;
|
||||
$this->h=array('h'=>0,'s'=>1,'h1'=>0,'s1'=>0,'maxh'=>4,'pos'=>array(),'pos'=>array(),'hh'=>0,'hh1'=>0);
|
||||
$this->r=0;
|
||||
$this->Timber=0;
|
||||
$this->d=0;
|
||||
$this->ro=0;
|
||||
}
|
||||
|
||||
public function addPos($info){
|
||||
if(count($info)!==10){
|
||||
return false;
|
||||
}
|
||||
if(!isset($info['ID'])){
|
||||
return false;
|
||||
}
|
||||
if($this->p->exists($info['ID'])){
|
||||
return false;
|
||||
}
|
||||
$id=$info['ID'];
|
||||
$this->p->set($id,$info);
|
||||
$this->p->save();
|
||||
unset($id,$info);
|
||||
return true;
|
||||
}
|
||||
|
||||
public function setPos($id,$type,$i){
|
||||
if(!$this->p->exists($id)){
|
||||
return false;
|
||||
}
|
||||
$info=$this->p->get($id);
|
||||
if(!isset($info[$type])){
|
||||
return false;
|
||||
}
|
||||
$info[$type]=$i;
|
||||
$this->p->set($id,$info);
|
||||
$this->p->save();
|
||||
unset($id,$type,$i);
|
||||
return true;
|
||||
}
|
||||
|
||||
public function delPos($id){
|
||||
if(!$this->p->exists($id)){
|
||||
return false;
|
||||
}
|
||||
$this->p->remove($id);
|
||||
$this->p->save();
|
||||
unset($id);
|
||||
return true;
|
||||
}
|
||||
|
||||
public function playParticle($info){
|
||||
if(!isset($info['Deg'])){
|
||||
$info['Deg']=0;
|
||||
}
|
||||
$name=$info['R'].$info['α'].$info['β'].$info['γ'].$info['Deg'];
|
||||
$obj=$this->shapes[$info['Shape']];
|
||||
if($obj==null){
|
||||
return false;
|
||||
}
|
||||
$data=$obj->run($info);
|
||||
if($data==null || $data[0]==null){
|
||||
return false;
|
||||
}
|
||||
$level=$this->getServer()->getLevelByName($info['Level']);
|
||||
if(!isset($level) || $level==null){
|
||||
return false;
|
||||
}
|
||||
$n=0;
|
||||
foreach($data[0] as $p){
|
||||
if(is_array($data[1]) && isset($data[1][$n])){
|
||||
$particle=$data[1][$n];
|
||||
}else{
|
||||
$particle=$info['Particle'];
|
||||
}
|
||||
$pt=$this->getParticle($particle,new Vector3($info['X']+$p[0],$info['Y']+$p[1],$info['Z']+$p[2]));
|
||||
if(!isset($pt)){
|
||||
return false;
|
||||
}
|
||||
$level->addParticle($pt);
|
||||
$n++;
|
||||
}
|
||||
unset($info,$n,$p,$data,$level,$pt,$particle);
|
||||
return true;
|
||||
}
|
||||
|
||||
public function sendParticle(){
|
||||
foreach($this->p->getAll() as $info){
|
||||
switch($info['Shape']){
|
||||
case 'Square':
|
||||
case 'Circle':
|
||||
case 'Circle1':
|
||||
case 'Ball':
|
||||
case 'Ball2':
|
||||
case 'Ring':
|
||||
case 'Star':
|
||||
if($this->Timber==10){
|
||||
$this->playParticle($info);
|
||||
}
|
||||
break;
|
||||
default:
|
||||
$this->playParticle($info);
|
||||
break;
|
||||
}
|
||||
}
|
||||
unset($info);
|
||||
}
|
||||
|
||||
public function getParticleList(){
|
||||
return array('Lava','Lavadrip','Waterdrip','Red','Orange','Yellow','Green','Blue','Green-blue','Purple','White','Pink','Colorful','Shadow','Redstone','Flame','Smoke','Enchant','HappyVillager','Portal','WhiteSmoke','AngryVillager');
|
||||
}
|
||||
|
||||
public function getShapeList(){
|
||||
return array('Circle','Circle1','Round','Round1','Round2','Round3','Triangle','Square','Hexagon','Pentagon','Ball','Ball1','Ball2','Star','Star1','Wing','Ring','Random');
|
||||
}
|
||||
|
||||
/*public function curve($info){
|
||||
//反比例函数双曲线算法
|
||||
$r=$info['R'];
|
||||
$level=$this->getServer()->getLevelByName($info['Level']);
|
||||
$pos=array();
|
||||
if($r==0){
|
||||
return;
|
||||
}
|
||||
for($i=0.1;$i<=$r;$i+=0.1){
|
||||
$x=$i;
|
||||
$z=$r/$x;
|
||||
$pos[]=new Vector3($info['X']+$x,$info['Y'],$info['Z']+$z);
|
||||
$pos[]=new Vector3($info['X']+$x,$info['Y'],$info['Z']-$z);
|
||||
$pos[]=new Vector3($info['X']-$x,$info['Y'],$info['Z']+$z);
|
||||
$pos[]=new Vector3($info['X']-$x,$info['Y'],$info['Z']-$z);
|
||||
}
|
||||
return $pos;
|
||||
unset($info,$r,$i,$level,$x,$z,$v3a,$v3b,$v3c,$v3d);
|
||||
}*/
|
||||
|
||||
|
||||
//直线算法
|
||||
public function line($info){
|
||||
$pos=array();
|
||||
$sd=pow($info['X']-$info['X1'],2)+pow($info['Y']-$info['Y1'],2)+pow($info['Z']-$info['Z1'],2);
|
||||
$dis=(int)sqrt($sd);
|
||||
for($t=0;$t<=1;$t+=(1/($dis))){
|
||||
$pos[]=array($info['X']+($info['X1']-$info['X'])*$t,$info['Y']+($info['Y1']-$info['Y'])*$t,$z=$info['Z']+($info['Z1']-$info['Z'])*$t);
|
||||
}
|
||||
return $pos;
|
||||
}
|
||||
|
||||
public function arc($x,$y,$r,$b,$d1,$d2){
|
||||
//弧算法
|
||||
$pos=array();
|
||||
if($d2<$d1){
|
||||
$d2+=360;
|
||||
}
|
||||
for($ii=$d1;$ii<=$d2;$ii+=$b){
|
||||
if($ii>360){
|
||||
$i=($ii-360)%180;
|
||||
}else{
|
||||
$i=$ii%180;
|
||||
}
|
||||
$xx=$r*cos(deg2rad($i));
|
||||
$yy=$r*sin(deg2rad($i));
|
||||
if($ii<=180){
|
||||
$pos[]=array($x+$xx,$y+$yy);
|
||||
}elseif($ii<=360 && $ii>180){
|
||||
$pos[]=array($x-$xx,$y-$yy);
|
||||
}
|
||||
}
|
||||
return $pos;
|
||||
unset($x,$y,$r,$b,$d1,$d2,$ii,$i,$xx,$yy);
|
||||
}
|
||||
|
||||
public function arc_port($x,$y,$r,$d){
|
||||
//弧取点算法
|
||||
$xx=$r*cos(deg2rad($d%180));
|
||||
$yy=$r*sin(deg2rad($d%180));
|
||||
if($d<=180){
|
||||
$pos=array($x+$xx,$y+$yy);
|
||||
}elseif($d<=360 && $d>180){
|
||||
$pos=array($x-$xx,$y-$yy);
|
||||
}
|
||||
return $pos;
|
||||
unset($x,$y,$r,$d,$xx,$yy);
|
||||
}
|
||||
|
||||
public function curve_circle($info){
|
||||
//曲线圆算法
|
||||
$r=$info['R'];
|
||||
$pos=array();
|
||||
$r1=3/8*$r;
|
||||
$l=2*$r*sin(deg2rad(15));
|
||||
$deg=2*rad2deg(asin($l/2/$r1));
|
||||
|
||||
|
||||
//全部坐标算法
|
||||
for($i=0;$i<360;$i+=30){
|
||||
$x=cos(deg2rad($i%180));
|
||||
$z=sin(deg2rad($i%180));
|
||||
if($i>=180){
|
||||
$x=-$x;
|
||||
$z=-$z;
|
||||
}
|
||||
if($i%60==30){
|
||||
$pos1[$i/30]=$this->arc($info['X']+$r*5/4*$x,$info['Z']+$r*5/4*$z,$r1,1,180-0.5*$deg+$i,180+0.5*$deg+$i);
|
||||
$pos2=$pos1[$i/30];
|
||||
$pos1[$i/30]=array();
|
||||
for($ii=count($pos2)-1;$ii>=0;$ii--){
|
||||
$pos1[$i/30][]=$pos2[$ii];
|
||||
}
|
||||
}else{
|
||||
$pos1[$i/30]=$this->arc($info['X']+$r*3/4*$x,$info['Z']+$r*3/4*$z,$r1,1,$i,$i+$deg);
|
||||
}
|
||||
}
|
||||
//最终坐标算法
|
||||
/*$ro=$this->r;
|
||||
$a=(int)$ro/36;
|
||||
$b=$ro%36;
|
||||
$pos2=$pos1[$a];
|
||||
if(!isset($pos1[$a])){
|
||||
return null;
|
||||
}
|
||||
for($i=$b*$deg/36;$i<=($b+1)*$deg/36;$i+=1){
|
||||
$pos[]=array($pos1[$a][(int)$i][0],$info['Y'],$pos1[$a][(int)$i][1]);
|
||||
}*/
|
||||
foreach($pos1 as $p1){
|
||||
foreach($p1 as $p2){
|
||||
$pos[]=array($p2[0],$info['Y'],$p2[1]);
|
||||
}
|
||||
}
|
||||
return $pos;
|
||||
unset($info,$level,$v3a,$v3b,$v3c,$v3d,$i,$r,$x,$z);
|
||||
}
|
||||
|
||||
public function star1($info){
|
||||
$pos=$this->star($info);
|
||||
$info1=$info;
|
||||
$info2=$info;
|
||||
$info3=$info;
|
||||
$info4=$info;
|
||||
$info5=$info;
|
||||
$info1['X']-=$info['R']*cos(18*pi()/180);
|
||||
$info1['Z']+=$info['R']*sin(18*pi()/180);
|
||||
|
||||
$info2['X']+=$info['R']*cos(18*pi()/180);
|
||||
$info2['Z']+=$info['R']*sin(18*pi()/180);
|
||||
|
||||
$info3['X']-=$info['R']*cos(54*pi()/180);
|
||||
$info3['Z']-=$info['R']*sin(54*pi()/180);
|
||||
|
||||
$info4['X']+=$info['R']*cos(54*pi()/180);
|
||||
$info4['Z']-=$info['R']*sin(54*pi()/180);
|
||||
$info5['Z']+=$info['R'];
|
||||
$info1['R']=$info['R']*0.2;
|
||||
$info2['R']=$info['R']*0.2;
|
||||
$info3['R']=$info['R']*0.2;
|
||||
$info4['R']=$info['R']*0.2;
|
||||
$info5['R']=$info['R']*0.2;
|
||||
$pos=array_merge($pos,$this->circle($info1));
|
||||
$pos=array_merge($pos,$this->circle($info2));
|
||||
$pos=array_merge($pos,$this->circle($info3));
|
||||
$pos=array_merge($pos,$this->circle($info4));
|
||||
$pos=array_merge($pos,$this->circle($info5));
|
||||
return $pos;
|
||||
}
|
||||
|
||||
public function star2($info){
|
||||
$this->star1($info);
|
||||
$this->circle($info);
|
||||
$info['R']=$info['R']*0.8;
|
||||
$this->circle($info);
|
||||
}
|
||||
|
||||
public function star3($info){
|
||||
$r=$info['R'];
|
||||
$info1=$info;
|
||||
$pos=array();
|
||||
|
||||
$pos=$this->circle($info1);
|
||||
$pos=array_merge($pos,$this->hexagon($info1));
|
||||
|
||||
$a=$info1;
|
||||
$b=$info1;
|
||||
$c=$info1;
|
||||
$info1['R']=$r*0.9;
|
||||
$a['X']-=$info1['R']*sin(deg2rad(60));
|
||||
$a['Z']-=$info1['R']*cos(deg2rad(60));
|
||||
$b['X']+=$info1['R']*sin(deg2rad(60));
|
||||
$b['Z']-=$info1['R']*cos(deg2rad(60));
|
||||
$c['Z']+=$info1['R'];
|
||||
$a['R']=$r*0.3;
|
||||
$b['R']=$r*0.3;
|
||||
$c['R']=$r*0.3;
|
||||
$pos=array_merge($pos,$this->triangle($a));
|
||||
$pos=array_merge($pos,$this->triangle($b));
|
||||
$pos=array_merge($pos,$this->triangle($c));
|
||||
|
||||
$info1['R']=$r*0.72;
|
||||
$pos=array_merge($pos,$this->circle($info1));
|
||||
$info1['R']=$r*0.7;
|
||||
$pos=array_merge($pos,$this->triangle($info1));
|
||||
$pos=array_merge($pos,$this->triangle1($info1));
|
||||
|
||||
$a=$info1;
|
||||
$b=$info1;
|
||||
$c=$info1;
|
||||
$d=$info1;
|
||||
$e=$info1;
|
||||
$f=$info1;
|
||||
//算坐标
|
||||
$a['X']-=$info1['R']*cos(deg2rad(30));
|
||||
$a['Z']+=$info1['R']*sin(deg2rad(30));
|
||||
|
||||
$b['X']+=$info1['R']*cos(deg2rad(30));
|
||||
$b['Z']+=$info1['R']*sin(deg2rad(30));
|
||||
|
||||
$c['Z']-=$info1['R'];
|
||||
|
||||
$d['X']+=$info1['R']*cos(deg2rad(30));
|
||||
$d['Z']-=$info1['R']*sin(deg2rad(30));
|
||||
|
||||
$e['X']-=$info1['R']*cos(deg2rad(30));
|
||||
$e['Z']-=$info1['R']*sin(deg2rad(30));
|
||||
|
||||
$f['Z']+=$info1['R'];
|
||||
//修改半径
|
||||
$a['R']=$r*0.1;
|
||||
$b['R']=$r*0.1;
|
||||
$c['R']=$r*0.1;
|
||||
$d['R']=$r*0.1;
|
||||
$e['R']=$r*0.1;
|
||||
$f['R']=$r*0.1;
|
||||
//生成
|
||||
$pos=array_merge($pos,$this->circle1($a));
|
||||
$pos=array_merge($pos,$this->circle1($b));
|
||||
$pos=array_merge($pos,$this->circle1($c));
|
||||
$pos=array_merge($pos,$this->circle1($d));
|
||||
$pos=array_merge($pos,$this->circle1($e));
|
||||
$pos=array_merge($pos,$this->circle1($f));
|
||||
|
||||
$info1['R']=$r*0.5;
|
||||
$pos=array_merge($pos,$this->triangle($info1));
|
||||
$pos=array_merge($pos,$this->triangle1($info1));
|
||||
return $pos;
|
||||
}
|
||||
|
||||
/* public function turn($a=0,$b=0,$c=0,$pos=array()){
|
||||
if($pos==array()){
|
||||
return null;
|
||||
}
|
||||
|
||||
if($a<0){
|
||||
$rx=$this->ro;
|
||||
}elseif($a>=0 && $a<=180){
|
||||
$rx=$a;
|
||||
}
|
||||
if($b<0){
|
||||
$ry=$this->ro;
|
||||
}elseif($b>=0 && $b<=180){
|
||||
$ry=$b;
|
||||
}
|
||||
if($c<0){
|
||||
$rz=$this->ro;
|
||||
}elseif($c>=0 && $c<=180){
|
||||
$rz=$c;
|
||||
}
|
||||
if(!isset($rx) || !isset($ry) || !isset($rz)){
|
||||
return $pos;
|
||||
}
|
||||
|
||||
$pos1=array();
|
||||
|
||||
foreach($pos as $p){
|
||||
$x=$p[0]-$info['X'];
|
||||
$y=$p[1]-$info['Y'];
|
||||
$z=$p[2]-$info['Z'];
|
||||
$nx1=$x*cos(deg2rad($ry))-$z*sin(deg2rad($ry));
|
||||
$ny1=$z*sin(deg2rad($rx))+$y*cos(deg2rad($rx));
|
||||
$nz1=$z*cos(deg2rad($rx))-$y*sin(deg2rad($rx));
|
||||
$x=$nx1;
|
||||
$y=$ny1;
|
||||
$z=$nz1;
|
||||
$nx2=$x*cos(deg2rad($rz))-$y*sin(deg2rad($rz));
|
||||
$ny2=$x*sin(deg2rad($rz))+$y*cos(deg2rad($rz));
|
||||
$nz2=$x*sin(deg2rad($ry))+$z*cos(deg2rad($ry));
|
||||
$pos1[]=array($info['X']+$nx2,$info['Y']+$ny2,$info['Z']+$nz2);
|
||||
}
|
||||
return $pos1;
|
||||
}
|
||||
*/
|
||||
public function Shadow(){
|
||||
switch($this->color['s']){
|
||||
case 1:
|
||||
$this->color['g']+=3;
|
||||
if($this->color['g']>=255){
|
||||
$this->color['g']=255;
|
||||
$this->color['s']=2;
|
||||
}
|
||||
break;
|
||||
case 2:
|
||||
$this->color['r']-=3;
|
||||
if($this->color['r']<=0){
|
||||
$this->color['r']=0;
|
||||
$this->color['s']=3;
|
||||
}
|
||||
break;
|
||||
case 3:
|
||||
$this->color['b']+=3;
|
||||
if($this->color['b']>=255){
|
||||
$this->color['b']=255;
|
||||
$this->color['s']=4;
|
||||
}
|
||||
break;
|
||||
case 4:
|
||||
$this->color['g']-=3;
|
||||
if($this->color['g']<=0){
|
||||
$this->color['g']=0;
|
||||
$this->color['s']=5;
|
||||
}
|
||||
break;
|
||||
case 5:
|
||||
$this->color['r']+=3;
|
||||
if($this->color['r']>=255){
|
||||
$this->color['r']=255;
|
||||
$this->color['s']=6;
|
||||
}
|
||||
break;
|
||||
case 6:
|
||||
$this->color['b']-=3;
|
||||
if($this->color['b']<=0){
|
||||
$this->color['b']=0;
|
||||
$this->color['s']=1;
|
||||
}
|
||||
break;
|
||||
}
|
||||
}
|
||||
|
||||
public function getParticle($name,Vector3 $pos){
|
||||
switch($name){
|
||||
case 'Lava':
|
||||
return new LavaParticle($pos);
|
||||
break;
|
||||
case 'Bubble':
|
||||
return new BubbleParticle($pos);
|
||||
break;
|
||||
case 'Lavadrip':
|
||||
return new LavaDripParticle($pos);
|
||||
break;
|
||||
case 'Waterdrip':
|
||||
return new WaterDripParticle($pos);
|
||||
break;
|
||||
case 'Enchant':
|
||||
return new EnchantmentTableParticle($pos);
|
||||
break;
|
||||
case 'Flame':
|
||||
return new FlameParticle($pos);
|
||||
break;
|
||||
case 'Redstone':
|
||||
return new RedstoneParticle($pos);
|
||||
break;
|
||||
case 'Smoke':
|
||||
return new SmokeParticle($pos);
|
||||
break;
|
||||
case 'WhiteSmoke':
|
||||
return new WhiteSmokeParticle($pos);
|
||||
break;
|
||||
case 'Spell':
|
||||
return new SpellParticle($pos);
|
||||
break;
|
||||
case 'Splash':
|
||||
return new SplashParticle($pos);
|
||||
break;
|
||||
case 'Spore':
|
||||
return new SporeParticle($pos);
|
||||
break;
|
||||
case 'HappyVillager':
|
||||
return new HappyVillagerParticle($pos);
|
||||
break;
|
||||
case 'AngryVillager':
|
||||
return new AngryVillagerParticle($pos);
|
||||
break;
|
||||
case 'Heart':
|
||||
return new HeartParticle($pos);
|
||||
break;
|
||||
case 'Portal':
|
||||
return new PortalParticle($pos);
|
||||
break;
|
||||
case 1:
|
||||
case 'Red':
|
||||
return new DustParticle($pos,250,0,0,250);
|
||||
break;
|
||||
case 2:
|
||||
case 'Green':
|
||||
return new DustParticle($pos,0,250,0,250);
|
||||
break;
|
||||
case 3:
|
||||
case 'Blue':
|
||||
return new DustParticle($pos,0,0,250,250);
|
||||
break;
|
||||
case 4:
|
||||
case 'Yellow':
|
||||
return new DustParticle($pos,250,250,0,250);
|
||||
break;
|
||||
case 5:
|
||||
case 'Orange':
|
||||
return new DustParticle($pos,250,125,0,250);
|
||||
break;
|
||||
case 6:
|
||||
case 'Pink':
|
||||
return new DustParticle($pos,250,125,250,250);
|
||||
break;
|
||||
case 7:
|
||||
case 'Purple':
|
||||
return new DustParticle($pos,125,0,250,250);
|
||||
break;
|
||||
case 8:
|
||||
case 'White':
|
||||
return new DustParticle($pos,250,250,250,250);
|
||||
break;
|
||||
case 9:
|
||||
case 'Green-blue':
|
||||
return new DustParticle($pos,0,250,250,250);
|
||||
break;
|
||||
case 'Shadow':
|
||||
return new DustParticle($pos,$this->color['r'],$this->color['g'],$this->color['b'],255);
|
||||
break;
|
||||
case 'Colorful':
|
||||
return $this->getParticle($this->cf,$pos);
|
||||
break;
|
||||
default:
|
||||
return $this->getParticle('Red',$pos);
|
||||
break;
|
||||
}
|
||||
unset($name,$pos);
|
||||
}
|
||||
|
||||
public function taskManager(){
|
||||
$this->sendParticle();
|
||||
if($this->Timber==10){
|
||||
$this->Timber=0;
|
||||
}
|
||||
$this->Timber++;
|
||||
if($this->r>=180){
|
||||
$this->r=0;
|
||||
}
|
||||
$this->r+=3;
|
||||
if($this->d==100){
|
||||
$this->d=0;
|
||||
}
|
||||
$this->d+=10;
|
||||
if($this->ro==180){
|
||||
$this->ro=0;
|
||||
}
|
||||
$this->ro+=1;
|
||||
$this->Height();
|
||||
$this->Shadow();
|
||||
$this->cf=rand(1,9);
|
||||
}
|
||||
|
||||
public function Height(){
|
||||
if($this->h['pos']==array()){
|
||||
$r=$this->h['maxh']/2;
|
||||
$pos=array();
|
||||
$pos1=array();
|
||||
for($i=0;$i<90;$i+=5){
|
||||
$x=$r*cos(deg2rad($i));
|
||||
$xx=$r*cos(deg2rad($i+1));
|
||||
$pos[]=$x-$xx;
|
||||
}
|
||||
for($i=0;$i<=90;$i+=5){
|
||||
$z=$r*sin(deg2rad($i));
|
||||
if($i!=0){
|
||||
$zz=$r*sin(deg2rad($i-1));
|
||||
}else{
|
||||
$zz=0;
|
||||
}
|
||||
$pos[]=$z-$zz;
|
||||
}
|
||||
for($i=0;$i<count($pos);$i+=1){
|
||||
if($i%2==0){
|
||||
$pos1[]=$pos[$i];
|
||||
}
|
||||
}
|
||||
$this->h['pos']=$pos;
|
||||
$this->h['pos1']=$pos1;
|
||||
}
|
||||
switch($this->h['s']){
|
||||
case 1:
|
||||
$this->h['h']+=$this->h['pos'][$this->h['hh']];
|
||||
$this->h['hh']+=1;
|
||||
if($this->h['hh']>=count($this->h['pos'])){
|
||||
$this->h['s']=2;
|
||||
$this->h['hh']-=1;
|
||||
}
|
||||
break;
|
||||
case 2:
|
||||
$this->h['h']-=$this->h['pos'][$this->h['hh']];
|
||||
$this->h['hh']-=1;
|
||||
if($this->h['hh']<0){
|
||||
$this->h['s']=1;
|
||||
$this->h['hh']=0;
|
||||
}
|
||||
if($this->h['h']<=$this->h['maxh']/2 && $this->h['s1']==0){
|
||||
$this->h['s1']=1;
|
||||
$this->h['h1']=0;
|
||||
$this->h['hh1']=0;
|
||||
}
|
||||
break;
|
||||
}
|
||||
|
||||
switch($this->h['s1']){
|
||||
case 1:
|
||||
$this->h['h1']+=$this->h['pos1'][$this->h['hh1']];
|
||||
$this->h['hh1']+=1;
|
||||
if($this->h['hh1']>=count($this->h['pos1'])){
|
||||
$this->h['s1']=2;
|
||||
$this->h['hh1']-=1;
|
||||
}
|
||||
break;
|
||||
case 2:
|
||||
$this->h['h1']-=$this->h['pos1'][$this->h['hh1']];
|
||||
$this->h['hh1']-=1;
|
||||
if($this->h['hh1']<0){
|
||||
$this->h['s1']=0;
|
||||
}
|
||||
break;
|
||||
}
|
||||
}
|
||||
}
|
||||
?>
|
||||
48
[粒子生成器]DParticle/src/dxp/dpt/shape/Ball.php
Normal file
48
[粒子生成器]DParticle/src/dxp/dpt/shape/Ball.php
Normal file
@@ -0,0 +1,48 @@
|
||||
<?php
|
||||
namespace dxp\dpt\shape;
|
||||
/*
|
||||
球体坐标算法
|
||||
By:aabbcc872[dxp]
|
||||
最后一次优化:2017.10.11
|
||||
参数说明:
|
||||
r=半径[double|int|float]
|
||||
data=array(经密度,纬密度)[建议为90因数]
|
||||
*/
|
||||
class Ball extends ShapeBase{
|
||||
public static function getVector3($r=3,$data=array()){
|
||||
$pos=array();
|
||||
//密度控制
|
||||
if(!isset($data[0])){
|
||||
$k1=9;
|
||||
}else{
|
||||
$k1=$data[0];
|
||||
}
|
||||
if(!isset($data[1])){
|
||||
$k2=9;
|
||||
}else{
|
||||
$k2=$data[1];
|
||||
}
|
||||
//经坐标计算
|
||||
$a=array();
|
||||
for($i=0;$i<=90;$i+=$k1){
|
||||
$x=$r*cos(deg2rad($i));
|
||||
$y=$r*sin(deg2rad($i));
|
||||
$a[]=array($x,+$y);
|
||||
$a[]=array($x,-$y);
|
||||
}
|
||||
//纬坐标计算
|
||||
foreach($a as $b){
|
||||
for($i=0;$i<=90;$i+=$k2){
|
||||
$x=$b[0]*cos(deg2rad($i));
|
||||
$z=$b[0]*sin(deg2rad($i));
|
||||
$pos[]=array($x,$b[1],$z);
|
||||
$pos[]=array(-$z,$b[1],$x);
|
||||
$pos[]=array(-$x,$b[1],-$z);
|
||||
$pos[]=array($z,$b[1],-$x);
|
||||
}
|
||||
}
|
||||
unset($r,$data,$k1,$k2,$a,$i,$x,$y,$b,$z);
|
||||
return $pos;
|
||||
}
|
||||
}
|
||||
?>
|
||||
34
[粒子生成器]DParticle/src/dxp/dpt/shape/Ball1.php
Normal file
34
[粒子生成器]DParticle/src/dxp/dpt/shape/Ball1.php
Normal file
@@ -0,0 +1,34 @@
|
||||
<?php
|
||||
namespace dxp\dpt\shape;
|
||||
/*
|
||||
球体坐标算法
|
||||
By:aabbcc872[dxp]
|
||||
最后一次优化:2017.10.11
|
||||
参数说明:
|
||||
r=半径[double|int|float]
|
||||
data=array(经密度,纬密度)[建议为90因数]
|
||||
*/
|
||||
class Ball1 extends ShapeBase{
|
||||
public static function getVector3($r,$data){
|
||||
$pos=array();
|
||||
|
||||
$a=array();
|
||||
for($i=0;$i<=90;$i+=3){
|
||||
$x=$r*cos(deg2rad($i));
|
||||
$y=$r*sin(deg2rad($i));
|
||||
$a[]=array($x,$y);
|
||||
$a[]=array($x,-$y);
|
||||
}
|
||||
foreach($a as $b){
|
||||
$x=$b[0]*cos(deg2rad($ro));
|
||||
$z=$b[0]*sin(deg2rad($ro));
|
||||
$pos[]=array($x,$b[1],$z);
|
||||
$pos[]=array(+$z,$b[1],-$x);
|
||||
$pos[]=array(-$x,$b[1],-$z);
|
||||
$pos[]=array(-$z,$b[1],$x);
|
||||
}
|
||||
return $pos;
|
||||
unset($pos,$r,$ro,$a,$i,$b,$x,$z);
|
||||
}
|
||||
}
|
||||
?>
|
||||
22
[粒子生成器]DParticle/src/dxp/dpt/shape/Ball2.php
Normal file
22
[粒子生成器]DParticle/src/dxp/dpt/shape/Ball2.php
Normal file
@@ -0,0 +1,22 @@
|
||||
<?php
|
||||
namespace dxp\dpt\shape;
|
||||
|
||||
class Ball2 extends ShapeBase{
|
||||
public static function getVector3($r,$data){
|
||||
//高密圆算法
|
||||
$pos=array();
|
||||
$info=$this->info;
|
||||
|
||||
$info['α']=0;
|
||||
$info['β']=0;
|
||||
$info['γ']=0;
|
||||
$obj=new Circle($info,$pl);
|
||||
$pos=$obj->pos;
|
||||
unset($obj);
|
||||
$pos1=array_merge($pos,$this->turn(90,0,0,$pos));
|
||||
$pos1=array_merge($pos1,$this->turn(0,0,90,$pos));
|
||||
return $pos1;
|
||||
unset($pos,$r,$pl,$info,$obj);
|
||||
}
|
||||
}
|
||||
?>
|
||||
44
[粒子生成器]DParticle/src/dxp/dpt/shape/Circle.php
Normal file
44
[粒子生成器]DParticle/src/dxp/dpt/shape/Circle.php
Normal file
@@ -0,0 +1,44 @@
|
||||
<?php
|
||||
namespace dxp\dpt\shape;
|
||||
/*
|
||||
圆算法
|
||||
By:aabbcc872[dxp]
|
||||
最后一次优化:2017.10.11
|
||||
参数说明:
|
||||
r=半径[double|int|float]
|
||||
data=array(密度)[建议为90因数,设为-1弹性计算]
|
||||
*/
|
||||
class Circle extends ShapeBase{
|
||||
public static function getVector3($r=2,$data=array()){
|
||||
$pos=array();
|
||||
//密度控制
|
||||
if(!isset($data[0])){
|
||||
$k=-1;
|
||||
}
|
||||
if($data[0]==0){
|
||||
return array(0,0,0);
|
||||
}
|
||||
if($data[0]==-1){
|
||||
|
||||
$ar=round($r,1);
|
||||
$c=0;
|
||||
for($a=0;$a<=$ar;$a+=0.1){
|
||||
$c++;
|
||||
}
|
||||
$b=360/($c*4);
|
||||
if($b>90 || $b<0){
|
||||
$b=3;
|
||||
}
|
||||
for($i=0;$i<=90;$i+=$b){
|
||||
$x=$r*cos(deg2rad($i));
|
||||
$z=$r*sin(deg2rad($i));
|
||||
$pos[]=array($x,0,$z);
|
||||
$pos[]=array(-$z,0,$x);
|
||||
$pos[]=array(-$x,0,-$z);
|
||||
$pos[]=array($z,0,-$x);
|
||||
}
|
||||
unset($r,$data,$i,$x,$z);
|
||||
return $pos;
|
||||
}
|
||||
}
|
||||
?>
|
||||
21
[粒子生成器]DParticle/src/dxp/dpt/shape/Circle1.php
Normal file
21
[粒子生成器]DParticle/src/dxp/dpt/shape/Circle1.php
Normal file
@@ -0,0 +1,21 @@
|
||||
<?php
|
||||
namespace dxp\dpt\shape;
|
||||
|
||||
class Circle1 extends ShapeBase{
|
||||
public static function getVector3($r,$data){
|
||||
//高密圆算法
|
||||
$pos=array();
|
||||
|
||||
for($t=0;$t<=sqrt(2)*$r;$t+=0.2){
|
||||
$x=sqrt(2)*$r*0.5-$t;
|
||||
$z=sqrt(pow(sqrt(2)*$r*0.5,2)-pow(sqrt(2)*$r*0.5-$t,2));
|
||||
$pos[]=array($x,0,$z);
|
||||
$pos[]=array($x,0,-$z);
|
||||
$pos[]=array($z,0,$x);
|
||||
$pos[]=array(-$z,0,$x);
|
||||
}
|
||||
unset($r,$x,$z,$t);
|
||||
return $pos;
|
||||
}
|
||||
}
|
||||
?>
|
||||
29
[粒子生成器]DParticle/src/dxp/dpt/shape/Hexagon.php
Normal file
29
[粒子生成器]DParticle/src/dxp/dpt/shape/Hexagon.php
Normal file
@@ -0,0 +1,29 @@
|
||||
<?php
|
||||
namespace dxp\dpt\shape;
|
||||
|
||||
class Hexagon extends ShapeBase{
|
||||
public static function getVector3($r,$data){
|
||||
//正六边形算法
|
||||
$pos=array();
|
||||
$sin=sin(deg2rad(30));
|
||||
$cos=cos(deg2rad(30));
|
||||
|
||||
$l=2*$r*$sin;
|
||||
for($i=-$r*$sin;$i<=$r*$sin;$i+=0.1){
|
||||
$pos[]=array($r*$cos,0,$i);
|
||||
$pos[]=array(-$r*$cos,0,$i);
|
||||
}
|
||||
|
||||
for($i=0;$i<=$l;$i+=0.1){
|
||||
$x=$i*$cos;
|
||||
$z=$i*$sin;
|
||||
$pos[]=array(-$x,0,$r-$z);
|
||||
$pos[]=array($x,0,$r-$z);
|
||||
$pos[]=array(-$x,0,-$r+$z);
|
||||
$pos[]=array($x,0,-$r+$z);
|
||||
}
|
||||
return $pos;
|
||||
unset($pos,$r,$i,$x,$z);
|
||||
}
|
||||
}
|
||||
?>
|
||||
28
[粒子生成器]DParticle/src/dxp/dpt/shape/Pentagon.php
Normal file
28
[粒子生成器]DParticle/src/dxp/dpt/shape/Pentagon.php
Normal file
@@ -0,0 +1,28 @@
|
||||
<?php
|
||||
namespace dxp\dpt\shape;
|
||||
|
||||
class Pentagon extends ShapeBase{
|
||||
public static function getVector3($r,$data){
|
||||
//正五边形算法
|
||||
$pos=array();
|
||||
$sin=sin(deg2rad(36));
|
||||
$cos=cos(deg2rad(36));
|
||||
|
||||
$l=2*$r*$sin;
|
||||
for($i=-$r*$sin;$i<=$r*$sin;$i+=0.1){
|
||||
$pos[]=array($i,0,-$r*$cos);
|
||||
}
|
||||
|
||||
for($i=0;$i<=$l;$i+=0.1){
|
||||
$x=$i*sin(deg2rad(18));
|
||||
$z=$i*cos(deg2rad(18));
|
||||
$pos[]=array(-$cos*$i,0,$r-$sin*$i);
|
||||
$pos[]=array($cos*$i,0,$r-$sin*$i);
|
||||
$pos[]=array(-$r*$sin-$x,0,-$r*$cos+$z);
|
||||
$pos[]=array($r*$sin+$x,0,-$r*$cos+$z);
|
||||
}
|
||||
return $pos;
|
||||
unset($pos,$r,$i,$x,$z,$sina,$sinb);
|
||||
}
|
||||
}
|
||||
?>
|
||||
18
[粒子生成器]DParticle/src/dxp/dpt/shape/Random.php
Normal file
18
[粒子生成器]DParticle/src/dxp/dpt/shape/Random.php
Normal file
@@ -0,0 +1,18 @@
|
||||
<?php
|
||||
namespace dxp\dpt\shape;
|
||||
|
||||
class Random extends ShapeBase{
|
||||
public static function getVector3($r,$data){
|
||||
//随机坐标算法
|
||||
$pos=array();
|
||||
|
||||
$x=rand(-10*$r,10*$r)/10;
|
||||
$z=rand(-10*$r,10*$r)/10;
|
||||
$pos[]=array($x,0,$z);
|
||||
$pos[]=array(-$x,0,-$z);
|
||||
|
||||
unset($r,$x,$z);
|
||||
return $pos;
|
||||
}
|
||||
}
|
||||
?>
|
||||
33
[粒子生成器]DParticle/src/dxp/dpt/shape/Ring.php
Normal file
33
[粒子生成器]DParticle/src/dxp/dpt/shape/Ring.php
Normal file
@@ -0,0 +1,33 @@
|
||||
<?php
|
||||
namespace dxp\dpt\shape;
|
||||
|
||||
class Ring extends ShapeBase{
|
||||
public static function getVector3($r,$data){
|
||||
//环形隧道算法
|
||||
$pos=array();
|
||||
|
||||
$a=array();
|
||||
$rr=$r*0.2;
|
||||
for($i=0;$i<=90;$i+=10){
|
||||
$x=$rr*cos(deg2rad($i));
|
||||
$y=$rr*sin(deg2rad($i));
|
||||
$a[]=array($x,$y);
|
||||
$a[]=array($x,-$y);
|
||||
$a[]=array(-$x,$y);
|
||||
$a[]=array(-$x,-$y);
|
||||
}
|
||||
foreach($a as $b){
|
||||
for($i=0;$i<=90;$i+=10){
|
||||
$x=($r-$b[0])*cos(deg2rad($i));
|
||||
$z=($r-$b[0])*sin(deg2rad($i));
|
||||
$pos[]=array($x,$b[1],$z);
|
||||
$pos[]=array(-$z,$b[1],$x);
|
||||
$pos[]=array(-$x,$b[1],-$z);
|
||||
$pos[]=array($z,$b[1],-$x);
|
||||
}
|
||||
}
|
||||
return $pos;
|
||||
unset($pos,$r,$i,$x,$z);
|
||||
}
|
||||
}
|
||||
?>
|
||||
17
[粒子生成器]DParticle/src/dxp/dpt/shape/Round.php
Normal file
17
[粒子生成器]DParticle/src/dxp/dpt/shape/Round.php
Normal file
@@ -0,0 +1,17 @@
|
||||
<?php
|
||||
namespace dxp\dpt\shape;
|
||||
|
||||
class Round extends ShapeBase{
|
||||
public static function getVector3($r,$data){
|
||||
//动态平面双行星环绕算法(正)
|
||||
$pos=array();
|
||||
|
||||
$x=$r*cos(deg2rad($data[0]));
|
||||
$z=$r*sin(deg2rad($data[0]));
|
||||
$pos[]=array($x,0,$z);
|
||||
$pos[]=array(-$x,0,-$z);
|
||||
return $pos;
|
||||
unset($pos,$deg,$x,$z);
|
||||
}
|
||||
}
|
||||
?>
|
||||
18
[粒子生成器]DParticle/src/dxp/dpt/shape/Round1.php
Normal file
18
[粒子生成器]DParticle/src/dxp/dpt/shape/Round1.php
Normal file
@@ -0,0 +1,18 @@
|
||||
<?php
|
||||
namespace dxp\dpt\shape;
|
||||
|
||||
class Round1 extends ShapeBase{
|
||||
public static function getVector3($r,$data){
|
||||
//动态平面双行星环绕算法(反)
|
||||
$pos=array();
|
||||
|
||||
$x=$r*cos(deg2rad($data[0]));
|
||||
$z=$r*sin(deg2rad($data[0]));
|
||||
$pos[]=array(-$x,0,$z);
|
||||
$pos[]=array($x,0,-$z);
|
||||
|
||||
unset($r,$data,$x,$z);
|
||||
return $pos;
|
||||
}
|
||||
}
|
||||
?>
|
||||
19
[粒子生成器]DParticle/src/dxp/dpt/shape/Round2.php
Normal file
19
[粒子生成器]DParticle/src/dxp/dpt/shape/Round2.php
Normal file
@@ -0,0 +1,19 @@
|
||||
<?php
|
||||
namespace dxp\dpt\shape;
|
||||
|
||||
use dxp\dpt\DParticle;
|
||||
use dxp\dpt\shape\Round as Rd;
|
||||
|
||||
class Round2 extends ShapeBase{
|
||||
|
||||
public static function getVector3($r,$data){
|
||||
//动态平面四行星环绕算法(正反)
|
||||
$pos=array();
|
||||
|
||||
$pos=Rd::getVector3($r,$data);
|
||||
$pos=array_merge($pos,Round1::getVector3($r,$data));
|
||||
unset($r,$data);
|
||||
return $pos;
|
||||
}
|
||||
}
|
||||
?>
|
||||
26
[粒子生成器]DParticle/src/dxp/dpt/shape/Round3.php
Normal file
26
[粒子生成器]DParticle/src/dxp/dpt/shape/Round3.php
Normal file
@@ -0,0 +1,26 @@
|
||||
<?php
|
||||
namespace dxp\dpt\shape;
|
||||
|
||||
class Round3 extends ShapeBase{
|
||||
public static function getVector3($r,$data){
|
||||
//动态平面双行星环绕算法(正)
|
||||
$pos=array();
|
||||
$h=$data[1];
|
||||
|
||||
$x=$r*cos(deg2rad($deg));
|
||||
$z=$r*sin(deg2rad($deg));
|
||||
$pos[]=array($x,-2+$h['h'],$z);
|
||||
$pos[]=array(-$x,-2+$h['h'],-$z);
|
||||
if($h['s1']!==0){
|
||||
$pos1=array();
|
||||
$x=$r*cos(deg2rad($data[0]));
|
||||
$z=$r*sin(deg2rad($data[0]));
|
||||
$pos1[]=array(-$x,-2+$h['h1'],-$z);
|
||||
$pos1[]=array($x,-2+$h['h1'],$z);
|
||||
$pos=array_merge($pos,$pos1);
|
||||
}
|
||||
return $pos;
|
||||
unset($pos,$pos1,$r,$pl,$h,$deg,$x,$z);
|
||||
}
|
||||
}
|
||||
?>
|
||||
116
[粒子生成器]DParticle/src/dxp/dpt/shape/ShapeBase.php
Normal file
116
[粒子生成器]DParticle/src/dxp/dpt/shape/ShapeBase.php
Normal file
@@ -0,0 +1,116 @@
|
||||
<?php
|
||||
namespace dxp\dpt\shape;
|
||||
|
||||
use dxp\dpt\DParticle;
|
||||
|
||||
class ShapeBase{
|
||||
public function __construct(DParticle $plugin){
|
||||
$this->cache=array();
|
||||
$this->cachetime=array();
|
||||
$this->plugin=$plugin;
|
||||
}
|
||||
|
||||
protected function run(Array $info){
|
||||
$name=$info['R'].$info['α'].$info['β'].$info['γ'].$info['Deg'];
|
||||
if(isset($this->cache[$name])){
|
||||
if($this->cachetime[$name]<=0){
|
||||
$data=$this->cache[$name];
|
||||
unset($this->cache[$name],$this->cachetime[$name]);
|
||||
}else{
|
||||
$data=$this->cache[$name];
|
||||
}
|
||||
}else{
|
||||
if(!isset($info['Deg'])){
|
||||
$info['Deg']=0;
|
||||
}
|
||||
$deg=$info['Deg'];
|
||||
if($deg<0){
|
||||
$deg=$this->plugin->r;
|
||||
}
|
||||
if($info['Shape']=='Wing'){
|
||||
$v3pos=$this->getVector3($info['R'],$info['Wing']);
|
||||
$this->cache[$name]=$data=array($this->turn($info['α'],$info['β'],$info['γ'],$v3pos),$this->getParticleMap($info['R'],$info['Wing']));
|
||||
$this->cachetime[$name]=12000;
|
||||
}elseif(in_array($info['Shape'],array('Random'))){
|
||||
$v3pos=$this->getVector3($info['R'],$deg);
|
||||
$data=array($this->turn($info['α'],$info['β'],$info['γ'],$v3pos),$this->getParticleMap($info['R'],$info['Deg']));
|
||||
}else{
|
||||
$v3pos=$this->getVector3($info['R'],$deg);
|
||||
$this->cache[$name]=$data=array($this->turn($info['α'],$info['β'],$info['γ'],$v3pos),$this->getParticleMap($info['R'],$info['Deg']));
|
||||
$this->cachetime[$name]=12000;
|
||||
}
|
||||
}
|
||||
return $data;
|
||||
}
|
||||
|
||||
public static function getVector3($r,Array $data){
|
||||
return null;
|
||||
}
|
||||
|
||||
public static function turn($a=0,$b=0,$c=0,$pos=array()){
|
||||
if($pos==array()){
|
||||
return $pos;
|
||||
}
|
||||
$k=array(array(1,1),array(1,1),array(1,1));
|
||||
$deg=array($a,$b,$c);
|
||||
|
||||
if($deg[0]==0 && $deg[1]==0 && $deg[2]==0){
|
||||
return $pos;
|
||||
}
|
||||
|
||||
if($a>180){
|
||||
$deg[0]-=180;
|
||||
$k[1][0]=-1;
|
||||
$k[2][0]=-1;
|
||||
}
|
||||
if($b>180){
|
||||
$deg[1]-=180;
|
||||
$k[0][0]=-1;
|
||||
$k[2][1]=-1;
|
||||
}
|
||||
if($c>180){
|
||||
$deg[2]-=180;
|
||||
$k[0][1]=-1;
|
||||
$k[1][1]=-1;
|
||||
}
|
||||
|
||||
$pos1=array();
|
||||
|
||||
foreach($pos as $p){
|
||||
$x=$p[0];
|
||||
$y=$p[1];
|
||||
$z=$p[2];
|
||||
$yy=$k[1][0]*($y*cos(deg2rad($deg[0]))+$z*sin(deg2rad($deg[0])));
|
||||
$zz=$k[2][0]*($z*cos(deg2rad($deg[0]))-$y*sin(deg2rad($deg[0])));
|
||||
$y=$yy;
|
||||
$z=$zz;
|
||||
$zz=$k[2][1]*($z*cos(deg2rad($deg[1]))+$x*sin(deg2rad($deg[1])));
|
||||
$xx=$k[0][0]*($x*cos(deg2rad($deg[1]))-$z*sin(deg2rad($deg[1])));
|
||||
$x=$xx;
|
||||
$z=$zz;
|
||||
|
||||
$xx=$k[0][1]*($x*cos(deg2rad($deg[2]))+$y*sin(deg2rad($deg[2])));
|
||||
$yy=$k[1][1]*($y*cos(deg2rad($deg[2]))-$x*sin(deg2rad($deg[2])));
|
||||
$pos1[]=array($xx,$yy,$zz);
|
||||
}
|
||||
unset($x,$y,$z,$nx,$ny,$nz,$deg,$a,$b,$c,$k,$pl,$pos);
|
||||
return $pos1;
|
||||
|
||||
}
|
||||
|
||||
public static function getParticleMap($r,$deg){
|
||||
return array();
|
||||
}
|
||||
|
||||
public function taskManager(){
|
||||
foreach($this->cachetime as $cache=>$time){
|
||||
if($time>0){
|
||||
$time--;
|
||||
$this->cachetime[$cache]=$time;
|
||||
}else{
|
||||
unset($this->cachetime[$cache]);
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
?>
|
||||
20
[粒子生成器]DParticle/src/dxp/dpt/shape/Square.php
Normal file
20
[粒子生成器]DParticle/src/dxp/dpt/shape/Square.php
Normal file
@@ -0,0 +1,20 @@
|
||||
<?php
|
||||
namespace dxp\dpt\shape;
|
||||
|
||||
class Square extends ShapeBase{
|
||||
public static function getVector3($r,$deg){
|
||||
//正方形算法
|
||||
$pos=array();
|
||||
|
||||
$r/=sqrt(2);
|
||||
for($i=-$r;$i<=$r;$i+=0.2){
|
||||
$pos[]=array($i,0,$r);
|
||||
$pos[]=array($i,0,-$r);
|
||||
$pos[]=array($r,0,$i);
|
||||
$pos[]=array(-$r,0,$i);
|
||||
}
|
||||
return $pos;
|
||||
unset($pos,$r,$i);
|
||||
}
|
||||
}
|
||||
?>
|
||||
33
[粒子生成器]DParticle/src/dxp/dpt/shape/Star.php
Normal file
33
[粒子生成器]DParticle/src/dxp/dpt/shape/Star.php
Normal file
@@ -0,0 +1,33 @@
|
||||
<?php
|
||||
namespace dxp\dpt\shape;
|
||||
|
||||
class Star extends ShapeBase{
|
||||
public static function getVector3($r,$deg){
|
||||
//五角星算法
|
||||
$pos=array();
|
||||
$sin1=sin(deg2rad(18));
|
||||
$cos1=cos(deg2rad(18));
|
||||
$sin2=sin(deg2rad(36));
|
||||
$cos2=cos(deg2rad(36));
|
||||
|
||||
$l=2*$r*$cos1;
|
||||
for($i=-$r*$cos1;$i<=$r*$cos1;$i+=0.1){
|
||||
$pos[]=array($i,0,$r*$sin1);
|
||||
}
|
||||
|
||||
for($i=0;$i<=$l;$i+=0.1){
|
||||
$x=$i*$cos1;
|
||||
$z=$i*$sin1;
|
||||
$pos[]=array(-$z,0,$r-$x);
|
||||
$pos[]=array($z,0,$r-$x);
|
||||
|
||||
$x=$i*$cos2;
|
||||
$z=$i*$sin2;
|
||||
$pos[]=array($r*$cos1-$x,0,$r*$sin1-$z);
|
||||
$pos[]=array(-$r*$cos1+$x,0,$r*$sin1-$z);
|
||||
}
|
||||
unset($r,$deg,$sin1,$cos1,$sin2,$cos2,$i,$x,$z,$l);
|
||||
return $pos;
|
||||
}
|
||||
}
|
||||
?>
|
||||
50
[粒子生成器]DParticle/src/dxp/dpt/shape/Star1.php
Normal file
50
[粒子生成器]DParticle/src/dxp/dpt/shape/Star1.php
Normal file
@@ -0,0 +1,50 @@
|
||||
<?php
|
||||
namespace dxp\dpt\shape;
|
||||
|
||||
use dxp\dpt\DParticle;
|
||||
|
||||
class Star1 extends ShapeBase{
|
||||
|
||||
public function run(){
|
||||
//五角星阵算法
|
||||
$pos=array();
|
||||
$r=$this->r;
|
||||
$pl=$this->pl;
|
||||
$info=$this->info;
|
||||
|
||||
$info['α']=0;
|
||||
$info['β']=0;
|
||||
$info['γ']=0;
|
||||
$o=new Star($info,$pl);
|
||||
$pos=$o->pos;
|
||||
$info1=$info;
|
||||
$info1['R']=$r*0.2;
|
||||
$oo=new Circle($info1,$pl);
|
||||
$poss=$oo->pos;
|
||||
foreach($poss as $p){
|
||||
$pp=$p;
|
||||
$pp[0]=$p[0]-$r*cos(deg2rad(18));
|
||||
$pp[2]=$p[2]+$r*sin(deg2rad(18));
|
||||
$pos[]=$pp;
|
||||
|
||||
$pp[0]=$p[0]+$r*cos(deg2rad(18));
|
||||
$pp[2]=$p[2]+$r*sin(deg2rad(18));
|
||||
$pos[]=$pp;
|
||||
|
||||
$pp[0]=$p[0]-$r*cos(deg2rad(54));
|
||||
$pp[2]=$p[2]-$r*sin(deg2rad(54));
|
||||
$pos[]=$pp;
|
||||
|
||||
$pp[0]=$p[0]+$r*cos(deg2rad(54));
|
||||
$pp[2]=$p[2]-$r*sin(deg2rad(54));
|
||||
$pos[]=$pp;
|
||||
|
||||
$pp[0]=$p[0];
|
||||
$pp[2]=$p[2]+$r;
|
||||
$pos[]=$pp;
|
||||
}
|
||||
return $pos;
|
||||
unset($pos,$r,$pl,$info,$info1,$poss,$p,$pp);
|
||||
}
|
||||
}
|
||||
?>
|
||||
26
[粒子生成器]DParticle/src/dxp/dpt/shape/Triangle.php
Normal file
26
[粒子生成器]DParticle/src/dxp/dpt/shape/Triangle.php
Normal file
@@ -0,0 +1,26 @@
|
||||
<?php
|
||||
namespace dxp\dpt\shape;
|
||||
|
||||
class Triangle extends ShapeBase{
|
||||
public static function getVector3($r,$deg){
|
||||
//正三角形算法
|
||||
$pos=array();
|
||||
$sin=sin(deg2rad(30));
|
||||
$cos=cos(deg2rad(30));
|
||||
|
||||
$l=2*$r*$cos;
|
||||
for($i=-$r*$cos;$i<=$r*$cos;$i+=0.1){
|
||||
$pos[]=array($i,0,-$r*$sin);
|
||||
}
|
||||
|
||||
for($i=0;$i<=$l;$i+=0.1){
|
||||
$x=$i*$cos;
|
||||
$z=$i*$sin;
|
||||
$pos[]=array(-$z,0,$r-$x);
|
||||
$pos[]=array($z,0,$r-$x);
|
||||
}
|
||||
return $pos;
|
||||
unset($pos,$r,$deg,$sin,$cos,$i,$x,$z);
|
||||
}
|
||||
}
|
||||
?>
|
||||
150
[粒子生成器]DParticle/src/dxp/dpt/shape/Wing.php
Normal file
150
[粒子生成器]DParticle/src/dxp/dpt/shape/Wing.php
Normal file
@@ -0,0 +1,150 @@
|
||||
<?php
|
||||
namespace dxp\dpt\shape;
|
||||
|
||||
class Wing extends ShapeBase{
|
||||
public static function getVector3($r,$wing=null){
|
||||
//粒子翼算法
|
||||
$pos=array();
|
||||
$w1=array();
|
||||
|
||||
if(!is_numeric($wing[0]) || !is_numeric($wing[1]) || !is_array($wing[2])){
|
||||
return null;
|
||||
}
|
||||
|
||||
for($a=0;$a<count($wing[2]);$a++){
|
||||
$w=$wing[2][$a];
|
||||
for($i=0;$i<count($w);$i++){
|
||||
$b=$w[$i];
|
||||
for($ii=0;$ii<count($b);$ii++){
|
||||
$c=$b[$ii];
|
||||
if($c!==0){
|
||||
$pos[]=array((count($b)-$ii)*0.15,(count($w)-$i)*0.15,-0.15*$a);
|
||||
}
|
||||
if($ii==0 && $w1==array()){
|
||||
$w1[]=array((count($b)-$ii)*0.15,0,0);
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
$pos1=ShapeBase::turn(0,$r,0,$pos);
|
||||
$w1=ShapeBase::turn(0,$r,0,$w1);
|
||||
|
||||
$pos=array();
|
||||
if($wing[0]==1){
|
||||
if(!isset($wing[3]) || !is_array($wing[3])){
|
||||
return null;
|
||||
}
|
||||
for($a=0;$a<count($wing[3]);$a++){
|
||||
$w=$wing[3][$a];
|
||||
for($i=0;$i<count($w);$i++){
|
||||
$b=$w[$i];
|
||||
for($ii=0;$ii<count($b);$ii++){
|
||||
$c=$b[$ii];
|
||||
if($c!==0){
|
||||
$pos[]=array((count($b)-$ii)*0.15,(count($w)-$i)*0.15,(-0.15*$a));
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
if($r<=90){
|
||||
$r=$r*3;
|
||||
}else{
|
||||
$rr=360-$r;
|
||||
$r=360-($rr*3);
|
||||
}
|
||||
$pos2=ShapeBase::turn(0,$r,0,$pos);
|
||||
$pos3=array();
|
||||
foreach($pos2 as $ppp){
|
||||
$ppp[0]+=$w1[0][0];
|
||||
$ppp[2]+=$w1[0][2];
|
||||
$pos3[]=$ppp;
|
||||
}
|
||||
$pos1=array_merge($pos1,$pos3);
|
||||
}
|
||||
$pos=array();
|
||||
foreach($pos1 as $p){
|
||||
$p[2]-=0.5;
|
||||
$pos[]=$p;
|
||||
$pp=$p;
|
||||
$pp[0]=-$p[0];
|
||||
$pos[]=$pp;
|
||||
}
|
||||
unset($r,$i,$x,$z,$w,$pos1,$pos2,$pp,$a,$b,$c,$deg);
|
||||
return $pos;
|
||||
}
|
||||
|
||||
public static function getParticleMap($r,$wing=null){
|
||||
if(!is_numeric($wing[0]) || !isset($wing[1]) || !is_array($wing[2])){
|
||||
return array();
|
||||
}
|
||||
$particle=array();
|
||||
for($a=0;$a<count($wing[2]);$a++){
|
||||
$w=$wing[2][$a];
|
||||
for($i=0;$i<count($w);$i++){
|
||||
$b=$w[$i];
|
||||
for($ii=0;$ii<count($b);$ii++){
|
||||
$c=$b[$ii];
|
||||
if($c!==0){
|
||||
$particle[]=$c;
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
if($wing[0]==1){
|
||||
if(!isset($wing[3]) || !is_array($wing[3])){
|
||||
return array();
|
||||
}
|
||||
for($a=0;$a<count($wing[3]);$a++){
|
||||
$w=$wing[3][$a];
|
||||
for($i=0;$i<count($w);$i++){
|
||||
$b=$w[$i];
|
||||
for($ii=0;$ii<count($b);$ii++){
|
||||
$c=$b[$ii];
|
||||
if($c!==0){
|
||||
$particle[]=$c;
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
$par=array();
|
||||
foreach($particle as $pp){
|
||||
$par[]=$pp;
|
||||
$par[]=$pp;
|
||||
}
|
||||
unset($pos,$r,$i,$x,$z,$w,$b,$c,$deg);
|
||||
$pt=array();
|
||||
foreach($par as $p){
|
||||
switch($p){
|
||||
case 1:
|
||||
$pt[]='Flame';
|
||||
break;
|
||||
case 2:
|
||||
$pt[]='Portal';
|
||||
break;
|
||||
case 3:
|
||||
$pt[]='HappyVillager';
|
||||
break;
|
||||
case 4:
|
||||
$pt[]='Redstone';
|
||||
break;
|
||||
case 5:
|
||||
$pt[]='Smoke';
|
||||
break;
|
||||
case 6:
|
||||
$pt[]='Heart';
|
||||
break;
|
||||
case 7:
|
||||
$pt[]='Bubble';
|
||||
break;
|
||||
default:
|
||||
$pt[]=null;
|
||||
break;
|
||||
}
|
||||
}
|
||||
return $pt;
|
||||
}
|
||||
}
|
||||
?>
|
||||
Reference in New Issue
Block a user