示例#1
0
        protected override bool TryCastShot()
        {
            ArtilleryMarker marker = ThingMaker.MakeThing(ThingDef.Named(ArtilleryMarker.MarkerDef)) as ArtilleryMarker;
            ShiftVecReport  report = ShiftVecReportFor(currentTarget);

            marker.sightsEfficiency = report.sightsEfficiency;
            marker.aimingAccuracy   = report.aimingAccuracy;
            marker.lightingShift    = report.lightingShift;
            marker.weatherShift     = report.weatherShift;

            GenSpawn.Spawn(marker, this.currentTarget.Cell, caster.Map);

            // Check for something to attach marker to
            if (this.currentTarget.HasThing)
            {
                CompAttachBase comp = this.currentTarget.Thing.TryGetComp <CompAttachBase>();
                if (comp != null)
                {
                    marker.AttachTo(this.currentTarget.Thing);
                }
            }
            // Show we learned something
            PlayerKnowledgeDatabase.KnowledgeDemonstrated(CE_ConceptDefOf.CE_Spotting, KnowledgeAmount.SmallInteraction);

            return(true);
        }
        public static Thing GetAttachment(this Thing t, ThingDef def)
        {
            CompAttachBase compAttachBase = t.TryGetComp <CompAttachBase>();

            if (compAttachBase == null)
            {
                return(null);
            }
            return(compAttachBase.GetAttachment(def));
        }
示例#3
0
 public override void AttachTo(Thing parent)
 {
     if (parent != null)
     {
         CompAttachBase comp = parent.TryGetComp <CompAttachBase>();
         if (comp != null)
         {
             if (parent.HasAttachment(ThingDef.Named(ArtilleryMarker.MarkerDef)))
             {
                 ArtilleryMarker oldMarker = (ArtilleryMarker)parent.GetAttachment(ThingDef.Named(ArtilleryMarker.MarkerDef));
                 oldMarker.Destroy();
             }
         }
     }
     base.AttachTo(parent);
 }
示例#4
0
 public override void DoDamage(IntVec3 pos)
 {
     base.DoDamage(pos);
     try
     {
         if (pos != this.launcher.Position && this.launcher.Map != null && GenGrid.InBounds(pos, this.launcher.Map))
         {
             var list = this.launcher.Map.thingGrid.ThingsListAt(pos);
             for (int num = list.Count - 1; num >= 0; num--)
             {
                 if (list[num].def != this.def && list[num] != this.launcher && list[num].def != ThingDefOf.Fire && (!(list[num] is Mote) && (!(list[num] is Filth))))
                 {
                     if (!list.Where(x => x.def == ThingDefOf.Fire).Any())
                     {
                         CompAttachBase compAttachBase = list[num].TryGetComp <CompAttachBase>();
                         Fire           obj            = (Fire)ThingMaker.MakeThing(ThingDefOf.Fire);
                         obj.fireSize = 1f;
                         GenSpawn.Spawn(obj, list[num].Position, list[num].Map, Rot4.North);
                         if (compAttachBase != null)
                         {
                             obj.AttachTo(list[num]);
                             Pawn pawn = list[num] as Pawn;
                             if (pawn != null)
                             {
                                 pawn.jobs.StopAll();
                                 pawn.records.Increment(RecordDefOf.TimesOnFire);
                             }
                         }
                     }
                     this.customImpact = true;
                     base.Impact(list[num]);
                     this.customImpact = false;
                 }
             }
         }
     }
     catch { };
 }
示例#5
0
        protected override bool TryCastShot()
        {
            ArtilleryMarker marker = ThingMaker.MakeThing(ThingDef.Named(ArtilleryMarker.MarkerDef)) as ArtilleryMarker;
            ShiftVecReport  report = ShiftVecReportFor(currentTarget);

            marker.aimEfficiency  = report.aimEfficiency;
            marker.aimingAccuracy = report.aimingAccuracy;
            marker.lightingShift  = report.lightingShift;
            marker.weatherShift   = report.weatherShift;

            GenSpawn.Spawn(marker, this.currentTarget.Cell, caster.Map);

            // Check for something to attach marker to
            if (this.currentTarget.HasThing)
            {
                CompAttachBase comp = this.currentTarget.Thing.TryGetComp <CompAttachBase>();
                if (comp != null)
                {
                    marker.AttachTo(this.currentTarget.Thing);
                }
            }
            return(true);
        }