private static Verb GetAttackVerb(Thing attacker) { Pawn pawn = attacker as Pawn; if (pawn != null) { return(pawn.TryGetAttackVerb(!pawn.IsColonist)); } Building_Turret building_Turret = attacker as Building_Turret; if (building_Turret != null) { return(building_Turret.AttackVerb); } Vehicle_Turret vehicle_Turret = attacker as Vehicle_Turret; if (vehicle_Turret != null) { return(vehicle_Turret.AttackVerb); } return(null); }
public Vehicle_TurretTop(Vehicle_Turret ParentTurret) { parentTurret = ParentTurret; }
/// <summary> /// Selects the appropriate vehicle by worktype /// </summary> /// <param name="pawn"></param> /// <param name="worktype"></param> /// <returns></returns> public static Thing GetRightVehicle(Pawn pawn, WorkTypeDef worktype, Thing t = null) { Thing cart = null; if (worktype.Equals(WorkTypeDefOf.Hunting)) { bool skip = false; IOrderedEnumerable <Thing> orderedEnumerable = ToolsForHaulUtility.CartTurret.OrderBy(x => pawn.Position.DistanceToSquared(x.Position)); foreach (Thing thing in orderedEnumerable) { Vehicle_Turret vehicleTurret = (Vehicle_Turret)thing; if (vehicleTurret == null) { continue; } if (!ToolsForHaulUtility.AvailableVehicle(pawn, vehicleTurret)) { continue; } if (!vehicleTurret.IsCurrentlyMotorized()) { continue; } if (vehicleTurret.vehicleComp.tankLeaking) { continue; } cart = vehicleTurret; skip = true; break; } if (!skip) { IOrderedEnumerable <Thing> orderedEnumerable2 = ToolsForHaulUtility.Cart.OrderBy(x => pawn.Position.DistanceToSquared(x.Position)); foreach (Thing thing in orderedEnumerable2) { Vehicle_Cart vehicleCart = (Vehicle_Cart)thing; if (vehicleCart == null) { continue; } if (!ToolsForHaulUtility.AvailableVehicle(pawn, vehicleCart)) { continue; } if (!vehicleCart.IsCurrentlyMotorized()) { continue; } if (vehicleCart.vehicleComp.tankLeaking) { continue; } cart = vehicleCart; break; } } } if (worktype.Equals(WorkTypeDefOf.Hauling)) { IOrderedEnumerable <Thing> orderedEnumerable2 = ToolsForHaulUtility.Cart.OrderByDescending(x => (x as Vehicle_Cart).MaxItem).ThenBy(x => pawn.Position.DistanceToSquared(x.Position)); foreach (Thing thing in orderedEnumerable2) { Vehicle_Cart vehicleCart = (Vehicle_Cart)thing; if (vehicleCart == null) { continue; } if (!ToolsForHaulUtility.AvailableVehicle(pawn, vehicleCart)) { continue; } if (vehicleCart.vehicleComp.tankLeaking) { continue; } cart = vehicleCart; break; } } if (worktype.Equals(WorkTypeDefOf.Construction)) { IOrderedEnumerable <Thing> orderedEnumerable2 = ToolsForHaulUtility.Cart.OrderBy(x => pawn.Position.DistanceToSquared(x.Position)).ThenByDescending(x => (x as Vehicle_Cart).VehicleSpeed); foreach (Thing thing in orderedEnumerable2) { Vehicle_Cart vehicleCart = (Vehicle_Cart)thing; if (vehicleCart == null) { continue; } if (!ToolsForHaulUtility.AvailableVehicle(pawn, vehicleCart)) { continue; } if (!vehicleCart.IsCurrentlyMotorized()) { continue; } if (vehicleCart.vehicleComp.tankLeaking) { continue; } cart = vehicleCart; break; } } return(cart); }