package ru.dbotthepony.kstarbound.world.physics

import ru.dbotthepony.kstarbound.json.builder.IStringSerializable
import java.util.*

enum class CollisionType(override val jsonName: String, val isEmpty: Boolean, val isSolidCollision: Boolean, val isTileCollision: Boolean) : IStringSerializable {
	// not loaded, block collisions by default
	NULL("Null", true, true, false),
	// air
	NONE("None", true, false, false),
	// including stairs made of platforms
	PLATFORM("Platform", false, false, false),
	DYNAMIC("Dynamic", false, true, false),
	SLIPPERY("Slippery", false, true, true),
	BLOCK("Block", false, true, true);

	fun maxOf(other: CollisionType): CollisionType {
		if (this === NULL || other === NULL)
			return NULL
		else if (this > other)
			return this
		else
			return other
	}

	companion object {
		val SOLID: Set<CollisionType> = Collections.unmodifiableSet(EnumSet.copyOf(entries.filter { it.isSolidCollision }.toSet()))
		val TILE: Set<CollisionType> = Collections.unmodifiableSet(EnumSet.copyOf(entries.filter { it.isTileCollision }.toSet()))
	}
}
