@makefully/platypus 4.1.4 → 4.1.6

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
Files changed (134) hide show
  1. package/CHANGELOG.md +20 -0
  2. package/README.md +4 -2
  3. package/lib/platypus.js +1 -1
  4. package/package.json +7 -2
  5. package/src/AABB.js +685 -0
  6. package/src/ActionState.js +121 -0
  7. package/src/AssetManager.js +206 -0
  8. package/src/CollisionData.js +96 -0
  9. package/src/CollisionDataContainer.js +127 -0
  10. package/src/CollisionShape.js +315 -0
  11. package/src/Component.js +231 -0
  12. package/src/Data.js +64 -0
  13. package/src/DataMap.js +204 -0
  14. package/src/Entity.js +404 -0
  15. package/src/EntityLinker.js +113 -0
  16. package/src/EventHandler.js +115 -0
  17. package/src/EventHandlerList.js +251 -0
  18. package/src/Game.js +840 -0
  19. package/src/Gamepad.js +175 -0
  20. package/src/ID3CaptionPlayer.js +61 -0
  21. package/src/Messenger.js +365 -0
  22. package/src/PIXIAnimation.js +622 -0
  23. package/src/RandomSet.js +140 -0
  24. package/src/SFXPlayer.js +120 -0
  25. package/src/StateMap.js +252 -0
  26. package/src/Storage.js +152 -0
  27. package/src/TickerClient.js +48 -0
  28. package/src/TickerServer.js +23 -0
  29. package/src/TimeEvent.js +50 -0
  30. package/src/TimeEventList.js +100 -0
  31. package/src/VOPlayer.js +684 -0
  32. package/src/Vector.js +702 -0
  33. package/src/components/AIChaser.js +161 -0
  34. package/src/components/AIPacer.js +107 -0
  35. package/src/components/AudioMusic.js +151 -0
  36. package/src/components/AudioSFX.js +673 -0
  37. package/src/components/AudioVO.js +301 -0
  38. package/src/components/CollisionBasic.js +826 -0
  39. package/src/components/CollisionFilter.js +74 -0
  40. package/src/components/CollisionGroup.js +448 -0
  41. package/src/components/CollisionTiles.js +608 -0
  42. package/src/components/ComponentSwitcher.js +173 -0
  43. package/src/components/ControllerInput.js +65 -0
  44. package/src/components/Counter.js +165 -0
  45. package/src/components/EntityCamera.js +215 -0
  46. package/src/components/EntityContainer.js +549 -0
  47. package/src/components/EntityController.js +541 -0
  48. package/src/components/HandlerCamera.js +1052 -0
  49. package/src/components/HandlerCollision.js +1318 -0
  50. package/src/components/HandlerController.js +291 -0
  51. package/src/components/HandlerLogic.js +394 -0
  52. package/src/components/HandlerRender.js +217 -0
  53. package/src/components/Interactive.js +502 -0
  54. package/src/components/LevelBuilder.js +524 -0
  55. package/src/components/LogicAngularMovement.js +154 -0
  56. package/src/components/LogicAttachment.js +265 -0
  57. package/src/components/LogicButton.js +466 -0
  58. package/src/components/LogicCarrier.js +39 -0
  59. package/src/components/LogicDestroyMe.js +58 -0
  60. package/src/components/LogicDirectionalMovement.js +325 -0
  61. package/src/components/LogicDragDrop.js +371 -0
  62. package/src/components/LogicImpactLaunch.js +144 -0
  63. package/src/components/LogicPacingPlatform.js +64 -0
  64. package/src/components/LogicPortable.js +112 -0
  65. package/src/components/LogicPortal.js +115 -0
  66. package/src/components/LogicPushable.js +98 -0
  67. package/src/components/LogicRebounder.js +136 -0
  68. package/src/components/LogicRegionSpawner.js +139 -0
  69. package/src/components/LogicRotationalMovement.js +205 -0
  70. package/src/components/LogicSpawner.js +159 -0
  71. package/src/components/LogicStateMachine.js +382 -0
  72. package/src/components/LogicSwitch.js +77 -0
  73. package/src/components/LogicTeleportee.js +68 -0
  74. package/src/components/LogicTeleporter.js +93 -0
  75. package/src/components/LogicTimer.js +178 -0
  76. package/src/components/LogicWindUpRacer.js +179 -0
  77. package/src/components/Motion.js +371 -0
  78. package/src/components/Mover.js +566 -0
  79. package/src/components/Node.js +289 -0
  80. package/src/components/NodeMap.js +295 -0
  81. package/src/components/NodeResident.js +636 -0
  82. package/src/components/Orientation.js +697 -0
  83. package/src/components/RandomEvents.js +73 -0
  84. package/src/components/RelativePosition.js +204 -0
  85. package/src/components/RelayFamily.js +106 -0
  86. package/src/components/RelayGame.js +53 -0
  87. package/src/components/RelayLinker.js +94 -0
  88. package/src/components/RelayParent.js +57 -0
  89. package/src/components/RelaySelf.js +55 -0
  90. package/src/components/Render.js +178 -0
  91. package/src/components/RenderAnimator.js +275 -0
  92. package/src/components/RenderContainer.js +646 -0
  93. package/src/components/RenderDebug.js +319 -0
  94. package/src/components/RenderDestroyMe.js +59 -0
  95. package/src/components/RenderLottie.js +149 -0
  96. package/src/components/RenderProgress.js +120 -0
  97. package/src/components/RenderSpine.js +833 -0
  98. package/src/components/RenderSprite.js +527 -0
  99. package/src/components/RenderText.js +147 -0
  100. package/src/components/RenderTiles.js +1391 -0
  101. package/src/components/SceneChanger.js +128 -0
  102. package/src/components/TiledLoader.js +1451 -0
  103. package/src/components/Timeline.js +314 -0
  104. package/src/components/Tutorial.js +267 -0
  105. package/src/components/Tween.js +296 -0
  106. package/src/components/VoiceOver.js +373 -0
  107. package/src/components/XHR.js +129 -0
  108. package/src/components/index.js +79 -0
  109. package/src/factory.js +305 -0
  110. package/src/index.js +159 -0
  111. package/src/mixins/PIXI.Graphics.js +41 -0
  112. package/src/platypus.css +68 -0
  113. package/src/sayHello.js +50 -0
  114. package/src/shapes/Capsule.js +74 -0
  115. package/src/shapes/Circle.js +43 -0
  116. package/src/shapes/Ellipse.js +117 -0
  117. package/src/shapes/Point.js +191 -0
  118. package/src/shapes/Polygon.js +112 -0
  119. package/src/shapes/Polyline.js +97 -0
  120. package/src/shapes/Rectangle.js +78 -0
  121. package/src/shapes/RoundedRectangle.js +33 -0
  122. package/src/shapes/Segment.js +346 -0
  123. package/src/shapes/adjustedXY.js +19 -0
  124. package/src/shapes/castFromBox2D.js +92 -0
  125. package/src/shapes/castFromObject.js +53 -0
  126. package/src/shapes/castFromPixiGraphics.js +6 -0
  127. package/src/shapes/castFromPixiShape.js +89 -0
  128. package/src/shapes/castToBox2D.js +190 -0
  129. package/src/shapes/castToPixiGraphics.js +100 -0
  130. package/src/shapes/castToPixiShape.js +61 -0
  131. package/src/shapes/checkPointsMap.js +313 -0
  132. package/src/shapes/index.js +35 -0
  133. package/src/utils/array.js +73 -0
  134. package/src/utils/string.js +39 -0
@@ -0,0 +1,265 @@
1
+ import Entity from '../Entity.js';
2
+ import {arrayCache} from '../utils/array.js';
3
+ import createComponentClass from '../factory.js';
4
+
5
+ export default createComponentClass(/** @lends platypus.components.LogicAttachment.prototype */{
6
+
7
+ id: 'LogicAttachment',
8
+
9
+ properties: {
10
+ /**
11
+ * An owner state, set to true when the attachment is attached. Meant to be read by other components or used in rendering.
12
+ *
13
+ * @property attachState
14
+ * @type String
15
+ * @default 'attached'
16
+ */
17
+ attachState: 'attached',
18
+
19
+ /**
20
+ * The type of the entity to be attached.
21
+ *
22
+ * @property attachment
23
+ * @type String
24
+ * @default ''
25
+ */
26
+ attachment: '',
27
+
28
+ /**
29
+ * The entity properties that should be updated on attached entity.
30
+ *
31
+ * @property updateProperties
32
+ * @type Array
33
+ * @default ["x", "y", "z"]
34
+ */
35
+ updateProperties: null,
36
+
37
+ /**
38
+ * This is an object of key/value pairs. The keys are events this component is listening for locally, the value is the new event to be broadcast on the attached entity. The value can also be an array of events to be fired.
39
+ *
40
+ * "events": {
41
+ * "sleeping": "good-night",
42
+ * "awake": ["alarm", "get-up"]
43
+ * }
44
+ *
45
+ * @property events
46
+ * @type Object
47
+ * @default null
48
+ */
49
+ events: null,
50
+
51
+ /**
52
+ * Whether the attachment starts out attached.
53
+ *
54
+ * @property startAttached
55
+ * @type Boolean
56
+ * @default false
57
+ */
58
+ startAttached: false,
59
+
60
+ /**
61
+ * The offset of the attached entity in x from the attachee.
62
+ *
63
+ * @property offsetX
64
+ * @type Number
65
+ * @default 0
66
+ */
67
+ offsetX: 0,
68
+
69
+ /**
70
+ * The offset of the attached entity in y from the attachee.
71
+ *
72
+ * @property offsetY
73
+ * @type Number
74
+ * @default 0
75
+ */
76
+ offsetY: 0,
77
+
78
+ /**
79
+ * The offset of the attached entity in z from the attachee.
80
+ *
81
+ * @property offsetZ
82
+ * @type Number
83
+ * @default 0
84
+ */
85
+ offsetZ: 0.01
86
+ },
87
+
88
+ /**
89
+ * Creates an entity and connects it with the owner entity. This is useful for entities that have a one-to-one relationship with a given entity and must move as if connected to the host entity.
90
+ *
91
+ * @memberof platypus.components
92
+ * @uses platypus.Component
93
+ * @constructs
94
+ * @listens platypus.Entity#attach
95
+ * @listens platypus.Entity#change-attachment-offset
96
+ * @listens platypus.Entity#detach
97
+ * @listens platypus.Entity#handle-logic
98
+ */
99
+ initialize: function () {
100
+ const
101
+ events = this.events;
102
+
103
+ this.state = this.owner.state;
104
+
105
+ this.state.set(this.attachState, this.startAttached);
106
+ this.attachmentPosition = {
107
+ x: 0,
108
+ y: 0,
109
+ z: 0,
110
+ dx: 0,
111
+ dy: 0
112
+ };
113
+ this.attachmentProperties = {
114
+ type: this.attachment,
115
+ properties: this.attachmentPosition
116
+ };
117
+ if (this.updateProperties === null) {
118
+ this.updateProperties = ['x', 'y', 'z'];
119
+ }
120
+
121
+ this.attachment = null;
122
+ this.isAttached = this.startAttached;
123
+
124
+ // Messages that this component listens for and then triggers on the attached entity.
125
+ if (events) {
126
+ const
127
+ keys = Object.keys(events),
128
+ {length} = keys;
129
+
130
+ for (let i = 0; i < length; i++) {
131
+ const
132
+ key = keys[i],
133
+ event = events[key];
134
+
135
+ this.addEventListener(key, (...args) => {
136
+ const
137
+ {attachment} = this;
138
+
139
+ if (attachment) {
140
+ attachment.trigger.call(attachment, event, ...args);
141
+ }
142
+ });
143
+ }
144
+ }
145
+ },
146
+
147
+ events: {
148
+ "handle-logic": function () {
149
+ const
150
+ {attachmentPosition, owner, state, updateProperties} = this;
151
+
152
+ if (!owner.destroyed) {
153
+ if (this.isAttached) {
154
+ if (!this.attachment) {
155
+ updateProperties.forEach((property) => attachmentPosition[property] = owner[property]);
156
+ this.attachment = this.owner.parent.addEntity(this.attachmentProperties);
157
+ }
158
+
159
+ if (this.attachment.destroyed) {
160
+ owner.parent.removeEntity(this.attachment);
161
+ this.attachment = null;
162
+ this.isAttached = false;
163
+ } else {
164
+ // New way (gets overridden by old way atm):
165
+ updateProperties.forEach((property) => this.attachment[property] = owner[property]);
166
+
167
+ // Old way:
168
+ let
169
+ {offsetX, offsetY} = this;
170
+
171
+ this.attachment.x = owner.x;
172
+ if (state.get('left')) { //TODO: Base this on object orientation. - DDD 3/2/2016
173
+ offsetX *= -1;
174
+ this.attachment.rotation = 180;
175
+ } else if (state.get('right')) {
176
+ this.attachment.rotation = 0;
177
+ }
178
+ this.attachment.x += offsetX;
179
+
180
+ this.attachment.y = owner.y;
181
+ if (state.get('top')) {
182
+ offsetY *= -1;
183
+ this.attachment.rotation = 90;
184
+ } else if (state.get('bottom')) {
185
+ this.attachment.rotation = -90;
186
+ }
187
+ this.attachment.y += offsetY;
188
+
189
+ this.attachment.z = owner.z;
190
+ this.attachment.z += this.offsetZ;
191
+ }
192
+ } else if (this.attachment) {
193
+ this.owner.parent.removeEntity(this.attachment);
194
+ this.attachment = null;
195
+ }
196
+
197
+ state.set(this.attachState, this.isAttached);
198
+ }
199
+ },
200
+
201
+ /**
202
+ * Creates and attaches the entity. The input value makes it possible to attach the entity on user input.
203
+ *
204
+ * @event platypus.Entity#attach
205
+ * @param input {Object} An input object.
206
+ * @param input.pressed {Boolean} If set to true, the entity is created and attached.
207
+ */
208
+ "attach": function (input) {
209
+ this.isAttached = !input || (input.pressed !== false);
210
+ },
211
+
212
+ /**
213
+ * Detaches and removes the entity.
214
+ *
215
+ * @event platypus.Entity#detach
216
+ */
217
+ "detach": function () {
218
+ this.isAttached = false;
219
+ },
220
+
221
+ /**
222
+ * Changes the x, y, and z offset of the attachment.
223
+ *
224
+ * @event platypus.Entity#change-attachment-offset
225
+ * @param offset {Object} An object containing the offset values.
226
+ * @param input.x {Number} The new X offset.
227
+ * @param input.y {Number} The new Y offset.
228
+ * @param input.y {Number} The new Z offset.
229
+ */
230
+ "change-attachment-offset": function (offset) {
231
+ if (typeof offset.x !== 'undefined') {
232
+ this.offsetX = offset.x;
233
+ } else if (typeof offset.y !== 'undefined') {
234
+ this.offsetY = offset.y;
235
+ } else if (typeof offset.z !== 'undefined') {
236
+ this.offsetZ = offset.z;
237
+ }
238
+ }
239
+ },
240
+
241
+ methods: {
242
+ destroy: function () {
243
+ this.state.set(this.attachState, false);
244
+ if (this.attachment) {
245
+ this.owner.parent.removeEntity(this.attachment);
246
+ this.attachment = null;
247
+ }
248
+ this.isAttached = false;
249
+ this.state = null;
250
+ }
251
+ },
252
+
253
+ getAssetList: function (def, props, defaultProps) {
254
+ const
255
+ attachment = def?.attachment ?? props?.attachment ?? defaultProps?.attachment;
256
+
257
+ if (attachment) {
258
+ return Entity.getAssetList({
259
+ type: attachment
260
+ });
261
+ }
262
+
263
+ return arrayCache.setUp();
264
+ }
265
+ });