Exemplo n.º 1
0
        public bool CanGetBlood(BloodType other)
        {
            if (other == null)
            {
                return(true);
            }
            var expressed      = ExpressedBloodType();
            var otherExpressed = other.ExpressedBloodType();

            if (RhExpressed() == Rh.Neg)
            {
                if (other.RhExpressed() == Rh.Pos)
                {
                    return(false);
                }
            }

            if (otherExpressed == ExpressedBloodTypes.O)
            {
                return(true);
            }

            if (expressed == ExpressedBloodTypes.AB)
            {
                return(true);
            }

            return(expressed == otherExpressed);
        }
Exemplo n.º 2
0
 public BloodType Child(BloodType other = null)
 {
     if (other == null)
     {
         other = Random();
     }
     return(new BloodType()
     {
         Primary = new [] { other.Primary, this.Primary }.RandomElement(),
         Secondary = new [] { other.Secondary, this.Primary }.RandomElement(),
         RhPrimary = new [] { other.RhPrimary, this.RhPrimary }.RandomElement(),
         RhSecondary = new [] { other.RhSecondary, this.RhSecondary }.RandomElement()
     });
 }
        public static void GenerateBloodType(Pawn pawn)
        {
            if (PawnHelper.IsHaveHediff(pawn, HediffDefOf.BloodType))
            {
                return;
            }

            bool      moreThanOne = false;
            BloodType current     = null;
            var       parents     = pawn.relations.DirectRelations.Where(x => x.def == PawnRelationDefOf.Parent);

            foreach (var relation in parents)
            {
                var bloodDiff = relation.otherPawn.GetBloodType();
                if (bloodDiff?.BloodType == null)
                {
                    continue;
                }
                if (current == null)
                {
                    current = bloodDiff.BloodType;
                }
                else
                {
                    moreThanOne = true;
                    current     = current.Child(bloodDiff.BloodType);
                }
            }

            if (current == null)
            {
                current = BloodType.Random();
            }
            else if (!moreThanOne)
            {
                current = current.Child();
            }


            AddBloodType(pawn, current);
        }
Exemplo n.º 4
0
 public bool Equals(BloodType other) => ExpressedBloodType().Equals(other.ExpressedBloodType()) && RhExpressed().Equals(other.RhExpressed());
        private static void AddBloodType(Pawn pawn, BloodType current)
        {
            var myDef = (BloodTypeHediffWithComps)pawn.health.AddHediff(HediffDefOf.BloodType);

            myDef.BloodType = current;
        }