13 float m_LifetimeEnd = -1;
14 float m_FadeOutTime = -1;
15 float m_FadeInTime = -1;
24 float m_BrightnessSpeedOfChange = 1;
25 float m_RadiusSpeedOfChange = 1;
26 float m_OptimizeShadowsRadius = 0;
33 bool m_IsDebugEnabled =
false;
47 m_LifetimeStart =
GetGame().GetTime();
55 if (m_NightTimeOnlyLights)
57 int index = m_NightTimeOnlyLights.Find(
this);
59 m_NightTimeOnlyLights.Remove(
index);
65 if (!IsVisibleDuringDaylight())
69 SetVisibleDuringDaylight(
true);
70 m_NightTimeOnlyLights.Insert(
this);
85 item.GetInventory().GetCurrentInventoryLocation(
il);
89 else if (
il.GetSlot() != -1)
139 parent.AddChild(
this, -1);
166 ErrorEx(
"memory point 'memory_point_target' not found when attaching light");
172 ErrorEx(
"memory point 'memory_point_start' not found when attaching light");
183 if (!
m_Parent.ToDelete() && !ToDelete())
214 Error(
"Error! Light entity of name " +
name.ToString() +
" cannot be spawned! This name is incorrect or not inherited from ScriptedLightBase.");
224 Error(
"An instance of ScriptedLightBase was attempted to spawn on server side! Lights are CLIENT SIDE ONLY!");
233 m_Brightness =
value;
234 m_BrightnessTarget =
value;
235 SetBrightness(m_Brightness * m_BrightnessPulse);
236 CorrectLightPulseDuringDaylight();
242 if (m_Brightness < 100)
244 float v = m_Brightness * 0.01;
261 m_BrightnessTarget =
value;
264 m_BrightnessSpeedOfChange = 9999;
273 m_RadiusTarget =
value;
280 m_RadiusTarget =
value;
283 m_RadiusSpeedOfChange = 9999;
294 DeleteLightWithDelay();
370 CheckIfParentIsInCargo();
371 TryShadowOptimization();
392 return m_DancingShadowsAmplitude;
398 return m_DancingShadowsSpeed;
404 m_IsDebugEnabled =
state;
410 if (m_DancingShadowsAmplitude > 0)
412 for (
int i = 0;
i < 3;
i++)
414 m_DancingShadowsLocalPos[
i] = m_DancingShadowsLocalPos[
i] + (
Math.
RandomFloat(-m_DancingShadowsSpeed, m_DancingShadowsSpeed) *
timeSlice) ;
416 if (m_DancingShadowsLocalPos[
i] > m_DancingShadowsAmplitude)
417 m_DancingShadowsLocalPos[
i] = m_DancingShadowsAmplitude;
419 if (m_DancingShadowsLocalPos[
i] < -m_DancingShadowsAmplitude)
420 m_DancingShadowsLocalPos[
i] = -m_DancingShadowsAmplitude;
435 if (m_IsDebugEnabled)
442 m_DancingShadowsLocalPos =
Vector(0, 0, 0);
448 if (m_BrightnessPulseAmplitudeMax > 0)
452 if (m_BrightnessPulse < m_BrightnessPulseAmplitudeMin + 1)
453 m_BrightnessPulse = m_BrightnessPulseAmplitudeMin + 1;
455 if (m_BrightnessPulse > m_BrightnessPulseAmplitudeMax + 1)
456 m_BrightnessPulse = m_BrightnessPulseAmplitudeMax + 1;
460 m_BrightnessPulse = 1;
466 m_BrightnessPulseSpeed = speed;
478 m_BrightnessPulseAmplitudeMax = coef;
483 m_BrightnessPulseAmplitudeMin = coef;
489 return m_BrightnessPulseSpeed;
495 return m_BrightnessPulseAmplitudeMax;
501 return m_BrightnessPulseAmplitudeMin;
507 if (m_OptimizeShadowsRadius > 0)
512 SetCastShadow(
false);
527 return m_OptimizeShadowsRadius;
566 if (
current_time > m_LifetimeEnd && m_LifetimeEnd != -1)
579 if (m_FadeOutTime != -1 && m_LifetimeEnd != -1 &&
current_time > m_LifetimeEnd - m_FadeOutTime)
592 if (m_Brightness != m_BrightnessTarget)
604 if (m_Brightness > 0 || m_BrightnessTarget > 0)
606 SetBrightness(m_Brightness * m_BrightnessPulse);
607 CorrectLightPulseDuringDaylight();
617 SetBrightness(m_Brightness * m_BrightnessPulse);
618 CorrectLightPulseDuringDaylight();
637 if (
m_Radius > 0 || m_RadiusTarget > 0)
658 return m_BlinkingSpeed;
664 if (m_BlinkingSpeed <= 0)
PlayerSpawnPresetDiscreteItemSetSlotData name
one set for cargo
PlayerSpawnPreset slotName
vector m_LocalPos
Cached local pos.
vector m_LocalOri
Local orientation set by SetAttachedLocalOri, only used by EffectParticle.
InventoryLocationType
types of Inventory Location
void ParticleManager(ParticleManagerSettings settings)
Constructor (ctor)
void SetEnabled()
prevents insider adding in the wrong position, HOTFIX
class JsonUndergroundAreaTriggerData GetPosition
void HandleBrightnessFadeing(float timeSlice)
float m_BrightnessPulseSpeed
Object GetAttachmentParent()
Returns attachment parent.
void HandleBlinking(float time)
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...
void FadeIn(float time_in_s)
Makes the light fade into existence. Works only at the moment the light is created....
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 li...
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 OnFra...
void ~ScriptedLightBase()
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 SetBrightnessTo(float value)
Sets the brightness of the light.
void DeleteLightWithDelay()
Correct way of deleting light from memory. It is necesarry to have this delay due to hierarchy.
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 ma...
override bool IsScriptedLight()
void SetDancingShadowsMovementSpeed(float speed_in_meters_per_frame)
Sets the maximum speed of the point light within the dancing shadows effect.
float GetDisableShadowsWithinRadius()
Returns the range you put inside SetDisableShadowsWithinRadius(...)
float GetBlinkingSpeed()
Returns the speed of blinks.
float m_BrightnessPulseAmplitudeMax
void HandleDancingShadows(float time, float timeSlice)
void SetBlinkingSpeed(float _speed)
Sets blinking speed (no blinking if speed <= 0)
void AddLifetime(float life_in_s)
Prolongs the lifetime of the light in seconds. Use negative number to shorten its lifetime.
void Destroy()
Switches off the light and deletes it from memory.
void SetDancingShadowsAmplitude(float max_deviation_in_meters)
Sets the maximum range of the point light within the dancing shadows effect.
void CheckIfParentIsInCargo()
void DetachFromParent()
Detaches this light from its parent entity.
void ScriptedLightBase()
Constructor. Everything here is executed before the constructor of all children.
float GetFlickerAmplitudeCoefMin()
Returns flicker amplitude minimum.
void SetFlickerSpeed(float speed)
Sets speed of light flickering (random brightness coefficient change per second)
void SetFlickerAmplitudeMax(float coef)
override void EOnInit(IEntity other, int extra)
float GetDancingShadowsAmplitude()
Returns max movement range of pointlight within the dancing shadow effect.
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.
float GetDancingShadowsMovementSpeed()
Returns max movement speed of pointlight within the dancing shadow effect.
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.
vector m_DancingShadowsLocalPos
float GetFlickerSpeed()
Returns flicker speed.
void CorrectLightPulseDuringDaylight()
Call this after using SetBrightness(...) to fix light's intensity during daytime.
void SetFlickerAmplitude(float coef)
Sets the change coefficient of flickering light. (0.0 - 1.0 values, result of greater values are peri...
float GetFlickerAmplitudeCoefMax()
Returns flicker amplitude maximum.
void HandleFlickering(float time, float timeSlice)
void SetRadiusTo(float value)
Sets the radius of the light.
void FadeOut(float time_in_s=-1)
Starts the fade out process and destroys the light when its done. Optional parameter allows you to se...
void FadeBrightnessTo(float value, float time_in_s)
Fades the brightness of the light to the given value.
void SetFlickerAmplitudeMin(float coef)
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 ...
void OnFrameLightSource(IEntity other, float timeSlice)
Override this for custom functionality.
void FadeRadiusTo(float value, float time_in_s)
Fades the radius of the light to the given value.
float m_BrightnessPulseAmplitudeMin
void EnableDebug(bool state)
Enables some debug functionality of this light.
void CheckFadeOut(int current_time)
float m_DancingShadowsSpeed
void UpdateLightMode(string slotName)
bool CheckLifetime(int current_time)
float m_DancingShadowsAmplitude
script counterpart to engine's class Inventory
provides access to slot configuration
static proto native owned string GetSlotName(int id)
converts slot_id to string
Legacy way of using particles in the game.
static const int DEBUG_DOT
static vector Direction(vector p1, vector p2)
Returns direction vector from point p1 to point p2.
static proto native float Distance(vector v1, vector v2)
Returns the distance between tips of two 3D vectors.
proto native CGame GetGame()
void Error(string err)
Messagebox with error message.
proto native void SetPosition(vector position)
Set the world position of the Effect.
proto native void Destroy()
Cleans up the Effect, including unregistering if needed.
EntityEvent
Entity events for event-mask, or throwing event from code.
proto native vector Vector(float x, float y, float z)
Vector constructor from components.
static proto float Round(float f)
Returns mathematical round of value.
static proto float RandomFloat(float min, float max)
Returns a random float number between and min[inclusive] and max[exclusive].
static proto float Sin(float angle)
Returns sinus of angle in radians.
static proto float AbsFloat(float f)
Returns absolute value.