public void CheckStruckOre(IntVec3 justMinedPos, ThingDef justMinedDef, Thing miner)
 {
     if (miner.Faction != Faction.OfPlayer)
     {
         return;
     }
     for (int i = 0; i < 4; i++)
     {
         IntVec3 intVec = justMinedPos + GenAdj.CardinalDirections[i];
         if (intVec.InBounds(miner.Map))
         {
             Building edifice = intVec.GetEdifice(miner.Map);
             if (edifice != null && edifice.def != justMinedDef && MineStrikeManager.MineableIsValuable(edifice.def) && !this.AlreadyVisibleNearby(intVec, miner.Map, edifice.def) && !this.RecentlyStruck(intVec, edifice.def))
             {
                 StrikeRecord item = default(StrikeRecord);
                 item.cell      = intVec;
                 item.def       = edifice.def;
                 item.ticksGame = Find.TickManager.TicksGame;
                 this.strikeRecords.Add(item);
                 Messages.Message("StruckMineable".Translate(new object[]
                 {
                     edifice.def.label
                 }), edifice, MessageTypeDefOf.PositiveEvent, true);
                 TaleRecorder.RecordTale(TaleDefOf.StruckMineable, new object[]
                 {
                     miner,
                     edifice
                 });
             }
         }
     }
 }
Example #2
0
 private bool RecentlyStruck(IntVec3 cell, ThingDef def)
 {
     for (int num = this.strikeRecords.Count - 1; num >= 0; num--)
     {
         if (this.strikeRecords[num].Expired)
         {
             this.strikeRecords.RemoveAt(num);
         }
         else
         {
             StrikeRecord strikeRecord = this.strikeRecords[num];
             if (strikeRecord.def == def)
             {
                 StrikeRecord strikeRecord2 = this.strikeRecords[num];
                 if (strikeRecord2.cell.InHorDistOf(cell, 12f))
                 {
                     return(true);
                 }
             }
         }
     }
     return(false);
 }