Created
September 17, 2014 09:50
-
-
Save arturaz/52be25fa21d32ad1c4c1 to your computer and use it in GitHub Desktop.
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
package app.models.world | |
import java.util.UUID | |
import shapeless._ | |
import shapeless.ops.record.Selector | |
import shapeless.record._ | |
import shapeless.syntax.singleton._ | |
trait WObjectStats | |
object WObject { | |
type Id = UUID | |
def newId: Id = UUID.randomUUID() | |
private object Witnesses { | |
val id = Witness("id") | |
val position = Witness("position") | |
} | |
private object Selectors { | |
type Id = Selector[Witnesses.id.T, UUID] | |
type Position = Selector[Witnesses.position.T, Vect2] | |
} | |
} | |
/* World object */ | |
abstract class WObject[A <: HList](val props: A)(implicit | |
idSel: WObject.Selectors.Id, positionSel: WObject.Selectors.Position | |
) { | |
def this(id: WObject.Id, position: Vect2) = | |
this("id" ->> id :: "position" ->> position :: HNil) | |
def id = props("id") | |
def position = props("position") | |
def withId(id: WObject.Id) = props | |
def stats: Stats | |
lazy val bounds = Bounds(position, Vect2.one) | |
} |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment