com.parzivail.pswg.client.input.JetpackControls Maven / Gradle / Ivy
Go to download
Show more of this group Show more artifacts with this name
Show all versions of pswg Show documentation
Show all versions of pswg Show documentation
Explore the galaxy with Galaxies: Parzi's Star Wars Mod!
package com.parzivail.pswg.client.input;
import ;
import java.util.EnumSet;
public enum JetpackControls
{
NONE(0), FORWARD(0b1), BACKWARD(0b10), LEFT(0b100), RIGHT(0b1000), ASCEND(0b10000), DESCEND(0b100000), MODE(0b1000000);
private final short flag;
JetpackControls(int flag)
{
this.flag = (short)flag;
}
public short getFlag()
{
return flag;
}
public static EnumSet unpack(short controls)
{
var allFlags = values();
var flags = EnumSet.noneOf(JetpackControls.class);
for (var flag : allFlags)
if ((controls & flag.getFlag()) != 0)
flags.add(flag);
return flags;
}
public static short pack(EnumSet controls)
{
short packed = 0;
for (var sc : controls)
packed |= sc.getFlag();
return packed;
}
}
© 2015 - 2025 Weber Informatics LLC | Privacy Policy