static bool Prefix(ref Thing shooter, ref LocalTargetInfo target, ref int degreesWide, ref float offsetDist)
        {
            if (!(shooter is Pawn))
            {
                return(true);
            }
            Pawn             pawn     = shooter as Pawn;
            ExtendedPawnData pawnData = Base.Instance.GetExtendedDataStorage().GetExtendedDataFor(pawn);

            if (pawnData.drawOffset > -1)
            {
                float facing = 0f;
                if (target.Cell != shooter.Position)
                {
                    if (target.Thing != null)
                    {
                        facing = (target.Thing.DrawPos - shooter.Position.ToVector3Shifted()).AngleFlat();
                    }
                    else
                    {
                        facing = (target.Cell - shooter.Position).AngleFlat;
                    }
                }
                GenDraw.DrawAimPieRaw(shooter.DrawPos + new Vector3(0f, offsetDist, pawnData.drawOffset), facing, degreesWide);
                return(false);
            }
            return(true);
        }
示例#2
0
        protected virtual void TurretTargeterTick()
        {
            if (cannonTarget.IsValid && currentRotation == rotationTargeted && !TargetLocked)
            {
                TargetLocked = true;
                ResetPrefireTimer();
            }
            if (cannonTarget.Cell.IsValid)
            {
                if (IsTargetable && !CannonTargeter.TargetMeetsRequirements(this, cannonTarget))
                {
                    SetTarget(LocalTargetInfo.Invalid);
                    TargetLocked = false;
                    return;
                }
                if (PrefireTickCount > 0)
                {
                    if (cannonTarget.HasThing)
                    {
                        rotationTargeted = TurretLocation.AngleToPointRelative(cannonTarget.Thing.DrawPos);
                        if (attachedTo != null)
                        {
                            rotationTargeted += attachedTo.TurretRotation;
                        }
                    }
                    else
                    {
                        rotationTargeted = TurretLocation.ToIntVec3().AngleToCell(cannonTarget.Cell, vehicle.Map);
                        if (attachedTo != null)
                        {
                            rotationTargeted += attachedTo.TurretRotation;
                        }
                    }

                    if (turretDef.autoSnapTargeting)
                    {
                        currentRotation = rotationTargeted;
                    }

                    if (TargetLocked && ReadyToFire)
                    {
                        float facing = cannonTarget.Thing != null ? (cannonTarget.Thing.DrawPos - TurretLocation).AngleFlat() : (cannonTarget.Cell - TurretLocation.ToIntVec3()).AngleFlat;
                        GenDraw.DrawAimPieRaw(TurretLocation + new Vector3(turretRenderOffset.x + aimPieOffset.x, 0.5f, turretRenderOffset.y + aimPieOffset.y).RotatedBy(TurretRotation), facing, (int)(PrefireTickCount * 0.5f));
                        PrefireTickCount--;
                    }
                }
                else if (ReadyToFire)
                {
                    if (IsTargetable && RotationIsValid && targetPersists && (cannonTarget.Pawn is null || !SetTargetConditionalOnThing(LocalTargetInfo.Invalid)))
                    {
                        GroupTurrets.ForEach(t => t.PushTurretToQueue());
                    }
                    else if (FullAuto)
                    {
                        GroupTurrets.ForEach(t => t.PushTurretToQueue());
                    }
                }
            }
示例#3
0
        // Token: 0x06002133 RID: 8499 RVA: 0x000CB158 File Offset: 0x000C9358
        public void DrawAimPie(Thing shooter, LocalTargetInfo target, int degreesWide, float offsetDist)
        {
            float facing = 0f;

            if (target.Cell != shooter.Position)
            {
                if (target.Thing != null)
                {
                    facing = (target.Thing.DrawPos - TurretPos).AngleFlat();
                }
                else
                {
                    facing = (target.Cell.ToVector3() - TurretPos).AngleFlat();
                }
            }
            GenDraw.DrawAimPieRaw(TurretPos + new Vector3(0f, offsetDist, 0f), facing, degreesWide);
        }
示例#4
0
 public override void StanceDraw()
 {
     if (Find.Selector.IsSelected(this.stanceTracker.pawn))
     {
         Pawn            shooter = this.stanceTracker.pawn;
         LocalTargetInfo target  = this.focusTarg;
         float           facing  = 0f;
         if (target.Cell != shooter.Position)
         {
             if (target.Thing != null)
             {
                 facing = (target.Thing.DrawPos - shooter.Position.ToVector3Shifted()).AngleFlat();
             }
             else
             {
                 facing = (target.Cell - shooter.Position).AngleFlat;
             }
         }
         float zOffSet = 0f;
         float xOffset = 0f;
         if (shooter.Rotation == Rot4.East)
         {
             zOffSet = 0.1f;
         }
         else if (shooter.Rotation == Rot4.West)
         {
             zOffSet = -0.1f;
         }
         else if (shooter.Rotation == Rot4.South)
         {
             xOffset = 0.1f;
         }
         else
         {
             xOffset = -0.1f;
         }
         GenDraw.DrawAimPieRaw(shooter.DrawPos + new Vector3(xOffset, 0.2f, zOffSet), facing, (int)((float)this.ticksLeft * this.pieSizeFactor));
     }
 }
示例#5
0
        public void DoTick()
        {
            if (cooldownTicks > 0)
            {
                cooldownTicks--;
                if (cooldownTicks <= 0)
                {
                    ReloadCannon();
                }
            }
            if (IsTargetable)
            {
                if (cannonTarget.Cell.IsValid)
                {
                    LockedStatusRotation = false;
                    if (PrefireTickCount > 0)
                    {
                        if (!CannonTargeter.TargetMeetsRequirements(this, cannonTarget) || !pawn.Drafted)
                        {
                            SetTarget(LocalTargetInfo.Invalid);
                            return;
                        }
                        currentRotation = (float)TurretLocation.ToIntVec3().AngleToPoint(cannonTarget.Cell, pawn.Map);

                        float facing = cannonTarget.Thing != null ? (cannonTarget.Thing.DrawPos - TurretLocation).AngleFlat() : (cannonTarget.Cell - TurretLocation.ToIntVec3()).AngleFlat;
                        GenDraw.DrawAimPieRaw(TurretLocation + new Vector3(cannonRenderOffset.x + aimPieOffset.x, 0.5f, cannonRenderOffset.y + aimPieOffset.y).RotatedBy(TurretRotation), facing, (int)(PrefireTickCount * 0.5f));

                        PrefireTickCount--;
                    }
                    else if (cooldownTicks <= 0)
                    {
                        CompCannon.multiFireCannon.Add(new SPTuple <int, CannonHandler, SPTuple2 <int, int> >(cannonDef.numberOfShots, this, new SPTuple2 <int, int>(0, 0)));
                        ActivateTimer();
                    }
                }
            }
        }
示例#6
0
        public void DoTick()
        {
            if (pawn.GetComp <CompCannons>().multiFireCannon.NullOrEmpty())
            {
                if (autoTargeting && Find.TickManager.TicksGame % AutoTargetInterval == 0 && pawn.Drafted)
                {
                    if (CannonDisabled)
                    {
                        return;
                    }
                    if (!cannonTarget.IsValid)
                    {
                        LocalTargetInfo autoTarget = this.GetCannonTarget();
                        if (autoTarget.IsValid)
                        {
                            SetTarget(autoTarget);
                            ResetPrefireTimer();
                        }
                    }
                }
                if (cooldownTicks > 0 && RotationIsValid)
                {
                    cooldownTicks--;
                    if (cooldownTicks <= 0)
                    {
                        ReloadCannon();
                    }
                }
            }

            if (rotationTargeted != currentRotation)
            {
                if (pawn.Drafted)
                {
                    float relativeCurrentRotation  = currentRotation + 90;
                    float relativeTargetedRotation = rotationTargeted + 90;
                    if (relativeCurrentRotation < 0)
                    {
                        relativeCurrentRotation += 360;
                    }
                    else if (relativeCurrentRotation > 360)
                    {
                        relativeCurrentRotation -= 360;
                    }
                    if (relativeTargetedRotation < 0)
                    {
                        relativeTargetedRotation += 360;
                    }
                    else if (relativeTargetedRotation > 360)
                    {
                        relativeTargetedRotation -= 360;
                    }
                    if (Math.Abs(relativeCurrentRotation - relativeTargetedRotation) < cannonDef.rotationSpeed)
                    {
                        currentRotation = rotationTargeted;
                    }
                    else
                    {
                        int?sign = AngleDirectionalRestricted(relativeTargetedRotation);

                        if (relativeCurrentRotation < relativeTargetedRotation)
                        {
                            if (Math.Abs(relativeCurrentRotation - relativeTargetedRotation) < 180)
                            {
                                currentRotation += cannonDef.rotationSpeed;
                            }
                            else
                            {
                                currentRotation -= cannonDef.rotationSpeed;
                            }
                        }
                        else
                        {
                            if (Math.Abs(relativeCurrentRotation - relativeTargetedRotation) < 180)
                            {
                                currentRotation -= cannonDef.rotationSpeed;
                            }
                            else
                            {
                                currentRotation += cannonDef.rotationSpeed;
                            }
                        }
                    }
                }
                else
                {
                    rotationTargeted = currentRotation;
                }
            }
            if (IsTargetable)
            {
                if (cannonTarget.Cell.IsValid)
                {
                    if (!CannonTargeter.TargetMeetsRequirements(this, cannonTarget) || !pawn.Drafted)
                    {
                        SetTarget(LocalTargetInfo.Invalid);
                        return;
                    }
                    LockedStatusRotation = false;

                    if (PrefireTickCount > 0)
                    {
                        rotationTargeted = (float)TurretLocation.ToIntVec3().AngleToPoint(cannonTarget.Cell, pawn.Map);
                        if (cannonDef.autoSnapTargeting)
                        {
                            currentRotation = rotationTargeted;
                        }

                        if (RotationIsValid)
                        {
                            float facing = cannonTarget.Thing != null ? (cannonTarget.Thing.DrawPos - TurretLocation).AngleFlat() : (cannonTarget.Cell - TurretLocation.ToIntVec3()).AngleFlat;
                            GenDraw.DrawAimPieRaw(TurretLocation + new Vector3(cannonRenderOffset.x + aimPieOffset.x, 0.5f, cannonRenderOffset.y + aimPieOffset.y).RotatedBy(TurretRotation), facing, (int)(PrefireTickCount * 0.5f));
                            PrefireTickCount--;
                        }
                    }
                    else if (cooldownTicks <= 0 && RotationIsValid && !CannonDisabled)
                    {
                        if (targetPersists && (cannonTarget.Pawn is null || !SetTargetConditionalOnThing(LocalTargetInfo.Invalid)))
                        {
                            CompCannon.multiFireCannon.Add(new Tuple <int, CannonHandler, Tuple <int, int> >(cannonDef.numberOfShots, this, new Tuple <int, int>(0, 0)));
                            ActivateTimer();
                        }

                        if (cannonTarget.IsValid)
                        {
                        }
                    }
                }
            }
        }