Пример #1
0
 public static LightStyle.Mod Lerp(LightStyle.Mod a, LightStyle.Mod b, float t, Mask mask)
 {
     b.mask &= mask;
     if (b.mask != 0)
     {
         a.mask &= mask;
         if (a.mask == 0)
         {
             return(b);
         }
         Mask mask2 = a.mask & b.mask;
         if (mask2 != 0)
         {
             float num = 1f - t;
             if (mask != 0)
             {
                 for (Element element = Element.Red; element < (Element.SpotAngle | Element.Green); element += 1)
                 {
                     if ((mask2 & ElementToMask(element)) == ElementToMask(element))
                     {
                         float faceValue = a.GetFaceValue(element);
                         float num3      = b.GetFaceValue(element);
                         float num4      = (faceValue * num) + (num3 * t);
                         a.SetFaceValue(element, num4);
                     }
                 }
             }
         }
         if (mask2 != a.mask)
         {
             a |= b;
         }
     }
     return(a);
 }
Пример #2
0
 public void BindToLight(Light light, LightStyle.Mod.Mask mask)
 {
     if (mask != (LightStyle.Mod.Mask.Red | LightStyle.Mod.Mask.Green | LightStyle.Mod.Mask.Blue | LightStyle.Mod.Mask.Alpha | LightStyle.Mod.Mask.Intensity | LightStyle.Mod.Mask.Range | LightStyle.Mod.Mask.SpotAngle))
     {
         if (this.destroyed)
         {
             return;
         }
         this.UpdateBinding();
         if ((this.mod.mask & mask) == this.mod.mask)
         {
             this.mod.ApplyTo(light);
         }
         else
         {
             LightStyle.Mod mod = this.mod;
             mod.mask = mod.mask & mask;
             mod.ApplyTo(light);
         }
     }
     else
     {
         this.BindToLight(light);
     }
 }
Пример #3
0
 public LightStyle.Mod BindMod(LightStyle.Mod.Mask mask)
 {
     if (!this.destroyed)
     {
         this.UpdateBinding();
     }
     LightStyle.Mod mod = this.mod;
     mod.mask = mod.mask & mask;
     return(mod);
 }
Пример #4
0
 public static LightStyle.Mod operator *(LightStyle.Mod a, float b)
 {
     LightStyle.Mod mod = a;
     for (LightStyle.Mod.Element i = LightStyle.Mod.Element.Red; i < (LightStyle.Mod.Element.Green | LightStyle.Mod.Element.Blue | LightStyle.Mod.Element.Alpha | LightStyle.Mod.Element.Intensity | LightStyle.Mod.Element.Range | LightStyle.Mod.Element.SpotAngle); i = (LightStyle.Mod.Element)((int)i + (int)LightStyle.Mod.Element.Green))
     {
         if ((a.mask & LightStyle.Mod.ElementToMask(i)) == LightStyle.Mod.ElementToMask(i))
         {
             mod.SetFaceValue(i, a.GetFaceValue(i) * b);
         }
     }
     return(mod);
 }
Пример #5
0
        public static LightStyle.Mod operator +(LightStyle.Mod a, LightStyle.Mod b)
        {
            LightStyle.Mod mod  = a;
            Mask           mask = a.mask & b.mask;

            for (Element element = Element.Red; element < (Element.SpotAngle | Element.Green); element += 1)
            {
                if ((mask & ElementToMask(element)) == ElementToMask(element))
                {
                    mod.SetFaceValue(element, a.GetFaceValue(element) + b.GetFaceValue(element));
                }
            }
            return(mod);
        }
Пример #6
0
 public static LightStyle.Mod Lerp(LightStyle.Mod a, LightStyle.Mod b, float t, LightStyle.Mod.Mask mask)
 {
     b.mask = b.mask & mask;
     if ((int)b.mask == 0)
     {
         return(a);
     }
     a.mask = a.mask & mask;
     if ((int)a.mask == 0)
     {
         return(b);
     }
     LightStyle.Mod.Mask mask1 = a.mask & b.mask;
     if ((int)mask1 != 0)
     {
         float single = 1f - t;
         if ((int)mask != 0)
         {
             for (LightStyle.Mod.Element i = LightStyle.Mod.Element.Red; i < (LightStyle.Mod.Element.Green | LightStyle.Mod.Element.Blue | LightStyle.Mod.Element.Alpha | LightStyle.Mod.Element.Intensity | LightStyle.Mod.Element.Range | LightStyle.Mod.Element.SpotAngle); i = (LightStyle.Mod.Element)((int)i + (int)LightStyle.Mod.Element.Green))
             {
                 if ((mask1 & LightStyle.Mod.ElementToMask(i)) == LightStyle.Mod.ElementToMask(i))
                 {
                     float faceValue  = a.GetFaceValue(i);
                     float faceValue1 = b.GetFaceValue(i);
                     float single1    = faceValue * single + faceValue1 * t;
                     a.SetFaceValue(i, single1);
                 }
             }
         }
     }
     if (mask1 != a.mask)
     {
         a = a | b;
     }
     return(a);
 }
Пример #7
0
    protected void LateUpdate()
    {
        float num;

        LightStyle.Mod mod;
        if (this.crossfadeThisFrame != null)
        {
            this.crossfadeNextFrame = this.crossfadeThisFrame;
            this.crossfadeThisFrame = null;
        }
        else if ((this.crossfadeNextFrame != null) && !this.CrossFade(this.crossfadeNextFrame, this.crossfadeLength))
        {
            this.crossfadeNextFrame = this.crossfadeThisFrame;
            this.crossfadeThisFrame = null;
        }
        float num2 = this.CalculateSumWeight(true, out num);

        if (num2 == 0f)
        {
            while (this.clipsInSortingArray > 0)
            {
                this.sortingArray[--this.clipsInSortingArray] = null;
            }
            if (this._lightStyle == null)
            {
                return;
            }
            mod = this.simulationIdle.BindMod(this._mask);
        }
        else
        {
            int count = this.clips.Count;
            if (this.clipsInSortingArray != count)
            {
                if (this.clipsInSortingArray > count)
                {
                    while (this.clipsInSortingArray > count)
                    {
                        this.sortingArray[--this.clipsInSortingArray] = null;
                    }
                }
                else if ((this.sortingArray == null) || (this.sortingArray.Length < count))
                {
                    Array.Resize <Clip>(ref this.sortingArray, ((count / 4) + (((count % 4) != 0) ? 1 : 2)) * 4);
                }
            }
            int num4 = 0;
            foreach (Clip clip in this.clips.Values)
            {
                if (clip.weight > 0f)
                {
                    this.sortingArray[num4++] = clip;
                }
            }
            if (this.clipsInSortingArray < num4)
            {
                this.clipsInSortingArray = num4;
            }
            else
            {
                while (this.clipsInSortingArray > num4)
                {
                    this.sortingArray[--this.clipsInSortingArray] = null;
                }
            }
            Array.Sort <Clip>(this.sortingArray, 0, this.clipsInSortingArray);
            float weight = this.sortingArray[0].weight;
            mod = this.sortingArray[0].simulation.BindMod(this._mask);
            for (int i = 1; i < this.clipsInSortingArray; i++)
            {
                Clip clip2 = this.sortingArray[i];
                weight += clip2.weight;
                mod     = LightStyle.Mod.Lerp(mod, clip2.simulation.BindMod(this._mask), clip2.weight / weight, this._mask);
            }
            if (this._lightStyle != null)
            {
                LightStyle.Mod b = this.simulationIdle.BindMod(this._mask);
                if (num2 < 1f)
                {
                    mod = LightStyle.Mod.Lerp(mod, b, 1f - num2, this._mask);
                }
                else
                {
                    mod |= b;
                }
            }
        }
        foreach (Light light in this.lights)
        {
            if (light != null)
            {
                mod.ApplyTo(light, this._mask);
            }
        }
    }
Пример #8
0
    protected void LateUpdate()
    {
        float single;

        LightStyle.Mod mod;
        int            num;

        if (this.crossfadeThisFrame)
        {
            this.crossfadeNextFrame = this.crossfadeThisFrame;
            this.crossfadeThisFrame = null;
        }
        else if (this.crossfadeNextFrame && !this.CrossFade(this.crossfadeNextFrame, this.crossfadeLength))
        {
            this.crossfadeNextFrame = this.crossfadeThisFrame;
            this.crossfadeThisFrame = null;
        }
        float single1 = this.CalculateSumWeight(true, out single);

        if (single1 != 0f)
        {
            int count = this.clips.Count;
            if (this.clipsInSortingArray != count)
            {
                if (this.clipsInSortingArray > count)
                {
                    while (this.clipsInSortingArray > count)
                    {
                        LightStylist lightStylist = this;
                        int          num1         = lightStylist.clipsInSortingArray - 1;
                        num = num1;
                        lightStylist.clipsInSortingArray = num1;
                        this.sortingArray[num]           = null;
                    }
                }
                else if (this.sortingArray == null || (int)this.sortingArray.Length < count)
                {
                    int num2 = count / 4;
                    Array.Resize <LightStylist.Clip>(ref this.sortingArray, (num2 + (count % 4 != 0 ? 1 : 2)) * 4);
                }
            }
            int num3 = 0;
            foreach (LightStylist.Clip value in this.clips.Values)
            {
                if (value.weight <= 0f)
                {
                    continue;
                }
                int num4 = num3;
                num3 = num4 + 1;
                this.sortingArray[num4] = value;
            }
            if (this.clipsInSortingArray >= num3)
            {
                while (this.clipsInSortingArray > num3)
                {
                    LightStylist lightStylist1 = this;
                    int          num5          = lightStylist1.clipsInSortingArray - 1;
                    num = num5;
                    lightStylist1.clipsInSortingArray = num5;
                    this.sortingArray[num]            = null;
                }
            }
            else
            {
                this.clipsInSortingArray = num3;
            }
            Array.Sort <LightStylist.Clip>(this.sortingArray, 0, this.clipsInSortingArray);
            float single2 = this.sortingArray[0].weight;
            mod = this.sortingArray[0].simulation.BindMod(this._mask);
            for (int i = 1; i < this.clipsInSortingArray; i++)
            {
                LightStylist.Clip clip = this.sortingArray[i];
                single2 = single2 + clip.weight;
                mod     = LightStyle.Mod.Lerp(mod, clip.simulation.BindMod(this._mask), clip.weight / single2, this._mask);
            }
            if (this._lightStyle)
            {
                LightStyle.Mod mod1 = this.simulationIdle.BindMod(this._mask);
                mod = (single1 >= 1f ? mod | mod1 : LightStyle.Mod.Lerp(mod, mod1, 1f - single1, this._mask));
            }
        }
        else
        {
            while (this.clipsInSortingArray > 0)
            {
                LightStylist lightStylist2 = this;
                int          num6          = lightStylist2.clipsInSortingArray - 1;
                num = num6;
                lightStylist2.clipsInSortingArray = num6;
                this.sortingArray[num]            = null;
            }
            if (!this._lightStyle)
            {
                return;
            }
            mod = this.simulationIdle.BindMod(this._mask);
        }
        Light[] lightArray = this.lights;
        for (int j = 0; j < (int)lightArray.Length; j++)
        {
            Light light = lightArray[j];
            if (light)
            {
                mod.ApplyTo(light, this._mask);
            }
        }
    }
Пример #9
0
 public void ToggleModify(LightStyle.Mod.Element element)
 {
     LightStyle.Mod mask = this;
     mask.mask = mask.mask ^ LightStyle.Mod.ElementToMask(element);
 }
Пример #10
0
 public void SetModify(LightStyle.Mod.Element element, float assignValue)
 {
     this.SetFaceValue(element, assignValue);
     LightStyle.Mod mask = this;
     mask.mask = mask.mask | LightStyle.Mod.ElementToMask(element);
 }
Пример #11
0
 public void SetModify(LightStyle.Mod.Element element)
 {
     LightStyle.Mod mask = this;
     mask.mask = mask.mask | LightStyle.Mod.ElementToMask(element);
 }
Пример #12
0
 public void ClearModify(LightStyle.Mod.Element element)
 {
     LightStyle.Mod maskNot = this;
     maskNot.mask = maskNot.mask & LightStyle.Mod.ElementToMaskNot(element);
 }