Exemple #1
0
        public void changeColourTest()
        {
            // new glower
            CompGlower myThingComp = new CompGlower();

            myThingComp.parent = this.parent;
            CompProperties_Glower compProps = new CompProperties_Glower();

            // color init
            curIndex = ((curIndex + 1) > 7) ? (0) : (curIndex + 1);
            newcolor = colors[curIndex];

            // setting props
            compProps.glowColor  = newcolor;
            compProps.glowRadius = glowRadius;
            // init
            myThingComp.Initialize(compProps);

            // applying to map
            Map     myMap = parent.Map;
            IntVec3 myPos = parent.Position;

            myMap.mapDrawer.MapMeshDirty(myPos, MapMeshFlag.Things);
            myMap.glowGrid.RegisterGlower(myThingComp);

            // removing old glow
            parent.AllComps.Remove(glowComp);
            myMap.glowGrid.DeRegisterGlower(glowComp);

            // remembering what you did last summer
            glowComp = myThingComp;
        }
 private void TurnLightsRed()
 {
     if (GlowerList == null)
     {
         GlowerList = new Dictionary <String, string>();
     }
     GlowerList.Clear();
     foreach (CompGlower glowerComp in
              from current in Map.listerThings.AllThings
              where current.TryGetComp <CompGlower>() != null && current.TryGetComp <CompPowerTrader>() != null
              select current.TryGetComp <CompGlower>())
     {
         CompProperties_Glower glower = glowerComp.Props;
         if (!GlowerList.ContainsKey(glowerComp.parent.ThingID))
         {
             if (glower.glowColor.ToColor != ColorLibrary.Red)
             {
                 GlowerList.Add(glowerComp.parent.ThingID, glower.glowColor.ToColor32.colorToHex());
                 glower.glowColor = ColorIntUtility.AsColorInt(ColorLibrary.Red);
             }
             Map.glowGrid.MarkGlowGridDirty(glowerComp.parent.Position);
         }
     }
     AlarmSound.PlayOneShotOnCamera();
 }
Exemple #3
0
        private void SetGlow(ColorInt glowColor, float glowRadius)
        {
            // new glower
            CompGlower myThingComp = new CompGlower();

            myThingComp.parent = parent;
            CompProperties_Glower compProps = new CompProperties_Glower
            {
                // setting props
                glowColor  = glowColor,
                glowRadius = glowRadius
            };

            // init
            myThingComp.Initialize(compProps);

            // applying to map
            Map     myMap = parent.Map;
            IntVec3 myPos = parent.Position;

            myMap.mapDrawer.MapMeshDirty(myPos, MapMeshFlag.Things);
            myMap.glowGrid.RegisterGlower(myThingComp);

            // removing old glow
            // AZAAAAARG
            UnsetGlow();

            // remembering what you did last summer
            glowComp = myThingComp;
        }
        // Replace the comp props with a new one with different values
        // must replace comp props as comps share props for things of the
        // same class.  We need to make a unique copy for the building.
        public void                         ChangeColor(ColorInt color)
        {
            // Get glower
            var glower = CompGlower;

            // New glower properties
            var newProps = new CompProperties_Glower();

            if (newProps == null)
            {
                CCL_Log.Error("CompColoredLight unable to create new CompProperties!", parent.def.defName);
                return;
            }

            // Set the new properties values
            newProps.compClass  = typeof(CompGlower);
            newProps.glowColor  = color;
            newProps.glowRadius = lightRadius;

            // Initialize comp with new properties
            glower.Initialize(newProps);

            // Update glow grid
            //glower.UpdateLit(); <-- Only works if the light changes state (on<->off)
            Find.GlowGrid.MarkGlowGridDirty(parent.Position);
        }
Exemple #5
0
        public void InstantiateGlow()
        {
            CompProperties compProps = DefDatabase <ThingDef> .GetNamed("CaveWell").CompDefFor <CompGlower>();

            if (compProps is CompProperties_Glower)
            {
                CompProperties_Glower glowerCompProps = (CompProperties_Glower)compProps;
                baseGlowColor.r = glowerCompProps.glowColor.r;
                baseGlowColor.g = glowerCompProps.glowColor.g;
                baseGlowColor.b = glowerCompProps.glowColor.b;

                glowRadiusCaveWellDay = glowerCompProps.glowRadius;
            }
        }
Exemple #6
0
        //provides a new Compglower
        public static CompGlower newCompGlower(ThingWithComps parent, ColorInt glowColour, float glowRadius)
        {
            CompGlower Comp_NewGlower = new CompGlower();

            Comp_NewGlower.parent = parent;


            //CompProperties CompProp_New = new CompProperties();


            CompProperties_Glower CompProp_New = new CompProperties_Glower();

            CompProp_New.compClass  = typeof(CompGlower);
            CompProp_New.glowColor  = glowColour;
            CompProp_New.glowRadius = glowRadius;

            Comp_NewGlower.Initialize(CompProp_New);

            return(Comp_NewGlower);
        }
Exemple #7
0
 public static void SelectedUpdate_Postfix(Designator_Place __instance)
 {
     if (!ArchitectCategoryTab.InfoRect.Contains(UI.MousePositionOnUIInverted))
     {
         ThingDef thingDef = __instance.PlacingDef as ThingDef;
         if (thingDef?.defName != null)
         {
             if (thingDef.HasComp(typeof(CompGlower)) && thingDef.selectable)
             {
                 CompProperties_Glower glowerProps = thingDef.GetCompProperties <CompProperties_Glower>();
                 if (LightRadiusSettings.innerLight)
                 {
                     GenDraw.DrawRadiusRing(UI.MouseCell(), glowerProps.glowRadius * 0.91f - 2f);
                 }
                 if (LightRadiusSettings.outerLight)
                 {
                     GenDraw.DrawRadiusRing(UI.MouseCell(), glowerProps.glowRadius * 0.91f - 0.5f);
                 }
             }
         }
     }
 }
Exemple #8
0
        // Replace the comp props with a new one with different values
        // must replace comp props as comps share props for things of the
        // same class.  We need to make a unique copy for the building.
        public void ChangeColor( ColorInt color )
        {
            // Get glower
            var glower = CompGlower;

            // New glower properties
            var newProps = new CompProperties_Glower();
            if( newProps == null )
            {
                CCL_Log.Error( "CompColoredLight unable to create new CompProperties!", parent.def.defName );
                return;
            }

            // Set the new properties values
            newProps.compClass = typeof( CompGlower );
            newProps.glowColor = color;
            newProps.glowRadius = lightRadius;

            // Initialize comp with new properties
            glower.Initialize( newProps );

            // Update glow grid
            //glower.UpdateLit(); <-- Only works if the light changes state (on<->off)
            Find.GlowGrid.MarkGlowGridDirty( parent.Position );
        }