Add Alot
This commit is contained in:
@@ -12,14 +12,13 @@ class TrailPoint {
|
||||
}
|
||||
|
||||
spawn() {
|
||||
let spawnPosition: Vector3 = Vector3Add(this.postion, { x: 0.5, y: 0.5, z: 0.5 });
|
||||
// let spawnPosition: Vector3 = Vector3Add(this.postion, { x: 0.5, y: 0.5, z: 0.5 });
|
||||
let spawnPosition: Vector3 = this.postion;
|
||||
try {
|
||||
world
|
||||
.getDimension("overworld")
|
||||
.spawnParticle("minecraft:balloon_gas_particle", spawnPosition, new MolangVariableMap());
|
||||
} catch (e) {}
|
||||
|
||||
|
||||
}
|
||||
}
|
||||
|
||||
@@ -27,13 +26,15 @@ class Trail {
|
||||
id: string;
|
||||
points: TrailPoint[] = [];
|
||||
currentPoint: number = 0;
|
||||
wrapIndex: number = 0;
|
||||
nextParticleTimer: number = 0;
|
||||
currentParticleCounter: number = 0;
|
||||
|
||||
calculatedLength: number = 0;
|
||||
constructor(id: string, nextParticleTimer: number = 5) {
|
||||
constructor(id: string, nextParticleTimer: number = 5, wrapIndex: number = 0) {
|
||||
this.id = id;
|
||||
this.nextParticleTimer = nextParticleTimer;
|
||||
this.wrapIndex = wrapIndex;
|
||||
}
|
||||
|
||||
addPoint(point: TrailPoint) {
|
||||
@@ -58,10 +59,14 @@ class Trail {
|
||||
spawnNext() {
|
||||
if (this.currentParticleCounter >= this.nextParticleTimer) {
|
||||
this.currentParticleCounter = 0;
|
||||
|
||||
//wrapindex is in how many segments the trail is divided into
|
||||
let pointsPerInterval = this.wrapIndex > 0 ? this.calculatedLength / this.wrapIndex : 0;
|
||||
this.points
|
||||
.filter((point) => {
|
||||
return point.index === this.currentPoint;
|
||||
return (
|
||||
point.index === this.currentPoint ||
|
||||
(this.wrapIndex > 0 && point.index % pointsPerInterval === this.currentPoint)
|
||||
);
|
||||
})
|
||||
.forEach((point) => {
|
||||
point.spawn();
|
||||
|
||||
Reference in New Issue
Block a user