1 class Headtorch_ColorBase
extends Clothing
5 static int REFLECTOR_ID = 4;
6 static int GLASS_ID = 5;
8 static string LIGHT_OFF_GLASS =
"dz\\characters\\headgear\\data\\HeadTorchGlass.rvmat";
9 static string LIGHT_OFF_REFLECTOR =
"dz\\characters\\headgear\\data\\HeadTorch.rvmat";
10 static string LIGHT_ON_GLASS =
"dz\\characters\\headgear\\data\\HeadTorchGlass_on.rvmat";
11 static string LIGHT_ON_GLASS_RED =
"dz\\characters\\headgear\\data\\HeadTorchGlass_on_red.rvmat";
12 static string LIGHT_ON_REFLECTOR =
"dz\\characters\\headgear\\data\\HeadTorch_ON.rvmat";
13 static string LIGHT_ON_REFLECTOR_RED =
"dz\\characters\\headgear\\data\\HeadTorch_ON_red.rvmat";
17 static string m_OffHeadLightPoint =
"beamStart";
18 static string m_OffHeadLightTarget =
"beamEnd";
22 void Headtorch_ColorBase()
29 m_Timer.Run(1 ,
this,
"CheckParent", NULL,
false);
33 override protected void InitGlobalExclusionValues()
35 super.InitGlobalExclusionValues();
36 AddSingleExclusionValueGlobal(EAttExclusions.EXCLUSION_HEADSTRAP_0);
41 EntityAI owner = GetHierarchyParent();
44 if (owner && owner.IsZombie())
46 GetInventory().CreateAttachment(
"Battery9V");
47 GetCompEM().SwitchOn();
62 CreateHeadtorchLight();
67 SetObjectMaterial(GLASS_ID, LIGHT_ON_GLASS_RED);
68 SetObjectMaterial(REFLECTOR_ID, LIGHT_ON_REFLECTOR_RED);
72 SetObjectMaterial(GLASS_ID, LIGHT_ON_GLASS);
73 SetObjectMaterial(REFLECTOR_ID, LIGHT_ON_REFLECTOR);
89 SetObjectMaterial(GLASS_ID, LIGHT_OFF_GLASS);
90 SetObjectMaterial(REFLECTOR_ID, LIGHT_OFF_REFLECTOR);
93 override void OnWork(
float consumed_energy)
95 super.OnWork(consumed_energy);
103 float efficiency = battery.GetEfficiency0To1();
107 m_Light.SetIntensity(efficiency, GetCompEM().GetUpdateInterval());
117 void OnLightCreated()
122 void CreateHeadtorchLight()
129 m_Light.PerformVisibilityCheck(
this);
131 EntityAI owner = GetHierarchyParent();
135 if (owner.IsPlayer())
138 ItemBase att_item = owner_PB.GetItemOnSlot(
"Eyewear");
140 if (att_item ==
this)
142 AttachLightOnHead(owner_PB);
146 m_Light.AttachOnMemoryPoint(
this, m_OffHeadLightPoint, m_OffHeadLightTarget);
149 else if (owner.IsZombie())
152 EntityAI item_EAI = owner.GetInventory().FindAttachment(slot_id);
157 AttachLightOnHead(owner);
163 m_Light.AttachOnMemoryPoint(
this, m_OffHeadLightPoint, m_OffHeadLightTarget);
167 void AttachLightOnHead(
EntityAI person)
169 if (person.IsPlayer())
172 int boneIdx = player.GetBoneIndexByName(
"Head");
179 m_Light.SetPosition(m_OnHeadLocalPos);
180 m_Light.SetOrientation(m_OnHeadLocalOri);
182 player.AddChild(
m_Light, boneIdx);
185 else if (person.IsZombie())
190 m_Light.SetPosition(m_OnHeadLocalPos);
191 m_Light.SetOrientation(m_OnHeadLocalOri);
199 super.OnWasAttached(parent, slot_id);
207 AttachLightOnHead(player);
214 super.OnWasDetached(parent, slot_id);
216 if (parent && (parent.IsPlayer() || parent.IsZombie()))
221 m_Light.AttachOnMemoryPoint(
this, m_OffHeadLightPoint, m_OffHeadLightTarget);
245 override void OnInvisibleSet(
bool invisible)
249 m_Light.SetEnabled(!invisible);