File size: 3,454 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 44 45 46 47 48 49 50 51 52 53 54 55 56 57 58 59 60 61 62 63 64 65 66 67 68 69 70 71 72 73 74 75 76 77 78 79 80 81 82 83 84 85 86 87 88 89 90 91 92 93 94 95 96 97 98 99 100 101 102 103 104 105 106 107 108 109 110 111 112 113 114 115 116 117 118 119 120 121 122 123 124 125 126 127 128 129 130 131 132 133 134 135 136 |
#ifdef DIAG_DEVELOPER
typedef Param3<bool, float, int> TimeAccelParam;//enabled, timeAccel,category mask
enum ETimeAccelCategories
{
//DO NOT FORGET TO INCLUDE IN THE MAPPING 'Init()' FUNCTION
UNDERGROUND_ENTRANCE = 0x00000001,
UNDERGROUND_RESERVOIR = 0x00000002,
ENERGY_CONSUMPTION = 0x00000004,
ENERGY_RECHARGE = 0x00000008,
FOOD_DECAY = 0x00000010,
//SYSTEM5 = 0x00000020,
//SYSTEM6 = 0x00000040,
//SYSTEM6 = 0x00000080,
}
class FeatureTimeAccel
{
static ref TimeAccelParam m_CurrentTimeAccel;// = new TimeAccelParam(false, 0, 0);
static ref map<int,int> m_Mapping = new map<int,int>();
static ref array<int> m_IDs = new array<int>();
static bool m_Initializeded = Init();
static bool Init()
{
Bind(DiagMenuIDs.FEATURE_TIME_ACCEL_UG_ENTRANCES, ETimeAccelCategories.UNDERGROUND_ENTRANCE);
Bind(DiagMenuIDs.FEATURE_TIME_ACCEL_UG_RESERVOIR, ETimeAccelCategories.UNDERGROUND_RESERVOIR);
Bind(DiagMenuIDs.FEATURE_TIME_ACCEL_ENERGY_CONSUME, ETimeAccelCategories.ENERGY_CONSUMPTION);
Bind(DiagMenuIDs.FEATURE_TIME_ACCEL_ENERGY_RECHARGE, ETimeAccelCategories.ENERGY_RECHARGE);
Bind(DiagMenuIDs.FEATURE_TIME_ACCEL_FOOD_DECAY, ETimeAccelCategories.FOOD_DECAY);
return true;
}
//-------------------------------
static void Bind(DiagMenuIDs id, ETimeAccelCategories catBit)
{
m_Mapping.Insert(id, catBit);
m_IDs.Insert(id);
}
//-------------------------------
static int GetCategoryByDiagID(DiagMenuIDs id)
{
return m_Mapping.Get(id);
}
//-------------------------------
static int GetDiagIDByCategory(ETimeAccelCategories category)
{
for (int i = 0; i < m_Mapping.Count();i++)
{
if (m_Mapping.GetElement(i) == category)
{
return m_Mapping.GetKey(i);
}
}
return -1;
}
//-------------------------------
static bool GetFeatureTimeAccelEnabled(ETimeAccelCategories categoryBit)
{
return (m_CurrentTimeAccel && m_CurrentTimeAccel.param1 && (categoryBit & m_CurrentTimeAccel.param3) != 0);
}
//-------------------------------
static float GetFeatureTimeAccelValue()
{
if (m_CurrentTimeAccel)
return m_CurrentTimeAccel.param2;
else return 1;
}
//-------------------------------
static void CopyTimeAccelClipboard(bool enable, int timeAccelBig, float timeAccelSmall, int bitMask)
{
string output = "-timeAccel=";
int val = enable;
output += val.ToString()+","+timeAccelBig.ToString()+","+timeAccelSmall.ToString()+","+bitMask.ToString();
GetGame().CopyToClipboard(output);
}
//-------------------------------
static int GetTimeAccelBitmask()
{
int bitmask = 0;
foreach (int id : m_IDs)
{
WriteCategoryBit(bitmask, id);
}
return bitmask;
}
//-------------------------------
static void WriteCategoryBit(out int bitmask, int diagMenuID)
{
int bit = GetCategoryByDiagID(diagMenuID);
if (DiagMenu.GetValue(diagMenuID))
{
bitmask = bitmask | bit;
}
}
//-------------------------------
static bool AreTimeAccelParamsSame(TimeAccelParam p1, TimeAccelParam p2)
{
if (!p1 || !p2)
return false;
if (p1.param1 != p2.param1)
return false;
if (p1.param2 != p2.param2)
return false;
if (p1.param3 != p2.param3)
return false;
return true;
}
//-------------------------------
static void SendTimeAccel(Man player, TimeAccelParam param)
{
GetGame().RPCSingleParam(player, ERPCs.DIAG_TIMEACCEL, param, true, player.GetIdentity());
}
}
#endif |