File size: 1,346 Bytes
24b81cb |
1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 26 27 28 29 30 31 32 33 34 35 36 37 38 39 40 41 42 43 |
class DisplayElementTendency extends DisplayElementBase
{
protected int TENDENCY_MASK = 7;// first x bits
protected int SERIOUSNESS_BIT_MASK = 7;// second x bits
protected int SERIOUSNESS_BIT_OFFSET = 3;//bit offset - points to where seriousness bit starts(TODO: get as log from mask)
void DisplayElementTendency(PlayerBase player)
{
NUM_OF_BITS = 6;//the overall num of bits this element occupies(can be calculated from masks, better leave it explicit)
}
void SetSeriousnessLevel( DSLevels level )
{
m_Value = (~(SERIOUSNESS_BIT_MASK << SERIOUSNESS_BIT_OFFSET)) & m_Value;//clear the last value
m_Value = (level << SERIOUSNESS_BIT_OFFSET) | m_Value;
}
override void UpdateHUD()
{
super.UpdateHUD();
int seriousness = m_Value >> SERIOUSNESS_BIT_OFFSET;
int tendency = TENDENCY_MASK & m_Value;
//PrintString(tendency.ToString());
if(tendency > 3)
{
tendency = -(tendency - 3);
}
/*
PrintString(this.ToString());
PrintString("ser:"+ seriousness.ToString());
PrintString("tnd:"+ tendency.ToString());
*/
m_ModulePlayerStatus.DisplayTendency(m_Key, tendency, TranslateLevelToStatus(seriousness));
}
void SetTendency(int tendency)
{
m_Value = (~TENDENCY_MASK) & m_Value;//clear the last value
m_Value = tendency | m_Value;//insert the new one
//PrintString(m_Value.ToString());
}
} |