Esempio n. 1
0
 private void DrawEquipment(Vector3 rootLoc)
 {
     if (!this.pawn.Dead && this.pawn.Spawned)
     {
         if (this.pawn.equipment != null && this.pawn.equipment.Primary != null)
         {
             if (this.pawn.CurJob == null || !this.pawn.CurJob.def.neverShowWeapon)
             {
                 Stance_Busy stance_Busy = this.pawn.stances.curStance as Stance_Busy;
                 if (stance_Busy != null && !stance_Busy.neverAimWeapon && stance_Busy.focusTarg.IsValid)
                 {
                     Vector3 a;
                     if (stance_Busy.focusTarg.HasThing)
                     {
                         a = stance_Busy.focusTarg.Thing.DrawPos;
                     }
                     else
                     {
                         a = stance_Busy.focusTarg.Cell.ToVector3Shifted();
                     }
                     float num = 0f;
                     if ((a - this.pawn.DrawPos).MagnitudeHorizontalSquared() > 0.001f)
                     {
                         num = (a - this.pawn.DrawPos).AngleFlat();
                     }
                     Vector3 drawLoc = rootLoc + new Vector3(0f, 0f, 0.4f).RotatedBy(num);
                     drawLoc.y += 0.0390625f;
                     this.DrawEquipmentAiming(this.pawn.equipment.Primary, drawLoc, num);
                 }
                 else if (this.CarryWeaponOpenly())
                 {
                     if (this.pawn.Rotation == Rot4.South)
                     {
                         Vector3 drawLoc2 = rootLoc + new Vector3(0f, 0f, -0.22f);
                         drawLoc2.y += 0.0390625f;
                         this.DrawEquipmentAiming(this.pawn.equipment.Primary, drawLoc2, 143f);
                     }
                     else if (this.pawn.Rotation == Rot4.North)
                     {
                         Vector3 drawLoc3 = rootLoc + new Vector3(0f, 0f, -0.11f);
                         drawLoc3.y = drawLoc3.y;
                         this.DrawEquipmentAiming(this.pawn.equipment.Primary, drawLoc3, 143f);
                     }
                     else if (this.pawn.Rotation == Rot4.East)
                     {
                         Vector3 drawLoc4 = rootLoc + new Vector3(0.2f, 0f, -0.22f);
                         drawLoc4.y += 0.0390625f;
                         this.DrawEquipmentAiming(this.pawn.equipment.Primary, drawLoc4, 143f);
                     }
                     else if (this.pawn.Rotation == Rot4.West)
                     {
                         Vector3 drawLoc5 = rootLoc + new Vector3(-0.2f, 0f, -0.22f);
                         drawLoc5.y += 0.0390625f;
                         this.DrawEquipmentAiming(this.pawn.equipment.Primary, drawLoc5, 217f);
                     }
                 }
             }
         }
     }
 }
        public bool ShouldLean()
        {
            Stance_Busy stance_Busy = this.pawn.stances.curStance as Stance_Busy;

            if (stance_Busy != null)
            {
                if (this.shootSourceOffset == new IntVec3(0, 0, 0))
                {
                    return(false);
                }
                return(true);
            }
            return(false);
        }
Esempio n. 3
0
        private void DrawEquipment(Vector3 rootLoc)
        {
            if (pawn.Dead || !pawn.Spawned || pawn.equipment == null || pawn.equipment.Primary == null || (pawn.CurJob != null && pawn.CurJob.def.neverShowWeapon))
            {
                return;
            }
            Stance_Busy stance_Busy = pawn.stances.curStance as Stance_Busy;

            if (stance_Busy != null && !stance_Busy.neverAimWeapon && stance_Busy.focusTarg.IsValid)
            {
                Vector3 a   = ((!stance_Busy.focusTarg.HasThing) ? stance_Busy.focusTarg.Cell.ToVector3Shifted() : stance_Busy.focusTarg.Thing.DrawPos);
                float   num = 0f;
                if ((a - pawn.DrawPos).MagnitudeHorizontalSquared() > 0.001f)
                {
                    num = (a - pawn.DrawPos).AngleFlat();
                }
                Vector3 drawLoc = rootLoc + new Vector3(0f, 0f, 0.4f).RotatedBy(num);
                drawLoc.y += 9f / 245f;
                DrawEquipmentAiming(pawn.equipment.Primary, drawLoc, num);
            }
            else if (CarryWeaponOpenly())
            {
                if (pawn.Rotation == Rot4.South)
                {
                    Vector3 drawLoc2 = rootLoc + new Vector3(0f, 0f, -0.22f);
                    drawLoc2.y += 9f / 245f;
                    DrawEquipmentAiming(pawn.equipment.Primary, drawLoc2, 143f);
                }
                else if (pawn.Rotation == Rot4.North)
                {
                    Vector3 drawLoc3 = rootLoc + new Vector3(0f, 0f, -0.11f);
                    drawLoc3.y += 0f;
                    DrawEquipmentAiming(pawn.equipment.Primary, drawLoc3, 143f);
                }
                else if (pawn.Rotation == Rot4.East)
                {
                    Vector3 drawLoc4 = rootLoc + new Vector3(0.2f, 0f, -0.22f);
                    drawLoc4.y += 9f / 245f;
                    DrawEquipmentAiming(pawn.equipment.Primary, drawLoc4, 143f);
                }
                else if (pawn.Rotation == Rot4.West)
                {
                    Vector3 drawLoc5 = rootLoc + new Vector3(-0.2f, 0f, -0.22f);
                    drawLoc5.y += 9f / 245f;
                    DrawEquipmentAiming(pawn.equipment.Primary, drawLoc5, 217f);
                }
            }
        }
 public void UpdateRotation()
 {
     if (this.pawn.Destroyed)
     {
         return;
     }
     if (this.pawn.jobs.HandlingFacing)
     {
         return;
     }
     if (this.pawn.pather.Moving)
     {
         if (this.pawn.pather.curPath == null || this.pawn.pather.curPath.NodesLeftCount < 1)
         {
             return;
         }
         this.FaceAdjacentCell(this.pawn.pather.nextCell);
         return;
     }
     else
     {
         Stance_Busy stance_Busy = this.pawn.stances.curStance as Stance_Busy;
         if (stance_Busy != null && stance_Busy.focusTarg.IsValid)
         {
             if (stance_Busy.focusTarg.HasThing)
             {
                 this.Face(stance_Busy.focusTarg.Thing.DrawPos);
             }
             else
             {
                 this.FaceCell(stance_Busy.focusTarg.Cell);
             }
             return;
         }
         if (this.pawn.jobs.curJob != null)
         {
             LocalTargetInfo target = this.pawn.CurJob.GetTarget(this.pawn.jobs.curDriver.rotateToFace);
             this.FaceTarget(target);
         }
         if (this.pawn.Drafted)
         {
             this.pawn.Rotation = Rot4.South;
         }
         return;
     }
 }
Esempio n. 5
0
 public void UpdateRotation()
 {
     if (!pawn.Destroyed && !pawn.jobs.HandlingFacing)
     {
         if (pawn.pather.Moving)
         {
             if (pawn.pather.curPath != null && pawn.pather.curPath.NodesLeftCount >= 1)
             {
                 FaceAdjacentCell(pawn.pather.nextCell);
             }
         }
         else
         {
             Stance_Busy stance_Busy = pawn.stances.curStance as Stance_Busy;
             if (stance_Busy != null && stance_Busy.focusTarg.IsValid)
             {
                 if (stance_Busy.focusTarg.HasThing)
                 {
                     Face(stance_Busy.focusTarg.Thing.DrawPos);
                 }
                 else
                 {
                     FaceCell(stance_Busy.focusTarg.Cell);
                 }
             }
             else
             {
                 if (pawn.jobs.curJob != null)
                 {
                     LocalTargetInfo target = pawn.CurJob.GetTarget(pawn.jobs.curDriver.rotateToFace);
                     FaceTarget(target);
                 }
                 if (pawn.Drafted)
                 {
                     pawn.Rotation = Rot4.South;
                 }
             }
         }
     }
 }
Esempio n. 6
0
 public void UpdateRotation()
 {
     if (!this.pawn.Destroyed && !this.pawn.jobs.HandlingFacing)
     {
         if (this.pawn.pather.Moving)
         {
             if (this.pawn.pather.curPath != null && this.pawn.pather.curPath.NodesLeftCount >= 1)
             {
                 this.FaceAdjacentCell(this.pawn.pather.nextCell);
             }
         }
         else
         {
             Stance_Busy stance_Busy = this.pawn.stances.curStance as Stance_Busy;
             if (stance_Busy != null && stance_Busy.focusTarg.IsValid)
             {
                 if (stance_Busy.focusTarg.HasThing)
                 {
                     this.Face(stance_Busy.focusTarg.Thing.DrawPos);
                 }
                 else
                 {
                     this.FaceCell(stance_Busy.focusTarg.Cell);
                 }
             }
             else
             {
                 if (this.pawn.jobs.curJob != null)
                 {
                     LocalTargetInfo target = this.pawn.CurJob.GetTarget(this.pawn.jobs.curDriver.rotateToFace);
                     if (target.HasThing)
                     {
                         bool     flag     = false;
                         IntVec3  c        = default(IntVec3);
                         CellRect cellRect = target.Thing.OccupiedRect();
                         for (int i = cellRect.minZ; i <= cellRect.maxZ; i++)
                         {
                             for (int j = cellRect.minX; j <= cellRect.maxX; j++)
                             {
                                 if (this.pawn.Position == new IntVec3(j, 0, i))
                                 {
                                     this.Face(target.Thing.DrawPos);
                                     return;
                                 }
                             }
                         }
                         for (int k = cellRect.minZ; k <= cellRect.maxZ; k++)
                         {
                             for (int l = cellRect.minX; l <= cellRect.maxX; l++)
                             {
                                 IntVec3 intVec = new IntVec3(l, 0, k);
                                 if (intVec.AdjacentToCardinal(this.pawn.Position))
                                 {
                                     this.FaceAdjacentCell(intVec);
                                     return;
                                 }
                                 if (intVec.AdjacentTo8Way(this.pawn.Position))
                                 {
                                     flag = true;
                                     c    = intVec;
                                 }
                             }
                         }
                         if (flag)
                         {
                             if (DebugViewSettings.drawPawnRotatorTarget)
                             {
                                 this.pawn.Map.debugDrawer.FlashCell(this.pawn.Position, 0.6f, "jbthing", 50);
                                 GenDraw.DrawLineBetween(this.pawn.Position.ToVector3Shifted(), c.ToVector3Shifted());
                             }
                             this.FaceAdjacentCell(c);
                         }
                         else
                         {
                             this.Face(target.Thing.DrawPos);
                         }
                         return;
                     }
                     if (this.pawn.Position.AdjacentTo8Way(target.Cell))
                     {
                         if (DebugViewSettings.drawPawnRotatorTarget)
                         {
                             this.pawn.Map.debugDrawer.FlashCell(this.pawn.Position, 0.2f, "jbloc", 50);
                             GenDraw.DrawLineBetween(this.pawn.Position.ToVector3Shifted(), target.Cell.ToVector3Shifted());
                         }
                         this.FaceAdjacentCell(target.Cell);
                         return;
                     }
                     if (target.Cell.IsValid && target.Cell != this.pawn.Position)
                     {
                         this.Face(target.Cell.ToVector3());
                         return;
                     }
                 }
                 if (this.pawn.Drafted)
                 {
                     this.pawn.Rotation = Rot4.South;
                 }
             }
         }
     }
 }
        public bool ShouldLean()
        {
            Stance_Busy stance_Busy = this.pawn.stances.curStance as Stance_Busy;

            return(stance_Busy != null && !(this.shootSourceOffset == new IntVec3(0, 0, 0)));
        }