コード例 #1
0
        protected override IEnumerable <Toil> MakeNewToils()
        {
            //this.FailOnDespawnedNullOrForbidden(TargetIndex.A);
            this.FailOn(delegate
            {
                return(pawn == Victim);
            });
            this.FailOn(delegate
            {
                return(BloodMaster.CurBloodPoints == 0);
            });
            this.FailOnAggroMentalState(TargetIndex.A);

            yield return(Toils_Reserve.Reserve(TargetIndex.A));

            var  newDomitor = GetActor();
            var  toil       = newDomitor?.Faction == TargetA.Thing?.Faction ? Toils_Goto.GotoThing(TargetIndex.A, PathEndMode.ClosestTouch) : Toils_Goto.GotoThing(TargetIndex.A, PathEndMode.Touch);
            Toil gotoToil   = toil;

            yield return(gotoToil);

            Toil grappleToil = new Toil()
            {
                initAction = delegate
                {
                    MoteMaker.MakeColonistActionOverlay(newDomitor, ThingDefOf.Mote_ColonistAttacking);

                    workLeft = BaseFeedTime;
                    Pawn victim = TargetA.Thing as Pawn;
                    if (victim != null)
                    {
                        if (newDomitor.InAggroMentalState || victim.InAggroMentalState || victim.Faction != newDomitor.Faction)
                        {
                            int grappleBonus = newDomitor is PawnTemporary ? 100 : 0;
                            if (!JecsTools.GrappleUtility.TryGrapple(newDomitor, victim, grappleBonus))
                            {
                                this.EndJobWith(JobCondition.Incompletable);
                                PawnUtility.ForceWait(newDomitor, (int)(BaseFeedTime * 0.15f));
                                return;
                            }
                        }
                        if (newDomitor.IsVampire())
                        {
                            //VampireBiteUtility.MakeNew(GetActor(), GetActor()); //Actor opens their own wound.
                            victim.stances.stunner.StunFor((int)BaseFeedTime, newDomitor);
                        }
                    }
                }
            };

            yield return(grappleToil);

            Toil feedToil = new Toil()
            {
                tickAction = delegate
                {
                    //try
                    //{
                    if (TargetA.Thing is Pawn victim && victim.Spawned && !victim.Dead)
                    {
                        workLeft--;
                        VampireWitnessUtility.HandleWitnessesOf(this.job.def, newDomitor, victim);
//                            if (victim?.needs?.mood?.thoughts?.memories != null)
//                            {
//                                var victimThoughtDef = VampDefOf.ROMV_IDrankVitae;
//                                Thought_Memory victimThought = null;
//                                if (victimThoughtDef != null) victimThought = (Thought_Memory)ThoughtMaker.MakeThought(victimThoughtDef);
//                                if (victimThought != null)
//                                {
//                                    victim.needs.mood.thoughts.memories.TryGainMemory(victimThought);
//                                }
//                            }
                        if (workLeft <= 0f)
                        {
                            if (newDomitor?.VampComp() is CompVampire v && v.IsVampire && newDomitor.Faction == Faction.OfPlayer)
                            {
                                MoteMaker.ThrowText(newDomitor.DrawPos, newDomitor.Map, "XP +" + 15);
                                v.XP += 15;
                            }
                            workLeft = BaseFeedTime;
                            MoteMaker.MakeColonistActionOverlay(newDomitor, ThingDefOf.Mote_ColonistAttacking);

                            if (!victim.IsGhoul())
                            {
                                CompThrall.InitializeGhoul(newDomitor);
                            }
                            else
                            {
                                CompThrall.ThrallData.TryAdjustBondStage(newDomitor, 1);
                            }
                            BloodMaster.TransferBloodTo(1, BloodThrall, true, true);
                            GhoulUtility.GiveVitaeEffects(victim, newDomitor);
                            //VampireBiteUtility.CleanBite(GetActor(), GetActor());
                            this.ReadyForNextToil();
                        }
                    }
コード例 #2
0
        // RimWorld.CharacterCardUtility
        public static void DrawVampCard(Rect rect, Pawn pawn)
        {
            AdjustForLanguage();

            GUI.BeginGroup(rect);


            CompVampire compVampire = pawn.GetComp <CompVampire>();

            if (compVampire != null && (compVampire.IsVampire || compVampire.IsGhoul))
            {
                Rect rect7 = new Rect(CharacterCardUtility.BasePawnCardSize.x - 105f, 0f, 30f, 30f);
                TooltipHandler.TipRegion(rect7, new TipSignal("ROMV_CharacterSheet".Translate()));
                if (Widgets.ButtonImage(rect7, TexButton.ROMV_HumanIcon))
                {
                    HarmonyPatches.isSwitched = false;
                }

                if (compVampire.IsVampire)
                {
                    Rect rectVampOptions = new Rect(CharacterCardUtility.BasePawnCardSize.x - 105f, 150f, 30f, 30f);
                    switch (compVampire.CurrentSunlightPolicy)
                    {
                    case SunlightPolicy.Relaxed:
                        TooltipHandler.TipRegion(rectVampOptions, new TipSignal("ROMV_SP_Relaxed".Translate()));
                        if (Widgets.ButtonImage(rectVampOptions, TexButton.ROMV_SunlightPolicyRelaxed))
                        {
                            compVampire.CurrentSunlightPolicy = SunlightPolicy.Restricted;
                        }
                        break;

                    case SunlightPolicy.Restricted:
                        TooltipHandler.TipRegion(rectVampOptions, new TipSignal("ROMV_SP_Restricted".Translate()));
                        if (Widgets.ButtonImage(rectVampOptions, TexButton.ROMV_SunlightPolicyRestricted))
                        {
                            compVampire.CurrentSunlightPolicy = SunlightPolicy.NoAI;
                        }
                        break;

                    case SunlightPolicy.NoAI:
                        TooltipHandler.TipRegion(rectVampOptions, new TipSignal("ROMV_SP_NoAI".Translate()));
                        if (Widgets.ButtonImage(rectVampOptions, TexButton.ROMV_SunlightPolicyNoAI))
                        {
                            compVampire.CurrentSunlightPolicy = SunlightPolicy.Relaxed;
                        }
                        break;
                    }
                }

                NameTriple nameTriple      = pawn.Name as NameTriple;
                Rect       rectSkillsLabel = new Rect(rect.xMin, rect.yMin - 15, rect.width, HeaderSize);

                Text.Font = GameFont.Medium;
                Widgets.Label(rectSkillsLabel, pawn.Name.ToStringFull);
                Text.Font = GameFont.Small;
                string label    = (compVampire.IsGhoul) ? GhoulUtility.MainDesc(pawn)  : VampireUtility.MainDesc(pawn);
                Rect   rectDesc = new Rect(0f, 45f, rect.width, 60f);
                Widgets.Label(rectDesc, label);

                //                               Skills

                //Widgets.DrawLineHorizontal(rect.x - 10, rectSkillsLabel.yMax + Padding, rect.width - 15f);
                //---------------------------------------------------------------------

                Rect rectSkills   = new Rect(rect.x, rectDesc.yMax - 42 + Padding, rectSkillsLabel.width, SkillsColumnHeight);
                Rect rectInfoPane = new Rect(rectSkills.x, rectSkills.y + Padding, rect.width * 0.9f, SkillsColumnHeight);

                //Rect rectSkillsPane = new Rect(rectSkills.x + SkillsColumnDivider, rectSkills.y + Padding, rectSkills.width - SkillsColumnDivider, SkillsColumnHeight);

                LevelPane(rectInfoPane, compVampire);
                //InfoPane(rectSkillsPane, compVampire);

                // LEVEL ________________             |
                // ||||||||||||||||||||||             |
                // Points Available 1                 |
                //

                float powersTextSize  = Text.CalcSize("ROMV_Disciplines".Translate()).x;
                Rect  rectPowersLabel = new Rect((rect.width / 2 - powersTextSize / 2) - 15f, rectSkills.yMax + SectionOffset - 5, rect.width, HeaderSize);
                Text.Font = GameFont.Medium;
                Widgets.Label(rectPowersLabel, "ROMV_Disciplines".Translate().CapitalizeFirst());
                //                                   Disciplines
                Text.Font = GameFont.Small;

                //Powers

                Widgets.DrawLineHorizontal(rect.x - 10, rectPowersLabel.yMax, rect.width - 15f);
                //---------------------------------------------------------------------
                float curY    = rectPowersLabel.yMax;
                var   outRect = new Rect(rect.x, curY + 3f, rect.width, (rectSkills.height * 4f) + 16f);
                //rectSkills.width -= 10f;
                var   viewRect    = new Rect(rect.x, curY + 3f, rect.width, scrollViewHeight);//rectSkills.height * 4f);
                float scrollViewY = 0f;
                Widgets.BeginScrollView(outRect, ref scrollPosition, viewRect, true);
                if (compVampire.Sheet.Pawn == null)
                {
                    compVampire.Sheet.Pawn = pawn;
                }
                if (compVampire.Sheet.Disciplines.NullOrEmpty())
                {
                    compVampire.Sheet.InitializeDisciplines();
                }
                for (int i = 0; i < compVampire.Sheet.Disciplines.Count; i++)
                {
                    Rect rectDisciplines = new Rect(rect.x, curY, rectPowersLabel.width, ButtonSize + Padding);
                    PowersGUIHandler(rectDisciplines, compVampire, compVampire.Sheet.Disciplines[i]);
                    var y = ButtonSize + Padding * 2 + TextSize * 2;
                    curY        += y;
                    scrollViewY += y;
                }
                if (Event.current.type == EventType.Layout)
                {
                    scrollViewHeight = scrollViewY + (ButtonSize + Padding * 2 + TextSize * 2) + 30f;
                }
                Widgets.EndScrollView();
            }
            GUI.EndGroup();
        }