Beispiel #1
0
        public override void TryEmptySlot(SlotLoadable slot)
        {
            //Log.Message("1");
            if (parent is ThingWithComps compOwner)
            {
                //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", MessageTypeDefOf.RejectInput);
                            return;
                        }
                    }
                }
            }

            base.TryEmptySlot(slot);
        }
Beispiel #2
0
        //public static void Remove_PostFix(Pawn_EquipmentTracker __instance, ThingWithComps eq)
        //{
        //    CompLightsaberActivatableEffect lightsaberEffect = eq.TryGetComp<CompLightsaberActivatableEffect>();
        //    if (lightsaberEffect != null)
        //    {

        //    }
        //}

        public static void CrystalSlotter(CompCrystalSlotLoadable crystalSlot, CompLightsaberActivatableEffect lightsaberEffect)
        { //
            crystalSlot.Initialize();
            List <string> randomCrystals = new List <string>()
            {
                "PJ_KyberCrystal",
                "PJ_KyberCrystalBlue",
                "PJ_KyberCrystalCyan",
                "PJ_KyberCrystalAzure",
                "PJ_KyberCrystalRed",
                "PJ_KyberCrystalPurple",
            };
            ThingWithComps thingWithComps = (ThingWithComps)ThingMaker.MakeThing(ThingDef.Named(randomCrystals.RandomElement <string>()), null);

            Log.Message(thingWithComps.Label);
            foreach (SlotLoadable slot in crystalSlot.Slots)
            {
                slot.TryLoadSlot(thingWithComps);
            }
            lightsaberEffect.TryActivate();
        }
Beispiel #3
0
        //public static void Remove_PostFix(Pawn_EquipmentTracker __instance, ThingWithComps eq)
        //{
        //    CompLightsaberActivatableEffect lightsaberEffect = eq.TryGetComp<CompLightsaberActivatableEffect>();
        //    if (lightsaberEffect != null)
        //    {

        //    }
        //}

        public static void AddEquipment_PostFix(Pawn_EquipmentTracker __instance, ThingWithComps newEq)
        {
            Pawn pawn = (Pawn)AccessTools.Field(typeof(Pawn_EquipmentTracker), "pawn").GetValue(__instance);

            CompLightsaberActivatableEffect lightsaberEffect = newEq.TryGetComp <CompLightsaberActivatableEffect>();

            if (lightsaberEffect != null)
            {
                if (pawn != null)
                {
                    if (pawn.Faction != Faction.OfPlayer)
                    {
                        Log.Message("1");
                        CompCrystalSlotLoadable crystalSlot = newEq.GetComp <CompCrystalSlotLoadable>();
                        if (crystalSlot != null)
                        {
                            crystalSlot.Initialize();
                            Log.Message("2");
                            List <string> randomCrystals = new List <string>()
                            {
                                "PJ_KyberCrystal",
                                "PJ_KyberCrystalBlue",
                                "PJ_KyberCrystalCyan",
                                "PJ_KyberCrystalAzure",
                                "PJ_KyberCrystalRed",
                                "PJ_KyberCrystalPurple",
                            };
                            ThingWithComps thingWithComps = (ThingWithComps)ThingMaker.MakeThing(ThingDef.Named(randomCrystals.RandomElement <string>()), null);
                            Log.Message(thingWithComps.Label);
                            foreach (SlotLoadable slot in crystalSlot.Slots)
                            {
                                Log.Message("3");
                                slot.TryLoadSlot(thingWithComps);
                            }
                            lightsaberEffect.Activate();
                        }
                    }
                }
            }
        }
Beispiel #4
0
        public static void AddEquipment_PostFix(Pawn_EquipmentTracker __instance, ThingWithComps newEq)
        {
            Pawn pawn = (Pawn)AccessTools.Field(typeof(Pawn_EquipmentTracker), "pawn").GetValue(__instance);

            CompLightsaberActivatableEffect lightsaberEffect = newEq.TryGetComp <CompLightsaberActivatableEffect>();

            if (lightsaberEffect != null)
            {
                if (pawn != null)
                {
                    if (pawn.Faction != null)
                    {
                        if (pawn.Faction != Faction.OfPlayerSilentFail)
                        {
                            CompCrystalSlotLoadable crystalSlot = newEq.GetComp <CompCrystalSlotLoadable>();
                            if (crystalSlot != null)
                            {
                                CrystalSlotter(crystalSlot, lightsaberEffect);
                            }
                        }
                    }
                }
            }
        }