Beispiel #1
0
 public void CopyFrom(RadiationInfo other)
 {
     chamberDef = other.chamberDef;
     pawn       = other.pawn;
     part       = other.part;
     secondHand = other.secondHand;
     visited    = other.visited;
 }
Beispiel #2
0
 public void Modify(ref RadiationInfo info)
 {
     if (info.part != null && enabledParts.Contains(info.part) && Rand.Range(0.0f, 1.0f) < props.blockChance)
     {
         info.burn   = 0;
         info.normal = 0;
         info.rare   = 0;
     }
 }
Beispiel #3
0
        public void Modify(ref RadiationInfo info)
        {
            CompFilterOperationMode m = Mode;

            if (m == null)
            {
                return;
            }

            m.Modify(ref info);
        }
Beispiel #4
0
 public override void Modify(ref RadiationInfo info)
 {
     if (info.rare * multiplier < info.normal)
     {
         info.normal -= info.rare * multiplier;
         info.rare    = 0;
     }
     else
     {
         info.normal = 0;
         info.rare  -= info.normal / multiplier;
     }
 }
Beispiel #5
0
 public override void Modify(ref RadiationInfo info)
 {
     if (info.rare * multiplier < info.burn)
     {
         info.burn -= info.rare * multiplier;
         info.rare  = 0;
     }
     else
     {
         info.burn  = 0;
         info.rare -= info.burn / multiplier;
     }
 }
Beispiel #6
0
        public void Irradiate(Pawn pawn, int ticksCooldown)
        {
            radiationTracker.Clear();
            foreach (CompIrradiator comp in GetIrradiators())
            {
                RadiationInfo info = new RadiationInfo {
                    chamber = this, pawn = pawn, part = null
                };
                comp.Irradiate(info, ticksCooldown);

                radiationTracker.burn   += info.burn;
                radiationTracker.normal += info.normal;
                radiationTracker.rare   += info.rare;
            }
        }
Beispiel #7
0
        public override void CreateRadiation(RadiationInfo fullInfo, int ticks)
        {
            foreach (CompIrradiator comp in GetIrradiators().InRandomOrder())
            {
                RadiationInfo info = new RadiationInfo();
                info.CopyFrom(fullInfo);
                comp.Irradiate(parent as Building, info, ticks);
                if (info.Empty())
                {
                    continue;
                }

                moteProps = comp.MoteProps;

                fullInfo.Add(info);
            }
        }
Beispiel #8
0
        public void Irradiate(Building target, RadiationInfo info, int ticks)
        {
            if (info.visited.Contains(this))
            {
                return;
            }
            info.visited.Add(this);

            linked = target;
            if (linked == null)
            {
                return;
            }

            CreateRadiation(info, ticks);
            if (info.Empty())
            {
                return;
            }

            ticksCooldown = ticks;
            bool playSound = props.soundIrradiate != null && info.visited.Count(x => x.props.soundIrradiate != null) < 2;

            soundSustainer = playSound ? props.soundIrradiate.TrySpawnSustainer(SoundInfo.InMap(parent, MaintenanceType.PerTick)) : null;

            motesReflectAt.Clear();
            foreach (ThingComp comp in GetModifiers <ThingComp, IRadiationModifier>(linked))
            {
                if (comp is CompBlocker)
                {
                    motesReflectAt.Add((Rotation().IsHorizontal ? comp.parent.Position.x : comp.parent.Position.z) + 0.5f);
                }

                if (info.secondHand)
                {
                    continue;
                }

                IRadiationModifier modifier = comp as IRadiationModifier;
                modifier.Modify(ref info);
            }
        }
Beispiel #9
0
        public void Irradiate(Pawn pawn, int ticksCooldown)
        {
            this.ticksCooldown = ticksCooldown;
            currentUser        = pawn;

            radiationTracker.Clear();

            Room room       = Position.GetRoom(Map);
            Pawn actualPawn = Map.mapPawns.AllPawns.Where(x => x.GetRoom() == room).RandomElementWithFallback(pawn);

            foreach (CompIrradiator comp in GetIrradiators())
            {
                RadiationInfo info = new RadiationInfo {
                    chamberDef = def, pawn = actualPawn, part = GetBodyPart(actualPawn), secondHand = actualPawn != pawn, visited = new HashSet <CompIrradiator>()
                };
                comp.Irradiate(this, info, ticksCooldown);
                radiationTracker.burn   += info.burn;
                radiationTracker.normal += info.normal;
                radiationTracker.rare   += info.rare;

                if (actualPawn.IsShielded())
                {
                    continue;
                }

                HediffRadiation radiation = RadiationHelper.GetHediffRadition(info.part, info.pawn);
                if (radiation == null)
                {
                    continue;
                }

                radiation.burn   += info.burn;
                radiation.normal += info.normal;
                radiation.rare   += info.rare;

                ApplyBurn(actualPawn, radiation);
                ApplyMutation(actualPawn, radiation);
            }
        }
Beispiel #10
0
        public void Irradiate(Pawn pawn, int ticksCooldown)
        {
            this.ticksCooldown = ticksCooldown;
            currentUser        = pawn;

            radiationTracker.Clear();

            Room room       = Position.GetRoom(Map);
            Pawn actualPawn = Map.mapPawns.AllPawns.Where(x => x.GetRoom() == room).RandomElementWithFallback(pawn);

            foreach (CompIrradiator comp in GetIrradiators())
            {
                RadiationInfo info = new RadiationInfo {
                    chamber = this, pawn = actualPawn, part = null, secondHand = actualPawn != pawn
                };
                comp.Irradiate(info, ticksCooldown);

                radiationTracker.burn   += info.burn;
                radiationTracker.normal += info.normal;
                radiationTracker.rare   += info.rare;
            }
        }
Beispiel #11
0
        public void Irradiate(RadiationInfo info, int ticks)
        {
            Chamber chamber = parent.Linked <Chamber>();

            SoundDefOf.RadiologyIrradiateBasic.PlayOneShot(new TargetInfo(parent.Position, parent.Map, false));
            ticksCooldown = ticks;

            if (info.pawn.IsShielded())
            {
                return;
            }

            info.part   = GetBodyPart(info.chamber, info.pawn);
            info.burn   = props.burn.perSecond.RandomInRange;
            info.normal = props.mutate.perSecond.RandomInRange;
            info.rare   = props.mutateRare.perSecond.RandomInRange;
            if (info.secondHand)
            {
                info.rare /= 2;
            }

            motesReflectAt.Clear();
            foreach (ThingComp comp in GetModifiers <ThingComp, IRadiationModifier>(info.chamber))
            {
                if (comp is CompBlocker)
                {
                    motesReflectAt.Add((parent.Rotation.IsHorizontal ? comp.parent.Position.x : comp.parent.Position.z) + 0.5f);
                }

                if (info.secondHand)
                {
                    continue;
                }

                IRadiationModifier modifier = comp as IRadiationModifier;
                modifier.Modify(ref info);
            }

            if (info.burn <= 0 && info.normal <= 0 && info.rare <= 0)
            {
                return;
            }

            HediffRadiation radiation = GetHediffRadition(info.part, info.chamber, info.pawn);

            if (radiation == null)
            {
                return;
            }

            radiation.burn   += info.burn;
            radiation.normal += info.normal;
            radiation.rare   += info.rare;

            float burnThreshold = info.chamber.def.burnThreshold.RandomInRange;
            float burnAmount    = radiation.burn - burnThreshold;

            if (burnAmount > 0)
            {
                radiation.burn -= info.chamber.def.burnThreshold.min;

                DamageInfo dinfo = new DamageInfo(DamageDefOf.Burn, burnAmount * props.burn.multiplier, 999999f, -1f, info.chamber, radiation.Part, null, DamageInfo.SourceCategory.ThingOrUnknown, null);
                info.pawn.TakeDamage(dinfo);

                if (chamber != null)
                {
                    RadiologyEffectSpawnerDef.Spawn(chamber.def.burnEffect, info.pawn);
                }
            }

            float mutateThreshold = info.chamber.def.mutateThreshold.RandomInRange;
            float mutateAmount    = radiation.normal + radiation.rare - mutateThreshold;

            if (mutateAmount > 0)
            {
                float ratio = radiation.rare / (radiation.normal + radiation.rare);
                radiation.rare   -= info.chamber.def.mutateThreshold.min * ratio;
                radiation.normal -= info.chamber.def.mutateThreshold.min * (1f - ratio);

                Mutation mutation;
                var      mutatedParts = RadiationHelper.MutatePawn(info.pawn, radiation, mutateAmount * props.mutate.multiplier, ratio, out mutation);
                if (mutatedParts != null)
                {
                    foreach (var anotherRadiation in info.pawn.health.hediffSet.GetHediffs <HediffRadiation>())
                    {
                        if (mutatedParts.Contains(anotherRadiation.Part) && radiation != anotherRadiation)
                        {
                            anotherRadiation.normal -= info.chamber.def.mutateThreshold.min * (1f - ratio);
                            anotherRadiation.rare   -= info.chamber.def.mutateThreshold.min * ratio;
                        }
                    }
                }
            }
        }
Beispiel #12
0
 public override void Modify(ref RadiationInfo info)
 {
     info.normal *= 0.7f;
 }
Beispiel #13
0
 public override void Modify(ref RadiationInfo info)
 {
     info.burn   *= 0.6f;
     info.normal *= 0.8f;
     info.rare   *= 0.8f;
 }
Beispiel #14
0
 public virtual void Modify(ref RadiationInfo info)
 {
     throw new NotImplementedException();
 }
Beispiel #15
0
 public virtual void CreateRadiation(RadiationInfo info, int ticks)
 {
     info.burn   = props.burn.perSecond.RandomInRange;
     info.normal = props.mutate.perSecond.RandomInRange;
     info.rare   = props.mutateRare.perSecond.RandomInRange;
 }
Beispiel #16
0
 public void Add(RadiationInfo info)
 {
     burn   += info.burn;
     normal += info.normal;
     rare   += info.rare;
 }