Exemplo n.º 1
0
        static void Prefix(PawnRenderer __instance, ref Vector3 rootLoc, ref float angle, ref bool renderBody, ref Rot4 bodyFacing, ref Rot4 headFacing, ref RotDrawMode bodyDrawType, ref bool portrait, ref bool headStump, ref bool invisible)
        {
            if (invisible)
            {
                return;
            }
            Pawn pawn = Traverse.Create(__instance).Field("pawn").GetValue <Pawn>();

            if (pawn != null)
            {
                Comp_Markable markable = pawn.TryGetComp <Comp_Markable>();
                if (markable != null)
                {
                    Hediff hd = pawn.health.hediffSet.hediffs.Find(x => x.TryGetComp <HediffComp_HunterMark>() != null);
                    if (hd != null)
                    {
                        HediffComp_HunterMark comp = hd.TryGetComp <HediffComp_HunterMark>();
                        if (comp.BloodStatus > HMSUtility.BloodStatusMode.Unblooded)
                        {
                            if (comp != null && comp.hasMat && !portrait)
                            {
                                DrawMark(comp, __instance, rootLoc, angle, renderBody, bodyFacing, headFacing, bodyDrawType, portrait, headStump);
                            }
                        }
                    }
                }
            }
        }
Exemplo n.º 2
0
        public override void DoEffect(Pawn user)
        {
            //    base.DoEffect(user);
            if (user.Markable(out Comp_Markable Markable))
            {
                BodyPartRecord part = Markable.partRecord;
                if (user.Marked(out Hediff marked, out Hediff blooded))
                {
                    //    Log.Message(string.Format("Removing hediff {0}", marked));
                    user.health.RemoveHediff(marked);
                }
                if (blooded != null)
                {
                    user.health.RemoveHediff(blooded);
                    //    Log.Message(string.Format("Removing hediff {0}", marked));
                }
                corpse = (Corpse)this.parent;
                marked = HediffMaker.MakeHediff(Markable.markDataKillNew.MarkDef, user, part);// user.health.hediffSet.GetFirstHediffOfDef(markedDef);
                HediffComp_HunterMark marked_Yautja = marked.TryGetComp <HediffComp_HunterMark>();
                Markable.Mark = corpse.InnerPawn;
                user.health.AddHediff(marked, part);
                ThingDef thingDef = null;
                foreach (var item in corpse.InnerPawn.health.hediffSet.GetNotMissingParts())
                {
                    TrophyPartDefExtension trophyDef = null;
                    if (item.def.HasModExtension <TrophyPartDefExtension>())
                    {
                        trophyDef = item.def.GetModExtension <TrophyPartDefExtension>();
                    }
                    if (trophyDef != null)
                    {
                        float    basechance = trophyDef.TrophyChance;
                        ThingDef trophy     = trophyDef.TrophyDef ?? item.def.spawnThingOnRemoved;
                        if (trophyDef.PartHealthModifier)
                        {
                            basechance = basechance * corpse.InnerPawn.health.hediffSet.GetPartHealth(item);
                        }
                        if (trophy != null)
                        {
                            if (Rand.Chance(basechance))
                            {
                                partRecord = item;
                                thingDef   = trophy;
                                corpse.InnerPawn.health.AddHediff(HediffMaker.MakeHediff(HediffDefOf.MissingBodyPart, corpse.InnerPawn, this.partRecord));
                                GenSpawn.Spawn(ThingMaker.MakeThing(thingDef), user.Position, user.Map);
                            }
                        }
                    }
                }
                if (user.story.adulthood.identifier == null || user.story.adulthood.identifier == "RRY_Yautja_YoungBlood")
                {
                    if (marked.def == HMSDefOf.HMS_Hediff_BloodedMXenomorph)
                    {
                        AlienRace.BackstoryDef backstoryDef = DefDatabase <AlienRace.BackstoryDef> .GetNamed("RRY_Yautja_Blooded");

                        user.story.adulthood = backstoryDef.backstory;
                    }
                }
                Markable.markDataKill = Markable.markDataKillNew;
                if (this.parent.IsForbidden(user))
                {
                    this.parent.SetForbidden(false);
                }

                if (user.Markable(out Comp_Markable markable))
                {
                    markable.markcorpse = null;
                    markable.Mark       = null;
                }
            }
        }
Exemplo n.º 3
0
        static void DrawMark(HediffComp_HunterMark comp, PawnRenderer __instance, Vector3 rootLoc, float angle, bool renderBody, Rot4 bodyFacing, Rot4 headFacing, RotDrawMode bodyDrawType, bool portrait, bool headStump)
        {
            Pawn    pawn      = Traverse.Create(__instance).Field("pawn").GetValue <Pawn>();
            bool    selected  = Find.Selector.SelectedObjects.Contains(pawn) && Prefs.DevMode;
            Rot4    rot       = bodyFacing;
            Vector3 vector3   = pawn.RaceProps.Humanlike ? __instance.BaseHeadOffsetAt(headFacing) : new Vector3();
            Vector3 s         = new Vector3(pawn.BodySize * 1.75f, pawn.BodySize * 1.75f, pawn.BodySize * 1.75f);
            bool    hasdefext = pawn.def.HasModExtension <MarkOffsetDefExtension>();

            if (hasdefext)
            {
                MarkOffsetDefExtension defExtension = pawn.def.GetModExtension <MarkOffsetDefExtension>() ?? ThingDefOf.Human.GetModExtension <MarkOffsetDefExtension>();
                if (defExtension != null)
                {
                    GetAltitudeOffset(pawn, defExtension, comp.parent, rot, out float X, out float Y, out float Z, out float DsX, out float DsZ, out float ang);
                    vector3.x += X;
                    vector3.y += Y;
                    vector3.z += Z;
                    angle     += ang;
                    s.x        = DsX;
                    s.z        = DsZ;
                }
            }
            else
            {
                if (pawn.RaceProps.Humanlike)
                {
                    vector3.z += 0.25f;
                }
            }
            if (pawn.RaceProps.Humanlike)
            {
                vector3.x += 0.01f;
                vector3.z += -0.35f;
            }
            Quaternion quaternion = Quaternion.AngleAxis(angle, Vector3.up);
            Vector3    b          = quaternion * vector3;
            Vector3    vector     = rootLoc;
            Vector3    a          = rootLoc;

            if (bodyFacing != Rot4.North)
            {
                a.y      += 0.02734375f;
                vector.y += 0.0234375f;
            }
            else
            {
                a.y      += 0.0234375f;
                vector.y += 0.02734375f;
            }
            Vector3 loc2 = rootLoc + b;

            loc2.y += 0.03105f;
            bool flag = false;

            if (!flag && bodyDrawType != RotDrawMode.Dessicated)
            {
                //    Mesh mesh4 = __instance.graphics.HairMeshSet.MeshAt(headFacing);
                Material mat = comp.ImplantMaterial(pawn, pawn.RaceProps.Humanlike ? headFacing : bodyFacing);
                //    GenDraw.DrawMeshNowOrLater(headFacing == Rot4.West ? MeshPool.plane10Flip : MeshPool.plane10, loc2, quaternion, mat, true);
                Matrix4x4 matrix = default(Matrix4x4);
                matrix.SetTRS(loc2, quaternion, s);
                Graphics.DrawMesh((pawn.RaceProps.Humanlike ? headFacing : bodyFacing) == Rot4.West ? MeshPool.plane10Flip : MeshPool.plane10, matrix, mat, 0);
            }
        }