public override void TryEmptySlot(SlotLoadable slot)
        {
            Log.Message("1");
            ThingWithComps compOwner = this.parent as ThingWithComps;

            if (compOwner != null)
            {
                Log.Message("2");

                CompLightsaberActivatableEffect compLightsaberActivatableEffect = compOwner.TryGetComp <CompLightsaberActivatableEffect>();
                if (compLightsaberActivatableEffect != null)
                {
                    Log.Message("3");

                    if (compLightsaberActivatableEffect.IsActive())
                    {
                        Log.Message("4");

                        if (!compLightsaberActivatableEffect.TryDeactivate())
                        {
                            Log.Message("5");

                            Messages.Message("DeactivateLightsaberFirst", MessageSound.RejectInput);
                            return;
                        }
                    }
                }
            }

            base.TryEmptySlot(slot);
        }
 public override Graphic PostGraphicEffects(Graphic graphic)
 {
     if (graphic != null)
     {
         ThingComp comp = this.parent.AllComps.FirstOrDefault((ThingComp x) => x is CompSlotLoadable.CompSlotLoadable);
         if (comp != null)
         {
             CompSlotLoadable.CompSlotLoadable compSlotLoadable = comp as CompSlotLoadable.CompSlotLoadable;
             SlotLoadable colorSlot = compSlotLoadable.Slots.FirstOrDefault((SlotLoadable x) => ((SlotLoadableDef)x.def).doesChangeColor == true);
             if (colorSlot != null)
             {
                 if (colorSlot.SlotOccupant != null)
                 {
                     if (graphic.Shader != null)
                     {
                         Graphic result = graphic.GetColoredVersion(graphic.Shader, colorSlot.SlotOccupant.DrawColor, colorSlot.SlotOccupant.DrawColorTwo);
                         if (result != null)
                         {
                             return(result);
                         }
                     }
                 }
             }
         }
     }
     return(base.PostGraphicEffects(graphic));
 }
Example #3
0
        public override void TryEmptySlot(SlotLoadable slot)
        {
            //Log.Message("1");
            if (parent is { } compOwner)
            {
                //Log.Message("2");

                var compLightsaberActivatableEffect = compOwner.TryGetComp <CompLightsaberActivatableEffect>();
                if (compLightsaberActivatableEffect != null)
                {
                    //Log.Message("3");

                    if (compLightsaberActivatableEffect.IsActive())
                    {
                        //Log.Message("4");

                        if (!compLightsaberActivatableEffect.TryDeactivate())
                        {
                            //Log.Message("5");

                            Messages.Message("DeactivateLightsaberFirst", MessageTypeDefOf.RejectInput);
                            return;
                        }
                    }
                }
            }

            base.TryEmptySlot(slot);
        }
        public override void ActiveTick()
        {
            //Log.Message("1");
            ThingComp comp = this.parent.AllComps.FirstOrDefault((ThingComp x) => x is CompSlotLoadable.CompSlotLoadable);

            if (comp != null)
            {
                //Log.Message("2");
                CompSlotLoadable.CompSlotLoadable compSlotLoadable = comp as CompSlotLoadable.CompSlotLoadable;
                SlotLoadable colorSlot = compSlotLoadable.Slots.FirstOrDefault((SlotLoadable x) => ((SlotLoadableDef)x.def).doesChangeColor == true);
                if (colorSlot != null)
                {
                    //Log.Message("3");
                    if (colorSlot.IsEmpty())
                    {
                        this.Deactivate();
                    }
                }
            }
        }
        public override bool CanActivate()
        {
            //Log.Message("1");
            ThingComp comp = this.parent.AllComps.FirstOrDefault((ThingComp x) => x is CompSlotLoadable.CompSlotLoadable);

            if (comp != null)
            {
                //Log.Message("2");
                CompSlotLoadable.CompSlotLoadable compSlotLoadable = comp as CompSlotLoadable.CompSlotLoadable;
                SlotLoadable colorSlot = compSlotLoadable.Slots.FirstOrDefault((SlotLoadable x) => ((SlotLoadableDef)x.def).doesChangeColor == true);
                if (colorSlot != null)
                {
                    //Log.Message("3");
                    if (colorSlot.SlotOccupant != null)
                    {
                        return(true);
                    }
                }//
            }
            Messages.Message("KyberCrystalRequired".Translate(), MessageSound.RejectInput);
            return(false);
        }