Add LightOffset property to allow light sources to origin from locations other than the object center.

shapetextures
Sven Eberhardt 2015-09-16 21:13:00 -04:00
parent 267737cab0
commit b683e47499
4 changed files with 21 additions and 1 deletions

View File

@ -24,6 +24,7 @@
</params>
</syntax>
<desc>Sets the light reach of the object. When a clonk is added to the crew via <funclink>MakeCrewMember</funclink>, a light is added automatically with the default range of 300 and a fadeout of 80.</desc>
<remark>A local offset for the light center can be defined by setting the object property LightRange to an array with two elements for X- and Y-offset respectively.</remark>
<examples>
<example>
<code>func ControlUse(object clonk)
@ -34,6 +35,15 @@
}</code>
<text>Confused the acid phile with the eye drops, did ya?</text>
</example>
<example>
<code>func Construction()
{
SetLightRange(100, 100);
this.LightRange = [0,-100];
return true;
}</code>
<text>Script for a lamp post. A light coming from 100 pixel above the object center is enabled when the object is created.</text>
</example>
</examples>
<related>
<funclink>SetPlrView</funclink>

View File

@ -96,8 +96,16 @@ void C4FoWLight::SetColor(uint32_t iValue)
void C4FoWLight::Update(C4Rect Rec)
{
// Update position from object. Clear if we moved in any way
// Update position from object.
int32_t iNX = fixtoi(pObj->fix_x), iNY = fixtoi(pObj->fix_y);
// position may be affected by LightOffset property
C4ValueArray *light_offset = pObj->GetPropertyArray(P_LightOffset);
if (light_offset)
{
iNX += light_offset->GetItem(0).getInt();
iNY += light_offset->GetItem(1).getInt();
}
// Clear if we moved in any way
if (iNX != iX || iNY != iY)
{
for(size_t i = 0; i < sections.size(); ++i )

View File

@ -236,6 +236,7 @@ C4StringTable::C4StringTable()
P[P_Equalizer_Mid2_Width] = "Equalizer_Mid2_Width";
P[P_Equalizer_High_Gain] = "Equalizer_High_Gain";
P[P_Equalizer_High_Cutoff] = "Equalizer_High_Cutoff";
P[P_LightOffset] = "LightOffset";
P[DFA_WALK] = "WALK";
P[DFA_FLIGHT] = "FLIGHT";
P[DFA_KNEEL] = "KNEEL";

View File

@ -438,6 +438,7 @@ enum C4PropertyName
P_Equalizer_Mid2_Width,
P_Equalizer_High_Gain,
P_Equalizer_High_Cutoff,
P_LightOffset,
// Default Action Procedures
DFA_WALK,
DFA_FLIGHT,