コード例 #1
0
 public static void CalcShootableCellsOf(List <IntVec3> outCells, Thing t)
 {
     outCells.Clear();
     if (t is Pawn)
     {
         outCells.Add(t.Position);
         for (int i = 0; i < 4; i++)
         {
             IntVec3 intVec = t.Position + GenAdj.CardinalDirections[i];
             if (intVec.CanBeSeenOver(t.Map))
             {
                 outCells.Add(intVec);
             }
         }
         return;
     }
     outCells.Add(t.Position);
     if (t.def.size.x != 1 || t.def.size.z != 1)
     {
         foreach (IntVec3 intVec2 in t.OccupiedRect())
         {
             if (intVec2 != t.Position)
             {
                 outCells.Add(intVec2);
             }
         }
     }
 }
コード例 #2
0
 // ===================== Utility Function =====================
 /// <summary>
 /// Try light the target position.
 /// </summary>
 public override void TryLightTarget(IntVec3 targetPosition)
 {
     if (targetPosition.CanBeSeenOver(this.Map) &&
         GenSight.LineOfSight(this.Position, targetPosition, this.Map))
     {
         SwitchOnLight(targetPosition);
     }
     else
     {
         IntVec3 farthestPosition = TryGetFarthestPositionInSight(targetPosition);
         if (farthestPosition.IsValid)
         {
             SwitchOnLight(farthestPosition);
         }
         else
         {
             SwitchOffLight();
         }
     }
 }