Guest User

Untitled

a guest
Mar 12th, 2017
110
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
text 1.88 KB | None | 0 0
  1. using System;
  2. using UnityEngine;
  3. using Verse;
  4. using RimWorld;
  5.  
  6. namespace IncidentWorker_Slimequeens
  7. {
  8. public class IncidentWorker_Slimequeens : IncidentWorker
  9. {
  10. private PawnKindDef pawnDef = PawnKindDef.Named("Slimequeen");
  11. protected override bool CanFireNowSub(IIncidentTarget target)
  12. {
  13. Map map = (Map)target;
  14. return !map.mapConditionManager.ConditionIsActive(MapConditionDefOf.ToxicFallout);
  15. }
  16. public override bool TryExecute(IncidentParms parms)
  17. {
  18. Map map = (Map)parms.target;
  19. IntVec3 intVec;
  20. if (!RCellFinder.TryFindRandomPawnEntryCell(out intVec, map))
  21. {
  22. return false;
  23. }
  24. PawnKindDef Slimequeen = PawnKindDefOf.Slimequeen;
  25. float points = StorytellerUtility.DefaultParmsNow(Find.Storyteller.def, IncidentCategory.ThreatBig, map).points;
  26. int num = GenMath.RoundRandom(points / Slimequeen.combatPower);
  27. int max = Rand.RangeInclusive(2, 4);
  28. num = Mathf.Clamp(num, 1, max);
  29. int num2 = Rand.RangeInclusive(90000, 150000);
  30. IntVec3 invalid = IntVec3.Invalid;
  31. if (!RCellFinder.TryFindRandomCellOutsideColonyNearTheCenterOfTheMap(intVec, map, 10f, out invalid))
  32. {
  33. invalid = IntVec3.Invalid;
  34. }
  35. Pawn pawn = null;
  36. for (int i = 0; i < num; i++)
  37. {
  38. IntVec3 loc = CellFinder.RandomClosewalkCellNear(intVec, map, 10);
  39. pawn = PawnGenerator.GeneratePawn(Slimequeen, null);
  40. GenSpawn.Spawn(pawn, loc, map, Rot4.Random);
  41. pawn.mindState.exitMapAfterTick = Find.TickManager.TicksGame + num2;
  42. if (invalid.IsValid)
  43. {
  44. pawn.mindState.forcedGotoPosition = CellFinder.RandomClosewalkCellNear(invalid, map, 10);
  45. }
  46. }
  47. Find.LetterStack.ReceiveLetter("LetterLabelSlimequeens".Translate(new object[]
  48. {
  49. Slimequeen.label
  50. }).CapitalizeFirst(), "LetterSlimequeens".Translate(new object[]
  51. {
  52. Slimequeen.label
  53. }), LetterType.Good, pawn, null);
  54. return true;
  55. }
  56. }
  57. }
Add Comment
Please, Sign In to add comment