// Copied from PawnRenderer
        private Rot4 LayingFacing()
        {
            if (Wearer == null)
            {
                return(Rot4.Random);
            }
            if (Wearer.GetPosture() == PawnPosture.LayingOnGroundFaceUp)
            {
                return(Rot4.South);
            }
            if (Wearer.RaceProps.Humanlike)
            {
                switch (Wearer.thingIDNumber % 4)
                {
                case 0:
                    return(Rot4.South);

                case 1:
                    return(Rot4.South);

                case 2:
                    return(Rot4.East);

                case 3:
                    return(Rot4.West);
                }
            }
            else
            {
                switch (Wearer.thingIDNumber % 4)
                {
                case 0:
                    return(Rot4.South);

                case 1:
                    return(Rot4.East);

                case 2:
                    return(Rot4.West);

                case 3:
                    return(Rot4.West);
                }
            }
            return(Rot4.Random);
        }
Пример #2
0
        // Token: 0x06000023 RID: 35 RVA: 0x000029F0 File Offset: 0x00000BF0
        public override void Tick()
        {
            base.Tick();
            if (JPCooldownTicks > 0)
            {
                JPCooldownTicks--;
            }

            if (Settings.AllowSlowBurn)
            {
                if (Wearer == null)
                {
                    JPSlowBurn = false;
                    return;
                }

                if (!JPSlowBurn || !Wearer.Spawned || Wearer.GetPosture() == PawnPosture.LayingInBed ||
                    Wearer.GetPosture() == PawnPosture.LayingOnGroundFaceUp ||
                    Wearer.GetPosture() == PawnPosture.LayingOnGroundNormal)
                {
                    return;
                }

                if (JPSlowBurnTicks > 0)
                {
                    JPSlowBurnTicks--;
                    return;
                }

                if (JPFuelAmount > 0)
                {
                    JPFuelAmount--;
                    JPSlowBurnTicks = JPUtility.GetSlowBurnTicks(JPFuelItem);
                    return;
                }

                JPSlowBurn = false;
                Messages.Message(
                    "JetPack.SBOutOfFuel".Translate(Wearer.LabelShort.CapitalizeFirst(), Label.CapitalizeFirst()),
                    Wearer, MessageTypeDefOf.NeutralEvent, false);
            }
            else
            {
                JPSlowBurn = false;
            }
        }
Пример #3
0
        public override void Tick()
        {
            base.Tick();
            if (Wearer != null)
            {
                if (Wearer.MentalState != null)
                {
                    if (Wearer.MentalState.def.defName == "Slaughterer")
                    {
                        DamageInfo dinfo = new DamageInfo();
                        dinfo.Def = OGShockCollarDefOf.OGElectrical;

                        Wearer.TakeDamage(dinfo);
                    }
                }
            }
        }
Пример #4
0
 // Token: 0x06000023 RID: 35 RVA: 0x00002CEC File Offset: 0x00000EEC
 public override void Tick()
 {
     base.Tick();
     if (Wearer != null)
     {
         if (Wearer.IsBurning())
         {
             DoFFoamBeltPop(Wearer, this);
         }
     }
     else
     {
         if (this.IsBurning())
         {
             DoFFoamBeltPop(null, this);
         }
     }
 }
Пример #5
0
        public void Zap()
        {
            var zap  = new DamageInfo(DamageDefOf.Burn, 1f, 100f, -1f, this, Wearer.RaceProps.body.AllParts.Find(part => part.def == BodyPartDefOf.Neck));
            var zap2 = new DamageInfo(DamageDefOf.Stun, 1f, 100f, -1f, this, Wearer.RaceProps.body.AllParts.Find(part => part.def == BodyPartDefOf.Neck));

            if (Wearer.Downed || !Wearer.Spawned)
            {
                armed = false;
                return;
            }
            SoundInfo info = SoundInfo.InMap(new TargetInfo(Wearer.PositionHeld, Wearer.MapHeld));

            SoundDefOf.Power_OffSmall.PlayOneShot(info);
            Wearer.TakeDamage(zap);
            Wearer.TakeDamage(zap2);
            Wearer.health.AddHediff(SS_HediffDefOf.Electrocuted);
            SlaveUtility.TryHeartAttack(Wearer);
        }
    private void AbsorbedDamage(DamageInfo dinfo)
    {
        SoundDefOf.EnergyShield_AbsorbDamage.PlayOneShot(new TargetInfo(Wearer.Position, Wearer.Map));
        impactAngleVect = Vector3Utility.HorizontalVectorFromAngle(dinfo.Angle);
        var loc = Wearer.TrueCenter() + (impactAngleVect.RotatedBy(180f) * 0.5f);
        var num = Mathf.Min(10f, 2f + (dinfo.Amount / 10f));

        FleckMaker.Static(loc, Wearer.Map, FleckDefOf.ExplosionFlash, num);
        var num2 = (int)num;

        for (var i = 0; i < num2; i++)
        {
            FleckMaker.ThrowDustPuff(loc, Wearer.Map, Rand.Range(0.8f, 1.2f));
        }

        lastAbsorbDamageTick = Find.TickManager.TicksGame;
        KeepDisplaying();
    }
Пример #7
0
        // Token: 0x0600005B RID: 91 RVA: 0x00003DCC File Offset: 0x00001FCC
        private void AbsorbedDamage(DamageInfo dinfo)
        {
            SoundDefOf.EnergyShield_AbsorbDamage.PlayOneShot(new TargetInfo(Wearer.Position, Wearer.Map, false));
            this.impactAngleVect = Vector3Utility.HorizontalVectorFromAngle(dinfo.Angle);
            UnityEngine.Vector3 loc = Wearer.TrueCenter() + this.impactAngleVect.RotatedBy(180f) * 0.5f;
            float num = Mathf.Min(10f, 2f + (float)dinfo.Amount / 10f);

            MoteMaker.MakeStaticMote(loc, Wearer.Map, ThingDefOf.Mote_ExplosionFlash, num);
            int num2 = (int)num;

            for (int i = 0; i < num2; i++)
            {
                Rand.PushState();
                MoteMaker.ThrowDustPuff(loc, Wearer.Map, Rand.Range(0.8f, 1.2f));
                Rand.PopState();
            }
            this.lastAbsorbDamageTick = Find.TickManager.TicksGame;
            this.KeepDisplaying();
        }
Пример #8
0
        public override bool CheckPreAbsorbDamage(DamageInfo dinfo)
        {
            if (ShieldMax <= 0 || shieldInit > 0)
            {
                //受到伤害时重置启动倒计时
                shieldInit = shieldInitSec.SecondsToTicks();
                return(false);
            }
            dinfo.SetAmount(dinfo.Amount / shieldDamagedRate);
            float impact = dinfo.Amount;

            if (impact > shieldCur)
            {
                dinfo.SetAmount(-shieldCur);
                shieldCur  = 0;
                shieldInit = shieldInitSec.SecondsToTicks();
                //剩余护盾相对冲击量越高,抵挡最后一次伤害的概率就越高
                return(Rand.Chance(shieldCur / impact));
            }
            else
            {
                shieldCur -= impact;
                SoundDefOf.EnergyShield_AbsorbDamage.PlayOneShot(new TargetInfo(Wearer.Position, Wearer.Map, false));
                impactAngleVect = Vector3Utility.HorizontalVectorFromAngle(dinfo.Angle);
                Vector3 loc = Wearer.TrueCenter() + impactAngleVect.RotatedBy(180f) * 0.5f;
                float   num = Mathf.Min(10f, 2f + dinfo.Amount / 10f);
                MoteMaker.MakeStaticMote(loc, Wearer.Map, ThingDefOf.Mote_ExplosionFlash, num);
                int num2 = (int)num;
                for (int i = 0; i < num2; i++)
                {
                    MoteMaker.ThrowDustPuff(loc, Wearer.Map, Rand.Range(0.8f, 1.2f));
                }
                int gt = Find.TickManager.TicksGame;
                lastAbsorbDamageTick = gt;
                lastKeepDisplayTick  = gt;
            }
            return(true);
        }
Пример #9
0
        private Command_Reloadable CreateVerbTargetCommand(Thing gear, Verb verb)
        {
            Command_Reloadable command_Reloadable = new Command_Reloadable(this);

            command_Reloadable.defaultDesc  = gear.def.description;
            command_Reloadable.hotKey       = Props.hotKey;
            command_Reloadable.defaultLabel = verb.verbProps.label;
            command_Reloadable.verb         = verb;
            if (verb.verbProps.defaultProjectile != null && verb.verbProps.commandIcon == null)
            {
                command_Reloadable.icon          = verb.verbProps.defaultProjectile.uiIcon;
                command_Reloadable.iconAngle     = verb.verbProps.defaultProjectile.uiIconAngle;
                command_Reloadable.iconOffset    = verb.verbProps.defaultProjectile.uiIconOffset;
                command_Reloadable.overrideColor = verb.verbProps.defaultProjectile.graphicData.color;
            }
            else
            {
                command_Reloadable.icon             = ((verb.UIIcon != BaseContent.BadTex) ? verb.UIIcon : gear.def.uiIcon);
                command_Reloadable.iconAngle        = gear.def.uiIconAngle;
                command_Reloadable.iconOffset       = gear.def.uiIconOffset;
                command_Reloadable.defaultIconColor = gear.DrawColor;
            }
            if (!Wearer.IsColonistPlayerControlled)
            {
                command_Reloadable.Disable();
            }
            else if (verb.verbProps.violent && Wearer.WorkTagIsDisabled(WorkTags.Violent))
            {
                command_Reloadable.Disable("IsIncapableOfViolenceLower".Translate(Wearer.LabelShort, Wearer).CapitalizeFirst() + ".");
            }
            else if (!CanBeUsed)
            {
                command_Reloadable.Disable(DisabledReason(MinAmmoNeeded(allowForcedReload: false), MaxAmmoNeeded(allowForcedReload: false)));
            }
            return(command_Reloadable);
        }
        public override void DrawWornExtras()
        {
            if (Wearer == null || !Wearer.Spawned)
            {
                return;
            }
            Building_Bed bed = Wearer.CurrentBed();

            if (bed != null && !bed.def.building.bed_showSleeperBody && !onHead)
            {
                return;
            }

            //Since I haven't a head apparel item to test the drawing code against for now we throw an error (ONCE) and exit.
            if (this.onHead)
            {
                Log.ErrorOnce(string.Concat("CombatExtended :: Apparel_VisibleAccessory: The head drawing code is incomplete and the apparel '",
                                            this.Label, "' will not be drawn."), this.def.debugRandomId);
                return;
            }

            // compute drawVec, angle and Rot4 vars
            Rot4    rotation;
            Rot4    bedRotation = new Rot4();
            float   angle       = 0;
            Vector3 drawVec     = Wearer.Drawer.DrawPos;

            if (Wearer.GetPosture() != PawnPosture.Standing)
            {
                rotation = LayingFacing();
                if (bed != null)
                {
                    bedRotation        = bed.Rotation;
                    bedRotation.AsInt += 2;
                    angle              = bedRotation.AsAngle;
                    AltitudeLayer altitude = (AltitudeLayer)((byte)Mathf.Max((int)bed.def.altitudeLayer, 14));
                    drawVec.y = Wearer.Position.ToVector3ShiftedWithAltitude(altitude).y;
                    drawVec  += bedRotation.FacingCell.ToVector3() * (-Wearer.Drawer.renderer.BaseHeadOffsetAt(Rot4.South).z);
                }
                else
                {
                    drawVec.y = Wearer.Position.ToVector3ShiftedWithAltitude(AltitudeLayer.LayingPawn).y;
                    if (Wearer.Downed)      // Wearer.Spawned == false when Pawn.Dead == true.
                    {
                        float?newAngle = (((((Wearer.Drawer == null) ? null : Wearer.Drawer.renderer) == null) ? null : Wearer.Drawer.renderer.wiggler) == null) ? (float?)null : Wearer.Drawer.renderer.wiggler.downedAngle;
                        if (newAngle != null)
                        {
                            angle = newAngle.Value;
                        }
                    }
                    else
                    {
                        angle = rotation.FacingCell.AngleFlat;
                    }
                }
                drawVec.y += 0.005f;
            }
            else
            {
                rotation  = Wearer.Rotation;
                drawVec.y = Wearer.Position.ToVector3ShiftedWithAltitude(AltitudeLayer.Pawn).y;
            }

            drawVec.y += GetAltitudeOffset(rotation);

            // Get the graphic path
            string  path    = def.graphicData.texPath + "_" + ((Wearer == null) ? null : Wearer.story.bodyType.ToString());
            Graphic graphic = GraphicDatabase.Get <Graphic_Multi>(path, ShaderDatabase.CutoutComplex, def.graphicData.drawSize, DrawColor);
            ApparelGraphicRecord apparelGraphic = new ApparelGraphicRecord(graphic, this);

            Material mat = apparelGraphic.graphic.MatAt(rotation);
            Vector3  s   = new Vector3(1.5f, 1.5f, 1.5f);

            //mat.shader = ShaderDatabase.CutoutComplex;
            //mat.color = DrawColor;
            Matrix4x4 matrix = default(Matrix4x4);

            matrix.SetTRS(drawVec, Quaternion.AngleAxis(angle, Vector3.up), s);
            Graphics.DrawMesh(rotation == Rot4.West ? MeshPool.plane10Flip : MeshPool.plane10, matrix, mat, 0);
        }
Пример #11
0
        public override IEnumerable <Gizmo> GetWornGizmos()
        {
            //  base.GetWornGizmos();
            if (Find.Selector.SingleSelectedThing != Wearer)
            {
                yield break;
            }

            //tanya
            if (Wearer.kindDef.defName == "ra2_AlliedTanya")
            {
                yield return(new Command_Action
                {
                    icon = ContentFinder <Texture2D> .Get(!tanyaHandWeapon()
                                                          ?DefDatabase <ThingDef> .GetNamed("ra2_Gun_Tanya").graphicData.texPath
                                                          : DefDatabase <ThingDef> .GetNamed("ra2_TanyaC4Bomb").graphicData.texPath),
                    defaultLabel = "TanyaChangeWeapon".Translate(),
                    activateSound = DefDatabase <SoundDef> .GetNamed("ra2_tanya_select"),
                    action = delegate
                    {
                        var pe = Wearer.equipment;
                        var tempDef =
                            DefDatabase <ThingDef> .GetNamed(tanyaHandWeapon()? "ra2_TanyaC4Bomb" : "ra2_Gun_Tanya");

                        pe.Remove(pe.Primary);
                        pe.AddEquipment((ThingWithComps)ThingMaker.MakeThing(tempDef));
                    }
                });
            }

            //chrono
            var tp = new TargetingParameters
            {
                canTargetBuildings = false,
                canTargetFires     = false,
                canTargetLocations = true,
                canTargetPawns     = false,
                canTargetSelf      = false
            };


            if (Wearer.kindDef.defName == "ra2_AlliedChrono")
            {
                yield return(new Command_TargetPlus
                {
                    icon = ContentFinder <Texture2D> .Get("ra2/Things/Misc/ChTeleport"),
                    defaultLabel = "ChronoTeleport".Translate(),
                    activateSound = DefDatabase <SoundDef> .GetNamed("ra2_Chrono_select"),
                    targetingParams = tp,
                    hotKey = KeyBindingDefOf.Misc4,
                    disabled = !Wearer.drafter.Drafted || Wearer.stances.stunner.Stunned,
                    aimIcon = ContentFinder <Texture2D> .Get("ra2/Things/Misc/ChTeleport"),
                    action = delegate(LocalTargetInfo target)
                    {
                        var casterPawn = Wearer;
                        var map = Wearer.Map;

                        var thi = map.thingGrid.ThingsAt(target.Cell);
                        foreach (var th in thi)
                        {
                            if (th is not Building)
                            {
                                continue;
                            }

                            Messages.Message("ChronoNotToBuild".Translate(), MessageTypeDefOf.RejectInput);
                            return;
                        }

                        FleckMaker.ThrowExplosionCell(target.Cell, map, FleckDefOf.ExplosionFlash, new Color(1, 1, 1));
                        // MoteMaker.ThrowExplosionCell(target.Cell, map, ThingDefOf.Mote_ExplosionFlash, new UnityEngine.Color(1,1,1));
                        for (var asd = 0; asd < 60; asd++)
                        {
                            FleckMaker.ThrowExplosionCell(casterPawn.Position, map, FleckDefOf.ExplosionFlash,
                                                          new Color(1f - (asd * 0.1f), asd * 0.1f, 1f - (asd * 0.05f)));
                        }


                        var dist = Math.Sqrt(Math.Pow(casterPawn.Position.x - target.Cell.x, 2) +
                                             Math.Pow(casterPawn.Position.z - target.Cell.z, 2));

                        if (dist < 20)
                        {
                            dist = 20;
                        }


                        ThingSelectionUtility.SelectNextColonist();
                        Wearer.DeSpawn();
                        GenSpawn.Spawn(casterPawn, target.Cell, map);
                        casterPawn.drafter.Drafted = true;
                        ThingSelectionUtility.SelectPreviousColonist();
                        DefDatabase <SoundDef> .GetNamed("ra2_Chrono_move").PlayOneShot(casterPawn);

                        DefDatabase <SoundDef> .GetNamed("ra2_Chrono_movesay").PlayOneShotOnCamera();

                        var dinfo = new DamageInfo(DamageDefOf.Stun, (int)(dist * 0.1), -1, 1, null, null,
                                                   Wearer.equipment.Primary.def, DamageInfo.SourceCategory.ThingOrUnknown, casterPawn);
                        casterPawn.TakeDamage(dinfo);
                        // Log.Warning(target+"VV");
                    }
                });
Пример #12
0
 // Token: 0x06000005 RID: 5 RVA: 0x00002108 File Offset: 0x00000308
 public bool ComputeCloakState()
 {
     return(IsWorn && !Wearer.Dead && !Wearer.Downed && Wearer.Awake() && this.cloakMode == CompCloakGenerator.CloakMode.On);
 }