Ludeon Forums

RimWorld => Mods => Help => Topic started by: mrofa on April 27, 2014, 10:57:56 AM

Title: Set_Lit light problems
Post by: mrofa on April 27, 2014, 10:57:56 AM
Im kinda stuck on light problem cant get it to lit , i always get this error " 'CompGlower.Lit.set': cannot explicitly call operator or accessor ". Im new to c# soo what did i miss this time :D ?

using System;
using System.Collections.Generic;
using System.Linq;
using System.Text;
using UnityEngine;

namespace PowerGenerator
{
    public class Building_Plasma : Building
     {
        private int time = 80;
        private int phase = 0;
        private CompGlower glowerComp;
        private CompPowerTrader powerComp;
        private static readonly SoundDef SoundBurn = SoundDef.Named("PowerOn");

        public override void SpawnSetup()
        {
            base.SpawnSetup();

            this.powerComp = base.GetComp<CompPowerTrader>();
            this.glowerComp = base.GetComp<CompGlower>();
           
           
           
           
           

        }
        public override void TickRare()   
        {
           base.TickRare();
           this.time --;

           if (this.time <= 80 && this.time >= 77 && this.phase == 0)
           {
               this.powerComp.powerOutput = -30f;
               this.phase = 1;
           }
           if (this.time <= 45 && this.time >= 42 && this.phase == 1)
            {
                this.powerComp.powerOutput = -10f;
                this.phase = 2;
            }
           else if (this.time <= 20 && this.time >= 17 && this.phase == 2)
            {
                this.powerComp.powerOutput = 0f;
                this.phase = 3;
            }
           else if (this.time <= 8 && this.time >= 5 && this.phase == 3)
            {
               
                this.powerComp.powerOutput = 100000f;
                this.phase = 4;
                this.glowerComp.set_Lit = true;
            }
           else if (this.time <= 1 && this.phase == 4)
            {
                this.glowerComp.set_Lit = false;
                this.time = 80;
                this.phase = 0;
            }
               
        }
    }
}
Title: Re: Set_Lit light problems
Post by: pawnstorm on April 27, 2014, 11:14:33 AM
try this.glowerComp.Lit instead of this.glowerComp.set_Lit
Title: Re: Set_Lit light problems
Post by: mrofa on April 27, 2014, 11:29:23 AM
Wow it worked thanks !
Do you know maybe if i can change the light settings like a color in the code ?
Title: Re: Set_Lit light problems
Post by: pawnstorm on April 27, 2014, 11:35:47 AM
I have no idea, but the GlowFlooder class seems to have a function that takes a colour as an argument (AddFloodGlowFor)
Title: Re: Set_Lit light problems
Post by: Architect on April 27, 2014, 02:59:10 PM
Quote from: mrofa on April 27, 2014, 11:29:23 AM
Wow it worked thanks !
Do you know maybe if i can change the light settings like a color in the code ?

If you can I'd surely like to know, its been the biggest pain in my ass for the longest of times with my emergency lighting stuff XD
Title: Re: Set_Lit light problems
Post by: Haplo on April 27, 2014, 04:33:44 PM
You can overwrite the glower def. That way the glower will always have your colors.
BUT if you do that, EVERY glower of that type will be changed as you overwrite the base definition with this.
E.g. every standing light has the color red if you overwrite the def of the standing light glower.


public override void SpawnSetup()
...
glower.def.glowColor = new ColorInt(255,0,0,255); // Red


Normally it's easier and less problematic to just set the color via XML.
Title: Re: Set_Lit light problems
Post by: Architect on April 27, 2014, 04:45:09 PM
Quote from: Haplo on April 27, 2014, 04:33:44 PM
You can overwrite the glower def. That way the glower will always have your colors.
BUT if you do that, EVERY glower of that type will be changed as you overwrite the base definition with this.
E.g. every standing light has the color red if you overwrite the def of the standing light glower.


public override void SpawnSetup()
...
glower.def.glowColor = new ColorInt(255,0,0,255); // Red


Normally it's easier and less problematic to just set the color via XML.

Actually, for me this is perfect to change all instances :D
Title: Re: Set_Lit light problems
Post by: Haplo on April 27, 2014, 04:52:00 PM
Honestly, I've never tried, what happends when you change the def on one thing only. It should change every instance of the glower, but I'm unsure about glowers already glowing. They should change their color instantly, but if the calculation is done with changes only, it may be that only one changes, even if the def is changed.
If you do it, can you tell us how it goes?
I'm a bit curious too ;)
Title: Re: Set_Lit light problems
Post by: Architect on April 27, 2014, 04:57:20 PM
Quote from: Haplo on April 27, 2014, 04:52:00 PM
Honestly, I've never tried, what happends when you change the def on one thing only. It should change every instance of the glower, but I'm unsure about glowers already glowing. They should change their color instantly, but if the calculation is done with changes only, it may be that only one changes, even if the def is changed.
If you do it, can you tell us how it goes?
I'm a bit curious too ;)

My to do list is a bit long, and I dont think reworking the emergency lighting is until about half way down it. However as soon as I do it, you'll know about it :P
Title: Re: Set_Lit light problems
Post by: Haplo on April 27, 2014, 04:58:52 PM
Fair enough ;)
I'll await your find patiently. 8)
Title: Re: Set_Lit light problems
Post by: mrofa on April 27, 2014, 04:59:46 PM
Quote from: Haplo on April 27, 2014, 04:33:44 PM
You can overwrite the glower def. That way the glower will always have your colors.
BUT if you do that, EVERY glower of that type will be changed as you overwrite the base definition with this.
E.g. every standing light has the color red if you overwrite the def of the standing light glower.


public override void SpawnSetup()
...
glower.def.glowColor = new ColorInt(255,0,0,255); // Red


Normally it's easier and less problematic to just set the color via XML.

That works perfect thanks alot !
Title: Re: Set_Lit light problems
Post by: Haplo on April 27, 2014, 05:02:34 PM
No problem, glad I could help. :)
Title: Re: Set_Lit light problems
Post by: Architect on April 27, 2014, 05:04:38 PM
Whats the fourth number there for? I never know, its R,G,B,? to me XD
Title: Re: Set_Lit light problems
Post by: Haplo on April 27, 2014, 05:11:01 PM
It is the alpha channel.
255 is fully visible, while 0 is invisible. Or something like that. :)
Title: Re: Set_Lit light problems
Post by: Architect on April 27, 2014, 05:18:17 PM
I see. I always just leave it at 0 in my light stuff :/
Title: Re: Set_Lit light problems
Post by: Tynan on April 27, 2014, 05:20:54 PM
Alpha isn't used in lighting calculations. But it's part of a standard 32-bit color value.

And yes, I'm sorry that, for now, light color is fixed in the def and not dynamically modifiable. I didn't really design for much in the way of dynamic lighting, though I have ways to do it in mind now.
Title: Re: Set_Lit light problems
Post by: mrofa on April 27, 2014, 05:31:11 PM
So i should start making disco floor :D
Title: Re: Set_Lit light problems
Post by: Cala13er on April 27, 2014, 05:35:34 PM
Quote from: mrofa on April 27, 2014, 05:31:11 PM
So i should start making disco floor :D

Please do ;)
Title: Re: Set_Lit light problems
Post by: pawnstorm on April 27, 2014, 09:47:10 PM
1. Make disco floor
2. Make all your colonists dance by putting them on fire
3. Capture it
4. Add the song I will survive by Gloria Gaynor to it and upload to youtube
5. ???
6. PROFIT!!!