6 [
Attribute(
"0",
"If multiselect uses custom flags. If false it will use the default system and sets states of flags either true or false")]
7 protected bool m_bCustomFlags;
10 private int m_iFlagChecker = 1;
13 protected vector m_vFlags;
16 private int m_iStateVectorIndex;
19 private int m_iFlagsPerIndex = 31;
22 private int m_iCurrentFlagsPerIndex;
25 protected void AddOrderedState(
bool state)
27 if (m_iStateVectorIndex > 2)
29 Debug.Error2(Type().ToString(),
string.Format(
"Attribute multiselect has reach the max element limit of '%1'!", (31 * 3).ToString()));
35 int stateValue = m_vFlags[m_iStateVectorIndex];
36 stateValue |= m_iFlagChecker;
37 m_vFlags[m_iStateVectorIndex] = stateValue;
41 m_iCurrentFlagsPerIndex++;
43 if (m_iCurrentFlagsPerIndex >= m_iFlagsPerIndex)
44 ResetLoopValues(
true);
48 protected bool GetOrderedState()
50 if (m_iStateVectorIndex > 2)
52 Print(
string.Format(
"Attribute multiselect has reach the max element limit of '%1' and is therefore set to false!", (31 * 3).ToString()), LogLevel.WARNING);
56 int stateValue = m_vFlags[m_iStateVectorIndex];
57 bool returnState = (stateValue & m_iFlagChecker);
60 m_iCurrentFlagsPerIndex++;
62 if (m_iCurrentFlagsPerIndex >= m_iFlagsPerIndex)
63 ResetLoopValues(
true);
68 protected int GetStateVectorIndex()
70 return m_iStateVectorIndex;
74 protected bool AddFlag(
int flag,
int vectorIndex = 0)
76 if (vectorIndex > 2 || vectorIndex < 0)
79 int flagValue = m_vFlags[vectorIndex];
81 m_vFlags[vectorIndex] = flagValue;
87 protected bool SetFlags(
int flags,
int vectorIndex = 0)
89 if (vectorIndex > 2 || vectorIndex < 0)
92 m_vFlags[vectorIndex] = flags;
97 protected int GetFlags(
int vectorIndex)
99 if (vectorIndex > 2 || vectorIndex < 0)
102 return m_vFlags[vectorIndex];
106 protected bool HasFlag(
int flagToCheck)
111 while (vectorIndex < 3)
113 flagValue = m_vFlags[vectorIndex];
114 if (flagValue & flagToCheck)
123 protected void ResetLoopValues(
bool increaseVectorIndex)
126 m_iCurrentFlagsPerIndex = 0;
128 if (increaseVectorIndex)
129 m_iStateVectorIndex++;
131 m_iStateVectorIndex = 0;
134 protected vector GetFlagVector()
142 ResetLoopValues(
false);
143 m_vFlags = Vector(0,0,0);
149 override void WriteVariable(Managed item,
SCR_BaseEditorAttributeVar var, SCR_AttributesManagerEditorComponent manager,
int playerID)
154 ResetLoopValues(
false);
155 m_vFlags = var.GetVector();
158 override int GetEntries(notnull array<ref SCR_BaseEditorAttributeEntry> outEntries)
163 return outEntries.Count();