summaryrefslogtreecommitdiff
path: root/src/tesseract/objects/emitters/FireableEmitter.java
blob: 881e4364c13d4b739fe688aaefc9c2deba7a8bca (plain)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
package tesseract.objects.emitters;

import java.util.LinkedList;
import java.util.List;

import javax.vecmath.Color3f;
import javax.vecmath.Vector3f;

import tesseract.objects.Particle;
import tesseract.objects.PhysicalObject;

public class FireableEmitter extends PhysicalObject {
	Color3f myColor;
	
	public FireableEmitter(Vector3f position, Vector3f direction, Color3f color) {
		super(position, Float.POSITIVE_INFINITY);
		myColor = color;
	}
	
	public void moveMe (Vector3f newPosition) {
		position = newPosition;
	}
	
	/**
	 * Update State and maybe generate a new object.
	 * 
	 * @param duration The length of time that has passed.
	 * @return A list of new objects to add to the world.
	 */
	public List<PhysicalObject> spawnChildren() {
		List<PhysicalObject> children = super.spawnChildren(0f);
		
		if (children == null) {
			children = new LinkedList<PhysicalObject>();
		}
		
		children.add(new Particle(this.position, myColor));
		
		return children;
	}

}