Clothing.ts 5.0 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142
  1. /// <reference path="../Thing.ts" />
  2. interface ClothingOptions extends ThingOptions {
  3. topDescription? : Say;
  4. bottomDescription? : Say;
  5. feetDescription? : Say;
  6. }
  7. interface ClothingWearerValue {
  8. weight : number;
  9. value : number;
  10. }
  11. class Clothing extends Thing {
  12. public slots : Array<number> = [];
  13. public transparentSlots : Array<number> = [];
  14. public layer : number = Clothing.LAYER_MEDIUM;
  15. public isVisible = false;
  16. public visibleOn : Array<number> = [];
  17. // Padding: gets added to current size. Can be negative
  18. // max: If current size > max, current size = max. On -1 this is not considered.
  19. // tight: If current size > tight, person becomes tight. On -1 this is not considered.
  20. // loose: if current size < loose, person becomes loose - can be overriden by covering clothes
  21. // If something is not used, leave as undefined
  22. // Would be fun to make them burst if too much over max, but that's not going to be used right now
  23. public breastPadding : number = 0;
  24. public maxBreastSize : number = -1;
  25. public tightBreastSize : number = -1;
  26. public looseBreastSize : number = 0;
  27. // Padding: gets added to current size. Can be negative
  28. // max: If current size > max, current size = max. On -1 this is not considered.
  29. // tight: If current size > tight, person becomes tight. On -1 this is not considered.
  30. // loose: if current size < loose, person becomes loose - can be overriden by covering clothes
  31. // If something is not used, leave as undefined
  32. // Would be fun to make them burst if too much over max, but that's not going to be used right now
  33. public crotchPadding : number = 0;
  34. public maxCrotchSize : number = -1;
  35. public tightCrotchSize : number = -1;
  36. public looseCrotchSize : number = 0;
  37. // Padding: gets added to current size. Can be negative
  38. // max: If current size > max, current size = max. On -1 this is not considered.
  39. // tight: If current size > tight, person becomes tight. On -1 this is not considered.
  40. // loose: if current size < loose, person becomes loose - can be overriden by covering clothes
  41. // If something is not used, leave as undefined
  42. // Would be fun to make them burst if too much over max, but that's not going to be used right now
  43. public buttPadding : number = 0;
  44. public maxButtSize : number = -1;
  45. public tightButtSize : number = -1;
  46. public looseButtSize : number = 0;
  47. /**
  48. * This function must be called any time anything could change clothing on a person.
  49. * Ripped a clothing? Update all clothes.
  50. * Changed breast size? Update all clothes.
  51. */
  52. public updateStatus () {
  53. this.visibleOn = [];
  54. this.visibleOn.push(...this.slots);
  55. let wearer = Thing.WearRelation.getLeft(this);
  56. if (wearer == undefined) return;
  57. let cloths = Thing.WearRelation.getRight(wearer);
  58. let coveredSlots = [];
  59. for (let i = 0; i < cloths.length; i++) {
  60. let worn = cloths[i];
  61. if ((worn != this) && worn.layer > this.layer) {
  62. coveredSlots.push(...worn.getCoveringSlots());
  63. }
  64. }
  65. this.visibleOn = this.visibleOn.filter(visible => {
  66. return coveredSlots.indexOf(visible) == -1;
  67. });
  68. this.isVisible = this.visibleOn.length > 0;
  69. }
  70. public getCoveringSlots () {
  71. if (this.transparentSlots.length == 0) {
  72. return this.slots.slice(0);
  73. }
  74. return this.slots.filter((value, index, array) => {
  75. return this.transparentSlots.indexOf(value) == -1;
  76. });
  77. }
  78. public static LAYER_LOWEST = 0;
  79. public static LAYER_LOW = 5;
  80. public static LAYER_MEDIUM = 10;
  81. public static LAYER_HIGH = 15;
  82. public static LAYER_HIGHEST = 20;
  83. public genderValue : number = 50;
  84. public sluttinessValue : number = 40;
  85. public getGenderWeight () {
  86. return this.visibleOn.length;
  87. }
  88. public getGenderValue () {
  89. return this.genderValue;
  90. }
  91. public getSluttinessWeight () {
  92. return this.visibleOn.length;
  93. }
  94. public getSluttinessValue () {
  95. return this.sluttinessValue;
  96. }
  97. public static getGenderValueOn (p : Thing) : ClothingWearerValue {
  98. let weight = 0;
  99. let value = 0;
  100. let clothes = Thing.WearRelation.getRight(p);
  101. for (let i = 0; i < clothes.length; i++) {
  102. weight += clothes[i].getGenderWeight();
  103. value += clothes[i].getGenderWeight() * clothes[i].getGenderValue();
  104. }
  105. return {
  106. weight : weight,
  107. value : value
  108. };
  109. }
  110. public static getSluttinessValueOn (p : Thing) : ClothingWearerValue {
  111. let weight = 0;
  112. let value = 0;
  113. let clothes = Thing.WearRelation.getRight(p);
  114. for (let i = 0; i < clothes.length; i++) {
  115. weight += clothes[i].getSluttinessWeight();
  116. value += clothes[i].getSluttinessWeight() * clothes[i].getSluttinessValue();
  117. }
  118. return {
  119. weight : weight,
  120. value : value
  121. };
  122. }
  123. }