mirror of
https://github.com/psforever/PSF-LoginServer.git
synced 2026-01-19 18:44:45 +00:00
prototype of weapon mold proof-of-concept in progress
This commit is contained in:
parent
87d2f256f1
commit
4bbf627770
|
|
@ -6,6 +6,46 @@ import scodec.{Attempt, Codec, Err}
|
|||
import scodec.codecs._
|
||||
import shapeless._
|
||||
|
||||
import scala.annotation.switch
|
||||
|
||||
case class Weapon(unk1 : Int,
|
||||
magazine : Int,
|
||||
unk2 : Int)
|
||||
|
||||
object Weapon extends Marshallable[Weapon] {
|
||||
implicit val codec : Codec[Weapon] = (
|
||||
("unk1" | uintL(23)) ::
|
||||
("magazine" | uint8L) ::
|
||||
("unk2" | uintL(13))
|
||||
).as[Weapon]
|
||||
}
|
||||
|
||||
case class Mold(objectClass : Int,
|
||||
dataPortion : BitVector) {
|
||||
|
||||
private var obj : Option[Any] = Mold.selectMold(objectClass, dataPortion)
|
||||
}
|
||||
|
||||
object Mold extends Marshallable[Mold] {
|
||||
def apply(objectClass : Int,
|
||||
obj : T forSome { type T }) : Mold =
|
||||
new Mold(objectClass, bin"")
|
||||
|
||||
def selectMold(objClass : Int, data : BitVector) : Option[Any] = {
|
||||
(objClass : @switch) match {
|
||||
case 0x4D3 =>
|
||||
Weapon.codec.decode(data).toOption
|
||||
case _ =>
|
||||
None
|
||||
}
|
||||
}
|
||||
|
||||
implicit val codec : Codec[Mold] = (
|
||||
("objectClass" | uintL(11)) ::
|
||||
("dataPortion" | bits)
|
||||
).as[Mold]
|
||||
}
|
||||
|
||||
/**
|
||||
* The parent information of a created object.<br>
|
||||
* <br>
|
||||
|
|
|
|||
Loading…
Reference in a new issue