All Downloads are FREE. Search and download functionalities are using the official Maven repository.

mmb.engine.visuals.VisualObject Maven / Gradle / Ivy

Go to download

Dependency for the MultiMachineBuilder, a voxel game about building an industrial empire in a finite world. THIS RELEASE IS NOT PLAYABLE. To play the game, donwload from >ITCH.IO LINK HERE< or >GH releases link here<

The newest version!
/**
 * 
 */
package mmb.engine.visuals;

import mmb.Nil;
import mmb.engine.worlds.world.World;

/**
 * @author oskar
 * This class allows easy management of visual objects (effects, handles etc...)
 * @param  type of the visual object
 */
public class VisualObject<@Nil T extends Visual> {
	private T obj;
	/** The world with visual objects */
	public final World w;
	
	/**
	 * Creates a visual object with a visual
	 * @param obj visual object (may be null)
	 * @param w the underlying world
	 */
	public VisualObject(@Nil T obj, World w) {
		super();
		setObj(obj);
		this.w = w;
	}
	/**
	 * Creates a visual object without a visual
	 * @param w the underlying world
	 */
	public VisualObject(World w) {
		super();
		this.w = w;
	}
	
	/** @return the current visual object */
	public T getObj() {
		return obj;
	}
	/** @param obj1 new visual object */
	public void setObj(T obj1) {
		if(obj != null) w.removeVisual(obj);
		obj = obj1;
		if(obj1 != null) w.addVisual(obj1);
	}
	/** Removes the visual object */
	public void kill() {
		setObj(null);
	}
}




© 2015 - 2024 Weber Informatics LLC | Privacy Policy