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<

There is a newer version: 0.6
Show newest version
/**
 * 
 */
package mmb.engine.visuals;

import org.checkerframework.checker.nullness.qual.Nullable;

import mmb.engine.worlds.world.World;

/**
 * @author oskar
 * This class allows easy management of visual objects (effects, handles etc...)
 */
public class VisualObject<@Nullable T extends Visual> {
	private T obj;
	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(@Nullable 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 obj 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