balistafreak

Metamorphosis

Jan 28th, 2021
80
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
text 2.49 KB | None | 0 0
  1. using System;
  2. using RimWorld;
  3. using Verse;
  4. using Verse.Sound;
  5.  
  6. namespace AlphaBehavioursAndEvents
  7. {
  8. // Token: 0x02000013 RID: 19
  9. public class CompMetamorphosis : ThingComp
  10. {
  11. // Token: 0x17000019 RID: 25
  12. // (get) Token: 0x06000056 RID: 86 RVA: 0x00003B01 File Offset: 0x00001D01
  13. public CompProperties_Metamorphosis Props
  14. {
  15. get
  16. {
  17. return (CompProperties_Metamorphosis)this.props;
  18. }
  19. }
  20.  
  21. // Token: 0x06000057 RID: 87 RVA: 0x00003B0E File Offset: 0x00001D0E
  22. public override void PostExposeData()
  23. {
  24. base.PostExposeData();
  25. Scribe_Values.Look<int>(ref this.metamorphosisTick, "metamorphosisTick", 0, false);
  26. }
  27.  
  28. // Token: 0x06000058 RID: 88 RVA: 0x00003B28 File Offset: 0x00001D28
  29. public override void CompTickRare()
  30. {
  31. base.CompTickRare();
  32. if (this.parent.Map != null)
  33. {
  34. this.metamorphosisTick++;
  35. if ((float)this.metamorphosisTick > (float)this.rareTicksInAYear * this.Props.timeInYears)
  36. {
  37. Faction faction = this.parent.Faction;
  38. GenSpawn.Spawn(PawnGenerator.GeneratePawn(new PawnGenerationRequest(PawnKindDef.Named(this.Props.pawnToTurnInto), faction, PawnGenerationContext.NonPlayer, -1, false, true, false, false, true, false, 1f, false, true, true, false, false, false, false, false, 0f, null, 1f, null, null, null, null, null, null, null, null, null, null, null, null)), CellFinder.RandomClosewalkCellNear(this.parent.Position, this.parent.Map, 3, null), this.parent.Map, WipeMode.Vanish);
  39. for (int i = 0; i < 20; i++)
  40. {
  41. IntVec3 c;
  42. CellFinder.TryFindRandomReachableCellNear(this.parent.Position, this.parent.Map, 2f, TraverseParms.For(TraverseMode.NoPassClosedDoors, Danger.Deadly, false), null, null, out c, 999999);
  43. FilthMaker.TryMakeFilth(c, this.parent.Map, ThingDefOf.Filth_AmnioticFluid, 1, FilthSourceFlags.None);
  44. }
  45. SoundDefOf.Hive_Spawn.PlayOneShot(new TargetInfo(this.parent.Position, this.parent.Map, false));
  46. this.parent.Destroy(DestroyMode.Vanish);
  47. }
  48. }
  49. }
  50.  
  51. // Token: 0x06000059 RID: 89 RVA: 0x00003CB4 File Offset: 0x00001EB4
  52. public override string CompInspectStringExtra()
  53. {
  54. int numTicks = (int)(((float)this.rareTicksInAYear * this.Props.timeInYears - (float)this.metamorphosisTick) * 250f);
  55. return this.Props.reportString.Translate(numTicks.ToStringTicksToPeriod(false, false, false, true));
  56. }
  57.  
  58. // Token: 0x0400001B RID: 27
  59. public int metamorphosisTick;
  60.  
  61. // Token: 0x0400001C RID: 28
  62. public int rareTicksInAYear = 14400;
  63. }
  64. }
Advertisement
Add Comment
Please, Sign In to add comment