DayZ 1.24
Loading...
Searching...
No Matches
EntityLightSource Class Reference
Collaboration diagram for EntityLightSource:
[legend]

Private Member Functions

void ScriptedLightBase ()
 Constructor. Everything here is executed before the constructor of all children.
 
void ~ScriptedLightBase ()
 
override void EOnInit (IEntity other, int extra)
 
override bool IsScriptedLight ()
 
void UpdateMode ()
 
void UpdateLightMode (string slotName)
 
void DeleteLightWithDelay ()
 Correct way of deleting light from memory. It is necesarry to have this delay due to hierarchy.
 
void DeleteLightNow ()
 
void AttachOnObject (Object parent, vector local_pos="0 0 0", vector local_ori="0 0 0")
 Attaches this light on the parent entity, with optional position and orientation offset.
 
Object GetAttachmentParent ()
 Returns attachment parent.
 
void AttachOnMemoryPoint (Object parent, string memory_point_start, string memory_point_target="")
 Attaches this light on the parent entity's memory point, with optional direction target memory point.
 
void DetachFromParent ()
 Detaches this light from its parent entity.
 
void SetBrightnessTo (float value)
 Sets the brightness of the light.
 
void CorrectLightPulseDuringDaylight ()
 Call this after using SetBrightness(...) to fix light's intensity during daytime.
 
void FadeBrightnessTo (float value, float time_in_s)
 Fades the brightness of the light to the given value.
 
void SetRadiusTo (float value)
 Sets the radius of the light.
 
void FadeRadiusTo (float value, float time_in_s)
 Fades the radius of the light to the given value.
 
void Destroy ()
 Switches off the light and deletes it from memory.
 
void SetLifetime (float life_in_s)
 Makes the light destroy itself after the given time in seconds. The light will fade out if it's set to do so with SetFadeOutTime(...)
 
void SetFadeOutTime (float time_in_s)
 Sets the fade out time in seconds. Fade out begins automatically as the light nears the end of its life time, or when method FadeOut() is called.
 
void FadeOut (float time_in_s=-1)
 Starts the fade out process and destroys the light when its done. Optional parameter allows you to set time of this fade out in seconds. If not set, then default value (from SetFadeOutTime(...)) is used.
 
void FadeIn (float time_in_s)
 Makes the light fade into existence. Works only at the moment the light is created. Consider using FadeBrightnessTo(...) and FadeRadiusTo(...) at anytime later during lifetime.
 
void AddLifetime (float life_in_s)
 Prolongs the lifetime of the light in seconds. Use negative number to shorten its lifetime.
 
void OnFrameLightSource (IEntity other, float timeSlice)
 Override this for custom functionality.
 
override void EOnFrame (IEntity other, float timeSlice)
 On frame event. If you want to control your light within your own rules then override the event OnFrameLightSource and put your code there.
 
void SetDancingShadowsAmplitude (float max_deviation_in_meters)
 Sets the maximum range of the point light within the dancing shadows effect.
 
void SetDancingShadowsMovementSpeed (float speed_in_meters_per_frame)
 Sets the maximum speed of the point light within the dancing shadows effect.
 
float GetDancingShadowsAmplitude ()
 Returns max movement range of pointlight within the dancing shadow effect.
 
float GetDancingShadowsMovementSpeed ()
 Returns max movement speed of pointlight within the dancing shadow effect.
 
void EnableDebug (bool state)
 Enables some debug functionality of this light.
 
void HandleDancingShadows (float time, float timeSlice)
 
void HandleFlickering (float time, float timeSlice)
 
void SetFlickerSpeed (float speed)
 Sets speed of light flickering (random brightness coefficient change per second)
 
void SetFlickerAmplitude (float coef)
 Sets the change coefficient of flickering light. (0.0 - 1.0 values, result of greater values are period time of light off )
 
void SetFlickerAmplitudeMax (float coef)
 
void SetFlickerAmplitudeMin (float coef)
 
float GetFlickerSpeed ()
 Returns flicker speed.
 
float GetFlickerAmplitudeCoefMax ()
 Returns flicker amplitude maximum.
 
float GetFlickerAmplitudeCoefMin ()
 Returns flicker amplitude minimum.
 
void TryShadowOptimization ()
 Optimizes shadows by disabling them on this light source while it's within the given radius around the camera.
 
void SetDisableShadowsWithinRadius (float radius_in_m)
 When the light source gets within this radius (radius_in_m) around the camera, then it's shadows are disabled.
 
float GetDisableShadowsWithinRadius ()
 Returns the range you put inside SetDisableShadowsWithinRadius(...)
 
void CheckIfParentIsInCargo ()
 
bool CheckLifetime (int current_time)
 
void CheckFadeOut (int current_time)
 
void HandleBrightnessFadeing (float timeSlice)
 
void HandleRadiusFadeing (float timeSlice)
 
void SetBlinkingSpeed (float _speed)
 Sets blinking speed (no blinking if speed <= 0)
 
float GetBlinkingSpeed ()
 Returns the speed of blinks.
 
void HandleBlinking (float time)
 

Static Private Member Functions

static ScriptedLightBase CreateLightAtObjMemoryPoint (typename name, notnull Object target, string memory_point_start, string memory_point_target="", vector global_pos="0 0 0", float fade_in_time_in_s=0)
 
static ScriptedLightBase CreateLight (typename name, vector global_pos="0 0 0", float fade_in_time_in_s=0)
 Creates an instance of light on the given position. Optionally, use fade_in_time_in_s parameter to make the light fade into existence.
 

Private Attributes

float m_LifetimeStart
 
float m_LifetimeEnd = -1
 
float m_FadeOutTime = -1
 
float m_FadeInTime = -1
 
float m_Radius
 
float m_RadiusTarget
 
float m_Brightness
 
float m_BrightnessPulse
 
float m_BrightnessPulseSpeed
 
float m_BrightnessPulseAmplitudeMax
 
float m_BrightnessPulseAmplitudeMin
 
float m_BrightnessTarget
 
float m_BrightnessSpeedOfChange = 1
 
float m_RadiusSpeedOfChange = 1
 
float m_OptimizeShadowsRadius = 0
 
float m_DancingShadowsAmplitude
 
float m_DancingShadowsSpeed
 
float m_BlinkingSpeed
 
bool m_IsDebugEnabled = false
 
Object m_Parent
 
vector m_LocalPos
 
vector m_LocalOri
 
vector m_DancingShadowsLocalPos
 
ref Timer m_DeleteTimer
 

Static Private Attributes

static ref set< ScriptedLightBasem_NightTimeOnlyLights = new set<ScriptedLightBase>()
 

Detailed Description

Definition at line 10 of file ScriptedLightBase.c.

Constructor & Destructor Documentation

◆ ~ScriptedLightBase()

void EntityLightSource::~ScriptedLightBase ( )
inlineprivate

Definition at line 53 of file ScriptedLightBase.c.

54 {
56 {
57 int index = m_NightTimeOnlyLights.Find(this);
58 if (index != -1)
60 }
61 }
static ref set< ScriptedLightBase > m_NightTimeOnlyLights

Member Function Documentation

◆ AddLifetime()

void EntityLightSource::AddLifetime ( float life_in_s)
inlineprivate

Prolongs the lifetime of the light in seconds. Use negative number to shorten its lifetime.

Definition at line 342 of file ScriptedLightBase.c.

343 {
344 m_LifetimeEnd += life_in_s * 1000;
345 }

◆ AttachOnMemoryPoint()

void EntityLightSource::AttachOnMemoryPoint ( Object parent,
string memory_point_start,
string memory_point_target = "" )
inlineprivate

Attaches this light on the parent entity's memory point, with optional direction target memory point.

Definition at line 150 of file ScriptedLightBase.c.

151 {
152 if (parent.MemoryPointExists(memory_point_start))
153 {
154 m_LocalPos = parent.GetMemoryPointPos(memory_point_start);
156
157 if (memory_point_target != "")
158 {
159 if (parent.MemoryPointExists(memory_point_target))
160 {
161 vector target_pos = parent.GetSelectionPositionLS(memory_point_target);
163 local_ori = target_pos.VectorToAngles();
164 }
165 else
166 ErrorEx("memory point 'memory_point_target' not found when attaching light");
167 }
169 UpdateMode();
170 }
171 else
172 ErrorEx("memory point 'memory_point_start' not found when attaching light");
173 }
void AttachOnObject(Object parent, vector local_pos="0 0 0", vector local_ori="0 0 0")
Attaches this light on the parent entity, with optional position and orientation offset.
static vector Direction(vector p1, vector p2)
Returns direction vector from point p1 to point p2.
Definition EnConvert.c:220
enum ShapeType ErrorEx

References vector::Direction(), ErrorEx, and m_LocalPos.

◆ AttachOnObject()

void EntityLightSource::AttachOnObject ( Object parent,
vector local_pos = "0 0 0",
vector local_ori = "0 0 0" )
inlineprivate

Attaches this light on the parent entity, with optional position and orientation offset.

Definition at line 119 of file ScriptedLightBase.c.

120 {
121 if (!parent)
122 {
123 if (m_Parent)
124 m_Parent.RemoveChild(this);
125
126 return;
127 }
128 else
129 {
130 if (m_Parent)
131 m_Parent.RemoveChild(this);
132 }
133
134 m_Parent = parent;
137 SetOrientation(local_ori);
139 parent.AddChild(this, -1);
140 parent.Update();
141 }
proto native void SetPosition(vector position)
Set the world position of the Effect.
Definition Effect.c:420

References m_LocalOri, m_LocalPos, m_Parent, and SetPosition().

◆ CheckFadeOut()

void EntityLightSource::CheckFadeOut ( int current_time)
inlineprivate

Definition at line 576 of file ScriptedLightBase.c.

577 {
578 // Control fade out of the light
580 {
581 m_FadeOutTime = -1;
582 m_FadeInTime = -1; // Stop fade in process
583 float time_left_in_s = (m_LifetimeEnd - current_time) * 0.001;
586 }
587 }
void FadeBrightnessTo(float value, float time_in_s)
Fades the brightness of the light to the given value.
void FadeRadiusTo(float value, float time_in_s)
Fades the radius of the light to the given value.

◆ CheckIfParentIsInCargo()

void EntityLightSource::CheckIfParentIsInCargo ( )
inlineprivate

Definition at line 530 of file ScriptedLightBase.c.

531 {
532 // TO DO: OPTIMIZE AND REFACTOR! THIS MUST BE HANDLED IN AN EVENT, NOT PER FRAME!
533
534 if (m_Parent)
535 {
537
538 if (parent_EAI) // Check if the Cast was successfull
539 {
540 GameInventory GI = parent_EAI.GetInventory();
541
542 if (GI) // Prevents handling of light on the parent item when it's projected in inventory as the item in inventory character's hands.
543 {
544 bool is_in_cargo = GI.IsInCargo();
545
546 if (!is_in_cargo)
547 {
548 EntityAI parent2 = parent_EAI.GetHierarchyParent();
549
550 if (parent2 && parent2.GetInventory())
551 is_in_cargo = parent2.GetInventory().IsInCargo();
552 }
553
554 if (is_in_cargo)
555 SetEnabled(false);
556 else
557 SetEnabled(true);
558 }
559 }
560 }
561 }
void SetEnabled()
prevents insider adding in the wrong position, HOTFIX
script counterpart to engine's class Inventory
Definition Inventory.c:79

References m_Parent, and SetEnabled().

◆ CheckLifetime()

bool EntityLightSource::CheckLifetime ( int current_time)
inlineprivate

Definition at line 564 of file ScriptedLightBase.c.

565 {
567 {
568 Destroy();
569 return false;
570 }
571
572 return true;
573 }
void Destroy()
Switches off the light and deletes it from memory.

References Destroy().

◆ CorrectLightPulseDuringDaylight()

void EntityLightSource::CorrectLightPulseDuringDaylight ( )
inlineprivate

Call this after using SetBrightness(...) to fix light's intensity during daytime.

Definition at line 240 of file ScriptedLightBase.c.

241 {
242 if (m_Brightness < 100)
243 {
244 float v = m_Brightness * 0.01;
245
246 if (v > 0)
247 {
248 float brightness_compesation = 1 / v;
250 SetBrightness(compenset_brightness);
251 SetPulseCoef(v);
252 }
253 }
254 else
255 SetPulseCoef(1);
256 }

◆ CreateLight()

static ScriptedLightBase EntityLightSource::CreateLight ( typename name ,
vector global_pos = "0 0 0",
float fade_in_time_in_s = 0 )
inlinestaticprivate

Creates an instance of light on the given position. Optionally, use fade_in_time_in_s parameter to make the light fade into existence.

Definition at line 204 of file ScriptedLightBase.c.

205 {
207
208 if (!GetGame().IsServer() || !GetGame().IsMultiplayer()) // Client side
209 {
210 light_instance = ScriptedLightBase.Cast(GetGame().CreateObject(name.ToString(), global_pos, true));
211
212 if (!light_instance)
213 {
214 Error("Error! Light entity of name " + name.ToString() + " cannot be spawned! This name is incorrect or not inherited from ScriptedLightBase.");
215 return null;
216 }
217
218 if (fade_in_time_in_s != 0)
220 }
221 else // Server side
222 {
223 if (GetGame().IsDebug())
224 Error("An instance of ScriptedLightBase was attempted to spawn on server side! Lights are CLIENT SIDE ONLY!");
225 }
226
227 return light_instance;
228 }
PlayerSpawnPresetDiscreteItemSetSlotData name
one set for cargo
proto native CGame GetGame()
void Error(string err)
Messagebox with error message.
Definition EnDebug.c:90

References Error(), GetGame(), and name.

◆ CreateLightAtObjMemoryPoint()

static ScriptedLightBase EntityLightSource::CreateLightAtObjMemoryPoint ( typename name ,
notnull Object target,
string memory_point_start,
string memory_point_target = "",
vector global_pos = "0 0 0",
float fade_in_time_in_s = 0 )
inlinestaticprivate

Definition at line 192 of file ScriptedLightBase.c.

193 {
195 if (target.MemoryPointExists(memory_point_start))
196 {
198 light.AttachOnMemoryPoint(target, memory_point_start, memory_point_target);
199 }
200 return light;
201 }
void CreateLight()

References CreateLight(), and name.

◆ DeleteLightNow()

void EntityLightSource::DeleteLightNow ( )
inlineprivate

Definition at line 113 of file ScriptedLightBase.c.

114 {
115 GetGame().ObjectDelete(this);
116 }

References GetGame().

◆ DeleteLightWithDelay()

void EntityLightSource::DeleteLightWithDelay ( )
inlineprivate

Correct way of deleting light from memory. It is necesarry to have this delay due to hierarchy.

Definition at line 98 of file ScriptedLightBase.c.

99 {
100 DetachFromParent(); // This is the reason for the delay
101
102 if (GetGame())
103 {
104 if (!m_DeleteTimer)
106
107 m_DeleteTimer.Run(0.03, this, "DeleteLightNow", NULL, true);
108 }
109
110 }
void DetachFromParent()
Detaches this light from its parent entity.
const int CALL_CATEGORY_SYSTEM
Definition tools.c:8

References CALL_CATEGORY_SYSTEM, GetGame(), and m_DeleteTimer.

◆ Destroy()

void EntityLightSource::Destroy ( )
inlineprivate

Switches off the light and deletes it from memory.

Definition at line 289 of file ScriptedLightBase.c.

290 {
291 ClearEventMask(EntityEvent.FRAME);
292 SetEnabled(false);
293 if (m_Parent)
295 else
297 }
void DeleteLightWithDelay()
Correct way of deleting light from memory. It is necesarry to have this delay due to hierarchy.
EntityEvent
Entity events for event-mask, or throwing event from code.
Definition EnEntity.c:44

References m_Parent, and SetEnabled().

◆ DetachFromParent()

void EntityLightSource::DetachFromParent ( )
inlineprivate

Detaches this light from its parent entity.

Definition at line 176 of file ScriptedLightBase.c.

177 {
178 if (!m_Parent)
179 m_Parent = Object.Cast(GetParent());
180
181 if (m_Parent)
182 {
183 if (!m_Parent.ToDelete() && !ToDelete())
184 m_Parent.RemoveChild(this);
185 }
186
187 m_Parent = null;
188 m_LocalPos = Vector(0, 0, 0);
189 m_LocalOri = Vector(0, 0, 0);
190 }
proto native vector Vector(float x, float y, float z)
Vector constructor from components.
proto native Widget GetParent()
Get parent of the Effect.
Definition Effect.c:389

References GetParent(), m_LocalOri, m_LocalPos, m_Parent, and Vector().

◆ EnableDebug()

void EntityLightSource::EnableDebug ( bool state)
inlineprivate

Enables some debug functionality of this light.

Definition at line 402 of file ScriptedLightBase.c.

403 {
405 }

◆ EOnFrame()

override void EntityLightSource::EOnFrame ( IEntity other,
float timeSlice )
inlineprivate

On frame event. If you want to control your light within your own rules then override the event OnFrameLightSource and put your code there.

Definition at line 354 of file ScriptedLightBase.c.

355 {
356 // Control lifetime of the light
357 int current_time = GetGame().GetTime();
358
360 SetRadius(m_Radius);
361 else
362 return;
363
369
373
375 }
void HandleBrightnessFadeing(float timeSlice)
void HandleBlinking(float time)
void TryShadowOptimization()
Optimizes shadows by disabling them on this light source while it's within the given radius around th...
void HandleRadiusFadeing(float timeSlice)
void HandleDancingShadows(float time, float timeSlice)
void HandleFlickering(float time, float timeSlice)
void OnFrameLightSource(IEntity other, float timeSlice)
Override this for custom functionality.
void CheckFadeOut(int current_time)
bool CheckLifetime(int current_time)

References GetGame(), and m_Radius.

◆ EOnInit()

override void EntityLightSource::EOnInit ( IEntity other,
int extra )
inlineprivate

Definition at line 63 of file ScriptedLightBase.c.

64 {
65 if (!IsVisibleDuringDaylight())
66 {
68 if (player && player.m_UndergroundPresence)
69 SetVisibleDuringDaylight(true);
70 m_NightTimeOnlyLights.Insert(this);
71 }
72 }
PlayerBase GetPlayer()

References GetGame(), and GetPlayer().

◆ FadeBrightnessTo()

void EntityLightSource::FadeBrightnessTo ( float value,
float time_in_s )
inlineprivate

Fades the brightness of the light to the given value.

Definition at line 259 of file ScriptedLightBase.c.

260 {
262
263 if (time_in_s == 0)
265 else
267 }
Definition EnMath.c:7
static proto float AbsFloat(float f)
Returns absolute value.

References Math::AbsFloat().

◆ FadeIn()

void EntityLightSource::FadeIn ( float time_in_s)
inlineprivate

Makes the light fade into existence. Works only at the moment the light is created. Consider using FadeBrightnessTo(...) and FadeRadiusTo(...) at anytime later during lifetime.

Definition at line 334 of file ScriptedLightBase.c.

335 {
336 float brightness = m_Brightness;
339 }
void SetBrightnessTo(float value)
Sets the brightness of the light.

◆ FadeOut()

void EntityLightSource::FadeOut ( float time_in_s = -1)
inlineprivate

Starts the fade out process and destroys the light when its done. Optional parameter allows you to set time of this fade out in seconds. If not set, then default value (from SetFadeOutTime(...)) is used.

Definition at line 313 of file ScriptedLightBase.c.

314 {
315 float time_in_ms = time_in_s * 1000;
316
317 if (time_in_s == -1)
318 {
319 float kill_time_in_s = m_FadeOutTime * 0.001;
320
324 }
325 else
326 {
330 }
331 }
void SetLifetime(float life_in_s)
Makes the light destroy itself after the given time in seconds. The light will fade out if it's set t...

◆ FadeRadiusTo()

void EntityLightSource::FadeRadiusTo ( float value,
float time_in_s )
inlineprivate

Fades the radius of the light to the given value.

Definition at line 278 of file ScriptedLightBase.c.

References Math::AbsFloat(), and m_Radius.

◆ GetAttachmentParent()

Object EntityLightSource::GetAttachmentParent ( )
inlineprivate

Returns attachment parent.

Definition at line 144 of file ScriptedLightBase.c.

145 {
146 return m_Parent;
147 }

References m_Parent.

◆ GetBlinkingSpeed()

float EntityLightSource::GetBlinkingSpeed ( )
inlineprivate

Returns the speed of blinks.

Definition at line 656 of file ScriptedLightBase.c.

657 {
658 return m_BlinkingSpeed;
659 }

◆ GetDancingShadowsAmplitude()

float EntityLightSource::GetDancingShadowsAmplitude ( )
inlineprivate

Returns max movement range of pointlight within the dancing shadow effect.

Definition at line 390 of file ScriptedLightBase.c.

391 {
393 }

◆ GetDancingShadowsMovementSpeed()

float EntityLightSource::GetDancingShadowsMovementSpeed ( )
inlineprivate

Returns max movement speed of pointlight within the dancing shadow effect.

Definition at line 396 of file ScriptedLightBase.c.

397 {
399 }

◆ GetDisableShadowsWithinRadius()

float EntityLightSource::GetDisableShadowsWithinRadius ( )
inlineprivate

Returns the range you put inside SetDisableShadowsWithinRadius(...)

Definition at line 525 of file ScriptedLightBase.c.

526 {
528 }

◆ GetFlickerAmplitudeCoefMax()

float EntityLightSource::GetFlickerAmplitudeCoefMax ( )
inlineprivate

Returns flicker amplitude maximum.

Definition at line 493 of file ScriptedLightBase.c.

494 {
496 }

◆ GetFlickerAmplitudeCoefMin()

float EntityLightSource::GetFlickerAmplitudeCoefMin ( )
inlineprivate

Returns flicker amplitude minimum.

Definition at line 499 of file ScriptedLightBase.c.

500 {
502 }

◆ GetFlickerSpeed()

float EntityLightSource::GetFlickerSpeed ( )
inlineprivate

Returns flicker speed.

Definition at line 487 of file ScriptedLightBase.c.

488 {
490 }

◆ HandleBlinking()

void EntityLightSource::HandleBlinking ( float time)
inlineprivate

Definition at line 662 of file ScriptedLightBase.c.

663 {
664 if (m_BlinkingSpeed <= 0)
665 return;
666
667 float multiplier;
668
669 multiplier = Math.Sin(time * 0.001 * m_BlinkingSpeed); // Oscillate the multiplier overtime (time normalized to sec)
670 multiplier = (multiplier + 1) / 2; // Normalized the value to 0-1
671
672 multiplier = Math.Round(multiplier); // Rounding to 0 or 1 to make it blink instantly
673 SetBrightness(m_Brightness * multiplier);
674 }
static proto float Round(float f)
Returns mathematical round of value.
static proto float Sin(float angle)
Returns sinus of angle in radians.

References Math::Round(), and Math::Sin().

◆ HandleBrightnessFadeing()

void EntityLightSource::HandleBrightnessFadeing ( float timeSlice)
inlineprivate

Definition at line 590 of file ScriptedLightBase.c.

591 {
593 {
595
598
601
603
604 if (m_Brightness > 0 || m_BrightnessTarget > 0)
605 {
606 SetBrightness(m_Brightness * m_BrightnessPulse);
608 }
609 else
610 {
611 Destroy();
612 return;
613 }
614 }
615 else
616 {
617 SetBrightness(m_Brightness * m_BrightnessPulse);
619 }
620 }
void CorrectLightPulseDuringDaylight()
Call this after using SetBrightness(...) to fix light's intensity during daytime.

References Destroy().

◆ HandleDancingShadows()

void EntityLightSource::HandleDancingShadows ( float time,
float timeSlice )
inlineprivate

Definition at line 408 of file ScriptedLightBase.c.

409 {
411 {
412 for (int i = 0; i < 3; i++)
413 {
415
418
421
422 }
423
424 if (m_Parent && !m_Parent.ToDelete())
425 {
426 // In order to move with the light, it must be detached from its parent first
427
428 m_Parent.RemoveChild(this);
430
431 m_Parent.AddChild(this, -1);
432 m_Parent.Update();
433 }
434
436 {
437 Particle p = ParticleManager.GetInstance().PlayInWorld(ParticleList.DEBUG_DOT, GetPosition());
438 p.SetParticleParam(EmitorParam.SIZE, 0.01);
439 }
440 }
441 else
443 }
void ParticleManager(ParticleManagerSettings settings)
Constructor (ctor)
class JsonUndergroundAreaTriggerData GetPosition
Legacy way of using particles in the game.
Definition Particle.c:7
static const int DEBUG_DOT
static proto float RandomFloat(float min, float max)
Returns a random float number between and min[inclusive] and max[exclusive].
EmitorParam
Definition EnVisual.c:114

References ParticleList::DEBUG_DOT, GetPosition, m_LocalPos, m_Parent, ParticleManager(), Math::RandomFloat(), SetPosition(), and Vector().

◆ HandleFlickering()

void EntityLightSource::HandleFlickering ( float time,
float timeSlice )
inlineprivate

◆ HandleRadiusFadeing()

void EntityLightSource::HandleRadiusFadeing ( float timeSlice)
inlineprivate

Definition at line 623 of file ScriptedLightBase.c.

624 {
626 {
628
631
634
636
637 if (m_Radius > 0 || m_RadiusTarget > 0)
638 SetRadius(m_Radius);
639 else
640 {
641 Destroy();
642 return;
643 }
644 }
645 else
646 SetRadius(m_Radius);
647 }

References Destroy(), and m_Radius.

◆ IsScriptedLight()

override bool EntityLightSource::IsScriptedLight ( )
inlineprivate

Definition at line 74 of file ScriptedLightBase.c.

75 {
76 return true;
77 }

◆ OnFrameLightSource()

void EntityLightSource::OnFrameLightSource ( IEntity other,
float timeSlice )
inlineprivate

Override this for custom functionality.

Definition at line 348 of file ScriptedLightBase.c.

349 {
350 // ...
351 }

◆ ScriptedLightBase()

void EntityLightSource::ScriptedLightBase ( )
inlineprivate

Constructor. Everything here is executed before the constructor of all children.

Definition at line 45 of file ScriptedLightBase.c.

46 {
47 m_LifetimeStart = GetGame().GetTime();
48 SetEnabled(true);
49 SetEventMask(EntityEvent.FRAME);
50 SetEventMask(EntityEvent.INIT);
51 }

References GetGame(), and SetEnabled().

◆ SetBlinkingSpeed()

void EntityLightSource::SetBlinkingSpeed ( float _speed)
inlineprivate

Sets blinking speed (no blinking if speed <= 0)

Definition at line 650 of file ScriptedLightBase.c.

651 {
653 }

◆ SetBrightnessTo()

void EntityLightSource::SetBrightnessTo ( float value)
inlineprivate

Sets the brightness of the light.

Definition at line 231 of file ScriptedLightBase.c.

◆ SetDancingShadowsAmplitude()

void EntityLightSource::SetDancingShadowsAmplitude ( float max_deviation_in_meters)
inlineprivate

Sets the maximum range of the point light within the dancing shadows effect.

Definition at line 378 of file ScriptedLightBase.c.

References Math::AbsFloat().

◆ SetDancingShadowsMovementSpeed()

void EntityLightSource::SetDancingShadowsMovementSpeed ( float speed_in_meters_per_frame)
inlineprivate

Sets the maximum speed of the point light within the dancing shadows effect.

Definition at line 384 of file ScriptedLightBase.c.

References Math::AbsFloat().

◆ SetDisableShadowsWithinRadius()

void EntityLightSource::SetDisableShadowsWithinRadius ( float radius_in_m)
inlineprivate

When the light source gets within this radius (radius_in_m) around the camera, then it's shadows are disabled.

Definition at line 519 of file ScriptedLightBase.c.

◆ SetFadeOutTime()

void EntityLightSource::SetFadeOutTime ( float time_in_s)
inlineprivate

Sets the fade out time in seconds. Fade out begins automatically as the light nears the end of its life time, or when method FadeOut() is called.

Definition at line 307 of file ScriptedLightBase.c.

308 {
309 m_FadeOutTime = time_in_s * 1000;
310 }

◆ SetFlickerAmplitude()

void EntityLightSource::SetFlickerAmplitude ( float coef)
inlineprivate

Sets the change coefficient of flickering light. (0.0 - 1.0 values, result of greater values are period time of light off )

Definition at line 470 of file ScriptedLightBase.c.

References Math::AbsFloat().

◆ SetFlickerAmplitudeMax()

void EntityLightSource::SetFlickerAmplitudeMax ( float coef)
inlineprivate

Definition at line 476 of file ScriptedLightBase.c.

477 {
479 }

◆ SetFlickerAmplitudeMin()

void EntityLightSource::SetFlickerAmplitudeMin ( float coef)
inlineprivate

Definition at line 481 of file ScriptedLightBase.c.

482 {
484 }

◆ SetFlickerSpeed()

void EntityLightSource::SetFlickerSpeed ( float speed)
inlineprivate

Sets speed of light flickering (random brightness coefficient change per second)

Definition at line 464 of file ScriptedLightBase.c.

465 {
467 }

◆ SetLifetime()

void EntityLightSource::SetLifetime ( float life_in_s)
inlineprivate

Makes the light destroy itself after the given time in seconds. The light will fade out if it's set to do so with SetFadeOutTime(...)

Definition at line 300 of file ScriptedLightBase.c.

301 {
302 if (GetGame())
303 m_LifetimeEnd = GetGame().GetTime() + life_in_s * 1000;
304 }

References GetGame().

◆ SetRadiusTo()

void EntityLightSource::SetRadiusTo ( float value)
inlineprivate

Sets the radius of the light.

Definition at line 270 of file ScriptedLightBase.c.

271 {
272 m_Radius = value;
274 SetRadius(m_Radius);
275 }

References m_Radius.

◆ TryShadowOptimization()

void EntityLightSource::TryShadowOptimization ( )
inlineprivate

Optimizes shadows by disabling them on this light source while it's within the given radius around the camera.

Definition at line 505 of file ScriptedLightBase.c.

506 {
508 {
509 float distance_to_camera = vector.Distance(GetPosition(), GetGame().GetCurrentCameraPosition());
510
512 SetCastShadow(false);
513 else
514 SetCastShadow(true);
515 }
516 }
static proto native float Distance(vector v1, vector v2)
Returns the distance between tips of two 3D vectors.

References vector::Distance(), GetGame(), and GetPosition.

◆ UpdateLightMode()

void EntityLightSource::UpdateLightMode ( string slotName)
private

◆ UpdateMode()

void EntityLightSource::UpdateMode ( )
inlineprivate

Definition at line 79 of file ScriptedLightBase.c.

80 {
82 if (item)
83 {
85 item.GetInventory().GetCurrentInventoryLocation(il);
86 string slotName;
87 if (il.GetType() == InventoryLocationType.GROUND)
88 slotName = "Ground";
89 else if (il.GetSlot() != -1)
92 }
93 }
PlayerSpawnPreset slotName
InventoryLocationType
types of Inventory Location
void UpdateLightMode(string slotName)
InventoryLocation.
provides access to slot configuration
static proto native owned string GetSlotName(int id)
converts slot_id to string

References InventorySlots::GetSlotName(), m_Parent, and slotName.

Member Data Documentation

◆ m_BlinkingSpeed

float EntityLightSource::m_BlinkingSpeed
private

Definition at line 31 of file ScriptedLightBase.c.

◆ m_Brightness

float EntityLightSource::m_Brightness
private

Definition at line 18 of file ScriptedLightBase.c.

◆ m_BrightnessPulse

float EntityLightSource::m_BrightnessPulse
private

Definition at line 19 of file ScriptedLightBase.c.

◆ m_BrightnessPulseAmplitudeMax

float EntityLightSource::m_BrightnessPulseAmplitudeMax
private

Definition at line 21 of file ScriptedLightBase.c.

◆ m_BrightnessPulseAmplitudeMin

float EntityLightSource::m_BrightnessPulseAmplitudeMin
private

Definition at line 22 of file ScriptedLightBase.c.

◆ m_BrightnessPulseSpeed

float EntityLightSource::m_BrightnessPulseSpeed
private

Definition at line 20 of file ScriptedLightBase.c.

◆ m_BrightnessSpeedOfChange

float EntityLightSource::m_BrightnessSpeedOfChange = 1
private

Definition at line 24 of file ScriptedLightBase.c.

◆ m_BrightnessTarget

float EntityLightSource::m_BrightnessTarget
private

Definition at line 23 of file ScriptedLightBase.c.

◆ m_DancingShadowsAmplitude

float EntityLightSource::m_DancingShadowsAmplitude
private

Definition at line 28 of file ScriptedLightBase.c.

◆ m_DancingShadowsLocalPos

vector EntityLightSource::m_DancingShadowsLocalPos
private

Definition at line 38 of file ScriptedLightBase.c.

◆ m_DancingShadowsSpeed

float EntityLightSource::m_DancingShadowsSpeed
private

Definition at line 29 of file ScriptedLightBase.c.

◆ m_DeleteTimer

ref Timer EntityLightSource::m_DeleteTimer
private

Definition at line 40 of file ScriptedLightBase.c.

◆ m_FadeInTime

float EntityLightSource::m_FadeInTime = -1
private

Definition at line 15 of file ScriptedLightBase.c.

◆ m_FadeOutTime

float EntityLightSource::m_FadeOutTime = -1
private

Definition at line 14 of file ScriptedLightBase.c.

◆ m_IsDebugEnabled

bool EntityLightSource::m_IsDebugEnabled = false
private

Definition at line 33 of file ScriptedLightBase.c.

◆ m_LifetimeEnd

float EntityLightSource::m_LifetimeEnd = -1
private

Definition at line 13 of file ScriptedLightBase.c.

◆ m_LifetimeStart

float EntityLightSource::m_LifetimeStart
private

Definition at line 12 of file ScriptedLightBase.c.

◆ m_LocalOri

vector EntityLightSource::m_LocalOri
private

Definition at line 37 of file ScriptedLightBase.c.

◆ m_LocalPos

vector EntityLightSource::m_LocalPos
private

Definition at line 36 of file ScriptedLightBase.c.

◆ m_NightTimeOnlyLights

ref set<ScriptedLightBase> EntityLightSource::m_NightTimeOnlyLights = new set<ScriptedLightBase>()
staticprivate

Definition at line 42 of file ScriptedLightBase.c.

◆ m_OptimizeShadowsRadius

float EntityLightSource::m_OptimizeShadowsRadius = 0
private

Definition at line 26 of file ScriptedLightBase.c.

◆ m_Parent

Object EntityLightSource::m_Parent
private

Definition at line 35 of file ScriptedLightBase.c.

◆ m_Radius

float EntityLightSource::m_Radius
private

Definition at line 16 of file ScriptedLightBase.c.

◆ m_RadiusSpeedOfChange

float EntityLightSource::m_RadiusSpeedOfChange = 1
private

Definition at line 25 of file ScriptedLightBase.c.

◆ m_RadiusTarget

float EntityLightSource::m_RadiusTarget
private

Definition at line 17 of file ScriptedLightBase.c.


The documentation for this class was generated from the following file: