| | 1 | | using System; |
| | 2 | | using System.Collections.Generic; |
| | 3 | | using DCL.CameraTool; |
| | 4 | | using DCL.Helpers; |
| | 5 | | using DCL.Models; |
| | 6 | | using Newtonsoft.Json; |
| | 7 | | using UnityEngine; |
| | 8 | | using Ray = UnityEngine.Ray; |
| | 9 | |
|
| | 10 | | #if UNITY_WEBGL && !UNITY_EDITOR |
| | 11 | | using System.Runtime.InteropServices; |
| | 12 | | #endif |
| | 13 | |
|
| | 14 | | namespace DCL.Interface |
| | 15 | | { |
| | 16 | | /** |
| | 17 | | * This class contains the outgoing interface of Decentraland. |
| | 18 | | * You must call those functions to interact with the WebInterface. |
| | 19 | | * |
| | 20 | | * The messages comming from the WebInterface instead, are reported directly to |
| | 21 | | * the handler GameObject by name. |
| | 22 | | */ |
| | 23 | | public static class WebInterface |
| | 24 | | { |
| | 25 | | public static bool VERBOSE = false; |
| | 26 | |
|
| | 27 | | [System.Serializable] |
| | 28 | | public class ReportPositionPayload |
| | 29 | | { |
| | 30 | | /** Camera position, world space */ |
| | 31 | | public Vector3 position; |
| | 32 | |
|
| | 33 | | /** Character rotation */ |
| | 34 | | public Quaternion rotation; |
| | 35 | |
|
| | 36 | | /** Camera rotation */ |
| | 37 | | public Quaternion cameraRotation; |
| | 38 | |
|
| | 39 | | /** Camera height, relative to the feet of the avatar or ground */ |
| | 40 | | public float playerHeight; |
| | 41 | |
|
| | 42 | | public Vector3 mousePosition; |
| | 43 | |
|
| | 44 | | public string id; |
| | 45 | | } |
| | 46 | |
|
| | 47 | | [System.Serializable] |
| | 48 | | public abstract class ControlEvent |
| | 49 | | { |
| | 50 | | public string eventType; |
| | 51 | | } |
| | 52 | |
|
| | 53 | | public abstract class ControlEvent<T> : ControlEvent |
| | 54 | | { |
| | 55 | | public T payload; |
| | 56 | |
|
| 415 | 57 | | protected ControlEvent(string eventType, T payload) |
| | 58 | | { |
| 415 | 59 | | this.eventType = eventType; |
| 415 | 60 | | this.payload = payload; |
| 415 | 61 | | } |
| | 62 | | } |
| | 63 | |
|
| | 64 | | [System.Serializable] |
| | 65 | | public class SceneReady : ControlEvent<SceneReady.Payload> |
| | 66 | | { |
| | 67 | | [System.Serializable] |
| | 68 | | public class Payload |
| | 69 | | { |
| | 70 | | public string sceneId; |
| | 71 | | } |
| | 72 | |
|
| | 73 | | public SceneReady(string sceneId) : base("SceneReady", new Payload() { sceneId = sceneId }) { } |
| | 74 | | } |
| | 75 | |
|
| | 76 | | [System.Serializable] |
| | 77 | | public class ActivateRenderingACK : ControlEvent<object> |
| | 78 | | { |
| | 79 | | public ActivateRenderingACK() : base("ActivateRenderingACK", null) { } |
| | 80 | | } |
| | 81 | |
|
| | 82 | | [System.Serializable] |
| | 83 | | public class DeactivateRenderingACK : ControlEvent<object> |
| | 84 | | { |
| | 85 | | public DeactivateRenderingACK() : base("DeactivateRenderingACK", null) { } |
| | 86 | | } |
| | 87 | |
|
| | 88 | | [System.Serializable] |
| | 89 | | public class SceneEvent<T> |
| | 90 | | { |
| | 91 | | public string sceneId; |
| | 92 | | public string eventType; |
| | 93 | | public T payload; |
| | 94 | | } |
| | 95 | |
|
| | 96 | | [System.Serializable] |
| | 97 | | public class AllScenesEvent<T> |
| | 98 | | { |
| | 99 | | public string eventType; |
| | 100 | | public T payload; |
| | 101 | | } |
| | 102 | |
|
| | 103 | | [System.Serializable] |
| | 104 | | public class UUIDEvent<TPayload> |
| | 105 | | where TPayload : class, new() |
| | 106 | | { |
| | 107 | | public string uuid; |
| | 108 | | public TPayload payload = new TPayload(); |
| | 109 | | } |
| | 110 | |
|
| | 111 | | public enum ACTION_BUTTON |
| | 112 | | { |
| | 113 | | POINTER = 0, |
| | 114 | | PRIMARY = 1, |
| | 115 | | SECONDARY = 2, |
| | 116 | | ANY = 3, |
| | 117 | | FORWARD = 4, |
| | 118 | | BACKWARD = 5, |
| | 119 | | RIGHT = 6, |
| | 120 | | LEFT = 7, |
| | 121 | | JUMP = 8, |
| | 122 | | WALK = 9, |
| | 123 | | ACTION_3 = 10, |
| | 124 | | ACTION_4 = 11, |
| | 125 | | ACTION_5 = 12, |
| | 126 | | ACTION_6 = 13 |
| | 127 | | } |
| | 128 | |
|
| | 129 | | [System.Serializable] |
| | 130 | | public class OnClickEvent : UUIDEvent<OnClickEventPayload> { }; |
| | 131 | |
|
| | 132 | | [System.Serializable] |
| | 133 | | public class CameraModePayload |
| | 134 | | { |
| | 135 | | public CameraMode.ModeId cameraMode; |
| | 136 | | }; |
| | 137 | |
|
| | 138 | | [System.Serializable] |
| | 139 | | public class Web3UseResponsePayload |
| | 140 | | { |
| | 141 | | public string id; |
| | 142 | | public bool result; |
| | 143 | | }; |
| | 144 | |
|
| | 145 | | [System.Serializable] |
| | 146 | | public class IdleStateChangedPayload |
| | 147 | | { |
| | 148 | | public bool isIdle; |
| | 149 | | }; |
| | 150 | |
|
| | 151 | | [System.Serializable] |
| | 152 | | public class OnPointerDownEvent : UUIDEvent<OnPointerEventPayload> { }; |
| | 153 | |
|
| | 154 | | [System.Serializable] |
| | 155 | | public class OnGlobalPointerEvent |
| | 156 | | { |
| | 157 | | public OnGlobalPointerEventPayload payload = new OnGlobalPointerEventPayload(); |
| | 158 | | }; |
| | 159 | |
|
| | 160 | | [System.Serializable] |
| | 161 | | public class OnPointerUpEvent : UUIDEvent<OnPointerEventPayload> { }; |
| | 162 | |
|
| | 163 | | [System.Serializable] |
| | 164 | | private class OnTextSubmitEvent : UUIDEvent<OnTextSubmitEventPayload> { }; |
| | 165 | |
|
| | 166 | | [System.Serializable] |
| | 167 | | private class OnTextInputChangeEvent : UUIDEvent<OnTextInputChangeEventPayload> { }; |
| | 168 | |
|
| | 169 | | [System.Serializable] |
| | 170 | | private class OnTextInputChangeTextEvent : UUIDEvent<OnTextInputChangeTextEventPayload> { }; |
| | 171 | |
|
| | 172 | | [System.Serializable] |
| | 173 | | private class OnScrollChangeEvent : UUIDEvent<OnScrollChangeEventPayload> { }; |
| | 174 | |
|
| | 175 | | [System.Serializable] |
| | 176 | | private class OnFocusEvent : UUIDEvent<EmptyPayload> { }; |
| | 177 | |
|
| | 178 | | [System.Serializable] |
| | 179 | | private class OnBlurEvent : UUIDEvent<EmptyPayload> { }; |
| | 180 | |
|
| | 181 | | [System.Serializable] |
| | 182 | | public class OnEnterEvent : UUIDEvent<OnEnterEventPayload> { }; |
| | 183 | |
|
| | 184 | | [System.Serializable] |
| | 185 | | public class OnClickEventPayload |
| | 186 | | { |
| | 187 | | public ACTION_BUTTON buttonId = ACTION_BUTTON.POINTER; |
| | 188 | | } |
| | 189 | |
|
| | 190 | | [System.Serializable] |
| | 191 | | public class SendChatMessageEvent |
| | 192 | | { |
| | 193 | | public ChatMessage message; |
| | 194 | | } |
| | 195 | |
|
| | 196 | | [System.Serializable] |
| | 197 | | public class RemoveEntityComponentsPayLoad |
| | 198 | | { |
| | 199 | | public string entityId; |
| | 200 | | public string componentId; |
| | 201 | | }; |
| | 202 | |
|
| | 203 | | [System.Serializable] |
| | 204 | | public class StoreSceneStateEvent |
| | 205 | | { |
| | 206 | | public string type = "StoreSceneState"; |
| | 207 | | public string payload = ""; |
| | 208 | | }; |
| | 209 | |
|
| | 210 | | [System.Serializable] |
| | 211 | | public class OnPointerEventPayload |
| | 212 | | { |
| | 213 | | [System.Serializable] |
| | 214 | | public class Hit |
| | 215 | | { |
| | 216 | | public Vector3 origin; |
| | 217 | | public float length; |
| | 218 | | public Vector3 hitPoint; |
| | 219 | | public Vector3 normal; |
| | 220 | | public Vector3 worldNormal; |
| | 221 | | public string meshName; |
| | 222 | | public string entityId; |
| | 223 | | } |
| | 224 | |
|
| | 225 | | public ACTION_BUTTON buttonId; |
| | 226 | | public Vector3 origin; |
| | 227 | | public Vector3 direction; |
| | 228 | | public Hit hit; |
| | 229 | | } |
| | 230 | |
|
| | 231 | | [System.Serializable] |
| | 232 | | public class OnGlobalPointerEventPayload : OnPointerEventPayload |
| | 233 | | { |
| | 234 | | public enum InputEventType |
| | 235 | | { |
| | 236 | | DOWN, |
| | 237 | | UP |
| | 238 | | } |
| | 239 | |
|
| | 240 | | public InputEventType type; |
| | 241 | | } |
| | 242 | |
|
| | 243 | | [System.Serializable] |
| | 244 | | public class OnTextSubmitEventPayload |
| | 245 | | { |
| | 246 | | public string id; |
| | 247 | | public string text; |
| | 248 | | } |
| | 249 | |
|
| | 250 | | [System.Serializable] |
| | 251 | | public class OnTextInputChangeEventPayload |
| | 252 | | { |
| | 253 | | public string value; |
| | 254 | | } |
| | 255 | |
|
| | 256 | | [System.Serializable] |
| | 257 | | public class OnTextInputChangeTextEventPayload |
| | 258 | | { |
| | 259 | | [System.Serializable] |
| | 260 | | public class Payload |
| | 261 | | { |
| | 262 | | public string value; |
| | 263 | | public bool isSubmit; |
| | 264 | | } |
| | 265 | |
|
| | 266 | | public Payload value = new Payload(); |
| | 267 | | } |
| | 268 | |
|
| | 269 | | [System.Serializable] |
| | 270 | | public class OnScrollChangeEventPayload |
| | 271 | | { |
| | 272 | | public Vector2 value; |
| | 273 | | public int pointerId; |
| | 274 | | } |
| | 275 | |
|
| | 276 | | [System.Serializable] |
| | 277 | | public class EmptyPayload { } |
| | 278 | |
|
| | 279 | | [System.Serializable] |
| | 280 | | public class MetricsModel |
| | 281 | | { |
| | 282 | | public int meshes; |
| | 283 | | public int bodies; |
| | 284 | | public int materials; |
| | 285 | | public int textures; |
| | 286 | | public int triangles; |
| | 287 | | public int entities; |
| | 288 | |
|
| | 289 | | public static MetricsModel operator +(MetricsModel lhs, MetricsModel rhs) |
| | 290 | | { |
| | 291 | | return new MetricsModel() |
| | 292 | | { |
| | 293 | | meshes = lhs.meshes + rhs.meshes, |
| | 294 | | bodies = lhs.bodies + rhs.bodies, |
| | 295 | | materials = lhs.materials + rhs.materials, |
| | 296 | | textures = lhs.textures + rhs.textures, |
| | 297 | | triangles = lhs.triangles + rhs.triangles, |
| | 298 | | entities = lhs.entities + rhs.entities |
| | 299 | | }; |
| | 300 | | } |
| | 301 | | } |
| | 302 | |
|
| | 303 | | [System.Serializable] |
| | 304 | | private class OnMetricsUpdate |
| | 305 | | { |
| | 306 | | public MetricsModel given = new MetricsModel(); |
| | 307 | | public MetricsModel limit = new MetricsModel(); |
| | 308 | | } |
| | 309 | |
|
| | 310 | | [System.Serializable] |
| | 311 | | public class OnEnterEventPayload { } |
| | 312 | |
|
| | 313 | | [System.Serializable] |
| | 314 | | public class TransformPayload |
| | 315 | | { |
| | 316 | | public Vector3 position = Vector3.zero; |
| | 317 | | public Quaternion rotation = Quaternion.identity; |
| | 318 | | public Vector3 scale = Vector3.one; |
| | 319 | | } |
| | 320 | |
|
| | 321 | | public class OnSendScreenshot |
| | 322 | | { |
| | 323 | | public string id; |
| | 324 | | public string encodedTexture; |
| | 325 | | }; |
| | 326 | |
|
| | 327 | | [System.Serializable] |
| | 328 | | public class GotoEvent |
| | 329 | | { |
| | 330 | | public int x; |
| | 331 | | public int y; |
| | 332 | | }; |
| | 333 | |
|
| | 334 | | [System.Serializable] |
| | 335 | | public class BaseResolution |
| | 336 | | { |
| | 337 | | public int baseResolution; |
| | 338 | | }; |
| | 339 | |
|
| | 340 | | //----------------------------------------------------- |
| | 341 | | // Raycast |
| | 342 | | [System.Serializable] |
| | 343 | | public class RayInfo |
| | 344 | | { |
| | 345 | | public Vector3 origin; |
| | 346 | | public Vector3 direction; |
| | 347 | | public float distance; |
| | 348 | | } |
| | 349 | |
|
| | 350 | | [System.Serializable] |
| | 351 | | public class RaycastHitInfo |
| | 352 | | { |
| | 353 | | public bool didHit; |
| | 354 | | public RayInfo ray; |
| | 355 | |
|
| | 356 | | public Vector3 hitPoint; |
| | 357 | | public Vector3 hitNormal; |
| | 358 | | } |
| | 359 | |
|
| | 360 | | [System.Serializable] |
| | 361 | | public class HitEntityInfo |
| | 362 | | { |
| | 363 | | public string entityId; |
| | 364 | | public string meshName; |
| | 365 | | } |
| | 366 | |
|
| | 367 | | [System.Serializable] |
| | 368 | | public class RaycastHitEntity : RaycastHitInfo |
| | 369 | | { |
| | 370 | | public HitEntityInfo entity; |
| | 371 | | } |
| | 372 | |
|
| | 373 | | [System.Serializable] |
| | 374 | | public class RaycastHitEntities : RaycastHitInfo |
| | 375 | | { |
| | 376 | | public RaycastHitEntity[] entities; |
| | 377 | | } |
| | 378 | |
|
| | 379 | | [System.Serializable] |
| | 380 | | public class RaycastResponse<T> where T : RaycastHitInfo |
| | 381 | | { |
| | 382 | | public string queryId; |
| | 383 | | public string queryType; |
| | 384 | | public T payload; |
| | 385 | | } |
| | 386 | |
|
| | 387 | | // Note (Zak): We need to explicitly define this classes for the JsonUtility to |
| | 388 | | // be able to serialize them |
| | 389 | | [System.Serializable] |
| | 390 | | public class RaycastHitFirstResponse : RaycastResponse<RaycastHitEntity> { } |
| | 391 | |
|
| | 392 | | [System.Serializable] |
| | 393 | | public class RaycastHitAllResponse : RaycastResponse<RaycastHitEntities> { } |
| | 394 | |
|
| | 395 | | [System.Serializable] |
| | 396 | | public class SendExpressionPayload |
| | 397 | | { |
| | 398 | | public string id; |
| | 399 | | public long timestamp; |
| | 400 | | } |
| | 401 | |
|
| | 402 | | [System.Serializable] |
| | 403 | | public class UserAcceptedCollectiblesPayload |
| | 404 | | { |
| | 405 | | public string id; |
| | 406 | | } |
| | 407 | |
|
| | 408 | | [System.Serializable] |
| | 409 | | public class SendBlockPlayerPayload |
| | 410 | | { |
| | 411 | | public string userId; |
| | 412 | | } |
| | 413 | |
|
| | 414 | | [Serializable] |
| | 415 | | private class SendReportPlayerPayload |
| | 416 | | { |
| | 417 | | public string userId; |
| | 418 | | public string name; |
| | 419 | | } |
| | 420 | |
|
| | 421 | | [Serializable] |
| | 422 | | private class SendReportScenePayload |
| | 423 | | { |
| | 424 | | public string sceneId; |
| | 425 | | } |
| | 426 | |
|
| | 427 | | [Serializable] |
| | 428 | | private class SetHomeScenePayload |
| | 429 | | { |
| | 430 | | public string sceneId; |
| | 431 | | } |
| | 432 | |
|
| | 433 | | [System.Serializable] |
| | 434 | | public class SendUnblockPlayerPayload |
| | 435 | | { |
| | 436 | | public string userId; |
| | 437 | | } |
| | 438 | |
|
| | 439 | | [System.Serializable] |
| | 440 | | public class TutorialStepPayload |
| | 441 | | { |
| | 442 | | public int tutorialStep; |
| | 443 | | } |
| | 444 | |
|
| | 445 | | [System.Serializable] |
| | 446 | | public class PerformanceReportPayload |
| | 447 | | { |
| | 448 | | public string samples; |
| | 449 | | public bool fpsIsCapped; |
| | 450 | | public int hiccupsInThousandFrames; |
| | 451 | | public float hiccupsTime; |
| | 452 | | public float totalTime; |
| | 453 | | public int gltfInProgress; |
| | 454 | | public int gltfFailed; |
| | 455 | | public int gltfCancelled; |
| | 456 | | public int gltfLoaded; |
| | 457 | | public int abInProgress; |
| | 458 | | public int abFailed; |
| | 459 | | public int abCancelled; |
| | 460 | | public int abLoaded; |
| | 461 | | public int gltfTexturesLoaded; |
| | 462 | | public int abTexturesLoaded; |
| | 463 | | public int promiseTexturesLoaded; |
| | 464 | | public int enqueuedMessages; |
| | 465 | | public int processedMessages; |
| | 466 | | public int playerCount; |
| | 467 | | public int loadRadius; |
| | 468 | | public Dictionary<string, long> sceneScores; |
| | 469 | | public object drawCalls; //int * |
| | 470 | | public object memoryReserved; //long, in total bytes * |
| | 471 | | public object memoryUsage; //long, in total bytes * |
| | 472 | | public object totalGCAlloc; //long, in total bytes, its the sum of all GCAllocs per frame over 1000 frames * |
| | 473 | |
|
| | 474 | | //* is NULL if SendProfilerMetrics is false |
| | 475 | | } |
| | 476 | |
|
| | 477 | | [System.Serializable] |
| | 478 | | public class SystemInfoReportPayload |
| | 479 | | { |
| | 480 | | public string graphicsDeviceName = SystemInfo.graphicsDeviceName; |
| | 481 | | public string graphicsDeviceVersion = SystemInfo.graphicsDeviceVersion; |
| | 482 | | public int graphicsMemorySize = SystemInfo.graphicsMemorySize; |
| | 483 | | public string processorType = SystemInfo.processorType; |
| | 484 | | public int processorCount = SystemInfo.processorCount; |
| | 485 | | public int systemMemorySize = SystemInfo.systemMemorySize; |
| | 486 | |
|
| | 487 | | // TODO: remove useBinaryTransform after ECS7 is fully in prod |
| | 488 | | public bool useBinaryTransform = true; |
| | 489 | | } |
| | 490 | |
|
| | 491 | | [System.Serializable] |
| | 492 | | public class GenericAnalyticPayload |
| | 493 | | { |
| | 494 | | public string eventName; |
| | 495 | | public Dictionary<object, object> data; |
| | 496 | | } |
| | 497 | |
|
| | 498 | | [System.Serializable] |
| | 499 | | public class PerformanceHiccupPayload |
| | 500 | | { |
| | 501 | | public int hiccupsInThousandFrames; |
| | 502 | | public float hiccupsTime; |
| | 503 | | public float totalTime; |
| | 504 | | } |
| | 505 | |
|
| | 506 | | [System.Serializable] |
| | 507 | | public class TermsOfServiceResponsePayload |
| | 508 | | { |
| | 509 | | public string sceneId; |
| | 510 | | public bool dontShowAgain; |
| | 511 | | public bool accepted; |
| | 512 | | } |
| | 513 | |
|
| | 514 | | [System.Serializable] |
| | 515 | | public class OpenURLPayload |
| | 516 | | { |
| | 517 | | public string url; |
| | 518 | | } |
| | 519 | |
|
| | 520 | | [System.Serializable] |
| | 521 | | public class GIFSetupPayload |
| | 522 | | { |
| | 523 | | public string imageSource; |
| | 524 | | public string id; |
| | 525 | | public bool isWebGL1; |
| | 526 | | } |
| | 527 | |
|
| | 528 | | [System.Serializable] |
| | 529 | | public class RequestScenesInfoAroundParcelPayload |
| | 530 | | { |
| | 531 | | public Vector2 parcel; |
| | 532 | | public int scenesAround; |
| | 533 | | } |
| | 534 | |
|
| | 535 | | [System.Serializable] |
| | 536 | | public class AudioStreamingPayload |
| | 537 | | { |
| | 538 | | public string url; |
| | 539 | | public bool play; |
| | 540 | | public float volume; |
| | 541 | | } |
| | 542 | |
|
| | 543 | | [System.Serializable] |
| | 544 | | public class SetScenesLoadRadiusPayload |
| | 545 | | { |
| | 546 | | public float newRadius; |
| | 547 | | } |
| | 548 | |
|
| | 549 | | [System.Serializable] |
| | 550 | | public class SetVoiceChatRecordingPayload |
| | 551 | | { |
| | 552 | | public bool recording; |
| | 553 | | } |
| | 554 | |
|
| | 555 | | [System.Serializable] |
| | 556 | | public class ApplySettingsPayload |
| | 557 | | { |
| | 558 | | public float voiceChatVolume; |
| | 559 | | public int voiceChatAllowCategory; |
| | 560 | | } |
| | 561 | |
|
| | 562 | | [Serializable] |
| | 563 | | public class UserRealmPayload |
| | 564 | | { |
| | 565 | | public string serverName; |
| | 566 | | public string layer; |
| | 567 | | } |
| | 568 | |
|
| | 569 | | [System.Serializable] |
| | 570 | | public class JumpInPayload |
| | 571 | | { |
| | 572 | | public UserRealmPayload realm = new UserRealmPayload(); |
| | 573 | | public Vector2 gridPosition; |
| | 574 | | } |
| | 575 | |
|
| | 576 | | [System.Serializable] |
| | 577 | | public class LoadingFeedbackMessage |
| | 578 | | { |
| | 579 | | public string message; |
| | 580 | | public int loadPercentage; |
| | 581 | | } |
| | 582 | |
|
| | 583 | | [System.Serializable] |
| | 584 | | public class AnalyticsPayload |
| | 585 | | { |
| | 586 | | [System.Serializable] |
| | 587 | | public class Property |
| | 588 | | { |
| | 589 | | public string key; |
| | 590 | | public string value; |
| | 591 | |
|
| | 592 | | public Property(string key, string value) |
| | 593 | | { |
| | 594 | | this.key = key; |
| | 595 | | this.value = value; |
| | 596 | | } |
| | 597 | | } |
| | 598 | |
|
| | 599 | | public string name; |
| | 600 | | public Property[] properties; |
| | 601 | | } |
| | 602 | |
|
| | 603 | | [System.Serializable] |
| | 604 | | public class DelightedSurveyEnabledPayload |
| | 605 | | { |
| | 606 | | public bool enabled; |
| | 607 | | } |
| | 608 | |
|
| | 609 | | [System.Serializable] |
| | 610 | | public class ExternalActionSceneEventPayload |
| | 611 | | { |
| | 612 | | public string type; |
| | 613 | | public string payload; |
| | 614 | | } |
| | 615 | |
|
| | 616 | | [System.Serializable] |
| | 617 | | public class MuteUserPayload |
| | 618 | | { |
| | 619 | | public string[] usersId; |
| | 620 | | public bool mute; |
| | 621 | | } |
| | 622 | |
|
| | 623 | | [System.Serializable] |
| | 624 | | public class CloseUserAvatarPayload |
| | 625 | | { |
| | 626 | | public bool isSignUpFlow; |
| | 627 | | } |
| | 628 | |
|
| | 629 | | [System.Serializable] |
| | 630 | | public class StringPayload |
| | 631 | | { |
| | 632 | | public string value; |
| | 633 | | } |
| | 634 | |
|
| | 635 | | [System.Serializable] |
| | 636 | | public class KillPortableExperiencePayload |
| | 637 | | { |
| | 638 | | public string portableExperienceId; |
| | 639 | | } |
| | 640 | |
|
| | 641 | | [System.Serializable] |
| | 642 | | public class SetDisabledPortableExperiencesPayload |
| | 643 | | { |
| | 644 | | public string[] idsToDisable; |
| | 645 | | } |
| | 646 | |
|
| | 647 | | [System.Serializable] |
| | 648 | | public class WearablesRequestFiltersPayload |
| | 649 | | { |
| | 650 | | public string ownedByUser; |
| | 651 | | public string[] wearableIds; |
| | 652 | | public string[] collectionIds; |
| | 653 | | public string thirdPartyId; |
| | 654 | | } |
| | 655 | |
|
| | 656 | | [System.Serializable] |
| | 657 | | public class EmotesRequestFiltersPayload |
| | 658 | | { |
| | 659 | | public string ownedByUser; |
| | 660 | | public string[] emoteIds; |
| | 661 | | public string[] collectionIds; |
| | 662 | | public string thirdPartyId; |
| | 663 | | } |
| | 664 | |
|
| | 665 | | [System.Serializable] |
| | 666 | | public class RequestWearablesPayload |
| | 667 | | { |
| | 668 | | public WearablesRequestFiltersPayload filters; |
| | 669 | | public string context; |
| | 670 | | } |
| | 671 | |
|
| | 672 | | [System.Serializable] |
| | 673 | | public class RequestEmotesPayload |
| | 674 | | { |
| | 675 | | public EmotesRequestFiltersPayload filters; |
| | 676 | | public string context; |
| | 677 | | } |
| | 678 | |
|
| | 679 | | [System.Serializable] |
| | 680 | | public class HeadersPayload |
| | 681 | | { |
| | 682 | | public string method; |
| | 683 | | public string url; |
| | 684 | | public Dictionary<string, object> metadata = new Dictionary<string, object>(); |
| | 685 | | } |
| | 686 | |
|
| | 687 | | [System.Serializable] |
| | 688 | | public class SearchENSOwnerPayload |
| | 689 | | { |
| | 690 | | public string name; |
| | 691 | | public int maxResults; |
| | 692 | | } |
| | 693 | |
|
| | 694 | | [System.Serializable] |
| | 695 | | public class UnpublishScenePayload |
| | 696 | | { |
| | 697 | | public string coordinates; |
| | 698 | | } |
| | 699 | |
|
| | 700 | | [System.Serializable] |
| | 701 | | public class AvatarStateBase |
| | 702 | | { |
| | 703 | | public string type; |
| | 704 | | public string avatarShapeId; |
| | 705 | | } |
| | 706 | |
|
| | 707 | | [System.Serializable] |
| | 708 | | public class AvatarStateSceneChanged : AvatarStateBase |
| | 709 | | { |
| | 710 | | public string sceneId; |
| | 711 | | } |
| | 712 | |
|
| | 713 | | [System.Serializable] |
| | 714 | | public class AvatarOnClickPayload |
| | 715 | | { |
| | 716 | | public string userId; |
| | 717 | | public RayInfo ray = new RayInfo(); |
| | 718 | | } |
| | 719 | |
|
| | 720 | | [System.Serializable] |
| | 721 | | public class TimeReportPayload |
| | 722 | | { |
| | 723 | | public float timeNormalizationFactor; |
| | 724 | | public float cycleTime; |
| | 725 | | public bool isPaused; |
| | 726 | | public float time; |
| | 727 | | } |
| | 728 | |
|
| | 729 | | [System.Serializable] |
| | 730 | | public class GetFriendsWithDirectMessagesPayload |
| | 731 | | { |
| | 732 | | public string userNameOrId; |
| | 733 | | public int limit; |
| | 734 | | public int skip; |
| | 735 | | } |
| | 736 | |
|
| | 737 | | [System.Serializable] |
| | 738 | | public class MarkMessagesAsSeenPayload |
| | 739 | | { |
| | 740 | | public string userId; |
| | 741 | | } |
| | 742 | |
|
| | 743 | | [System.Serializable] |
| | 744 | | public class GetPrivateMessagesPayload |
| | 745 | | { |
| | 746 | | public string userId; |
| | 747 | | public int limit; |
| | 748 | | public string fromMessageId; |
| | 749 | | } |
| | 750 | |
|
| | 751 | | [Serializable] |
| | 752 | | public class FriendshipUpdateStatusMessage |
| | 753 | | { |
| | 754 | | public string userId; |
| | 755 | | public FriendshipAction action; |
| | 756 | | } |
| | 757 | |
|
| | 758 | | public enum FriendshipAction |
| | 759 | | { |
| | 760 | | NONE, |
| | 761 | | APPROVED, |
| | 762 | | REJECTED, |
| | 763 | | CANCELLED, |
| | 764 | | REQUESTED_FROM, |
| | 765 | | REQUESTED_TO, |
| | 766 | | DELETED |
| | 767 | | } |
| | 768 | |
|
| | 769 | | [Serializable] |
| | 770 | | private class GetFriendsPayload |
| | 771 | | { |
| | 772 | | public string userNameOrId; |
| | 773 | | public int limit; |
| | 774 | | public int skip; |
| | 775 | | } |
| | 776 | |
|
| | 777 | | [Serializable] |
| | 778 | | private class GetFriendRequestsPayload |
| | 779 | | { |
| | 780 | | public int sentLimit; |
| | 781 | | public int sentSkip; |
| | 782 | | public int receivedLimit; |
| | 783 | | public int receivedSkip; |
| | 784 | | } |
| | 785 | |
|
| | 786 | | public static event Action<string, byte[]> OnBinaryMessageFromEngine; |
| | 787 | |
|
| | 788 | | #if UNITY_WEBGL && !UNITY_EDITOR |
| | 789 | | /** |
| | 790 | | * This method is called after the first render. It marks the loading of the |
| | 791 | | * rest of the JS client. |
| | 792 | | */ |
| | 793 | | [DllImport("__Internal")] public static extern void StartDecentraland(); |
| | 794 | | [DllImport("__Internal")] public static extern void MessageFromEngine(string type, string message); |
| | 795 | | [DllImport("__Internal")] public static extern string GetGraphicCard(); |
| | 796 | | [DllImport("__Internal")] public static extern void BinaryMessageFromEngine(string sceneId, byte[] bytes, int size); |
| | 797 | |
|
| | 798 | | public static System.Action<string, string> OnMessageFromEngine; |
| | 799 | | #else |
| | 800 | | public static Action<string, string> OnMessageFromEngine |
| | 801 | | { |
| | 802 | | set |
| | 803 | | { |
| | 804 | | OnMessage = value; |
| | 805 | | if (OnMessage != null) |
| | 806 | | { |
| | 807 | | ProcessQueuedMessages(); |
| | 808 | | } |
| | 809 | | } |
| | 810 | | get => OnMessage; |
| | 811 | | } |
| | 812 | | private static Action<string, string> OnMessage; |
| | 813 | |
|
| | 814 | | private static bool hasQueuedMessages = false; |
| | 815 | | private static List<(string, string)> queuedMessages = new List<(string, string)>(); |
| | 816 | | public static void StartDecentraland() { } |
| | 817 | | public static bool CheckURLParam(string targetParam) { return false; } |
| | 818 | | public static string GetURLParam(string targetParam) { return String.Empty; } |
| | 819 | |
|
| | 820 | | public static void MessageFromEngine(string type, string message) |
| | 821 | | { |
| | 822 | | if (OnMessageFromEngine != null) |
| | 823 | | { |
| | 824 | | if (hasQueuedMessages) |
| | 825 | | { |
| | 826 | | ProcessQueuedMessages(); |
| | 827 | | } |
| | 828 | |
|
| | 829 | | OnMessageFromEngine.Invoke(type, message); |
| | 830 | | if (VERBOSE) |
| | 831 | | { |
| | 832 | | Debug.Log("MessageFromEngine called with: " + type + ", " + message); |
| | 833 | | } |
| | 834 | | } |
| | 835 | | else |
| | 836 | | { |
| | 837 | | lock (queuedMessages) |
| | 838 | | { |
| | 839 | | queuedMessages.Add((type, message)); |
| | 840 | | } |
| | 841 | |
|
| | 842 | | hasQueuedMessages = true; |
| | 843 | | } |
| | 844 | | } |
| | 845 | |
|
| | 846 | | private static void ProcessQueuedMessages() |
| | 847 | | { |
| | 848 | | hasQueuedMessages = false; |
| | 849 | | lock (queuedMessages) |
| | 850 | | { |
| | 851 | | foreach ((string type, string payload) in queuedMessages) |
| | 852 | | { |
| | 853 | | MessageFromEngine(type, payload); |
| | 854 | | } |
| | 855 | |
|
| | 856 | | queuedMessages.Clear(); |
| | 857 | | } |
| | 858 | | } |
| | 859 | |
|
| | 860 | | public static string GetGraphicCard() => "In Editor Graphic Card"; |
| | 861 | | #endif |
| | 862 | |
|
| | 863 | | public static void SendMessage(string type) |
| | 864 | | { |
| | 865 | | // sending an empty JSON object to be compatible with other messages |
| | 866 | | MessageFromEngine(type, "{}"); |
| | 867 | | } |
| | 868 | |
|
| | 869 | | public static void SendMessage<T>(string type, T message) |
| | 870 | | { |
| | 871 | | string messageJson = JsonUtility.ToJson(message); |
| | 872 | | SendJson(type, messageJson); |
| | 873 | | } |
| | 874 | |
|
| | 875 | | public static void SendJson(string type, string json) |
| | 876 | | { |
| | 877 | | if (VERBOSE) |
| | 878 | | { |
| | 879 | | Debug.Log($"Sending message: " + json); |
| | 880 | | } |
| | 881 | |
|
| | 882 | | MessageFromEngine(type, json); |
| | 883 | | } |
| | 884 | |
|
| | 885 | | private static ReportPositionPayload positionPayload = new ReportPositionPayload(); |
| | 886 | | private static CameraModePayload cameraModePayload = new CameraModePayload(); |
| | 887 | | private static Web3UseResponsePayload web3UseResponsePayload = new Web3UseResponsePayload(); |
| | 888 | | private static IdleStateChangedPayload idleStateChangedPayload = new IdleStateChangedPayload(); |
| | 889 | | private static OnMetricsUpdate onMetricsUpdate = new OnMetricsUpdate(); |
| | 890 | | private static OnClickEvent onClickEvent = new OnClickEvent(); |
| | 891 | | private static OnPointerDownEvent onPointerDownEvent = new OnPointerDownEvent(); |
| | 892 | | private static OnPointerUpEvent onPointerUpEvent = new OnPointerUpEvent(); |
| | 893 | | private static OnTextSubmitEvent onTextSubmitEvent = new OnTextSubmitEvent(); |
| | 894 | | private static OnTextInputChangeEvent onTextInputChangeEvent = new OnTextInputChangeEvent(); |
| | 895 | | private static OnTextInputChangeTextEvent onTextInputChangeTextEvent = new OnTextInputChangeTextEvent(); |
| | 896 | | private static OnScrollChangeEvent onScrollChangeEvent = new OnScrollChangeEvent(); |
| | 897 | | private static OnFocusEvent onFocusEvent = new OnFocusEvent(); |
| | 898 | | private static OnBlurEvent onBlurEvent = new OnBlurEvent(); |
| | 899 | | private static OnEnterEvent onEnterEvent = new OnEnterEvent(); |
| | 900 | | private static OnSendScreenshot onSendScreenshot = new OnSendScreenshot(); |
| | 901 | | private static OnPointerEventPayload onPointerEventPayload = new OnPointerEventPayload(); |
| | 902 | | private static OnGlobalPointerEventPayload onGlobalPointerEventPayload = new OnGlobalPointerEventPayload(); |
| | 903 | | private static OnGlobalPointerEvent onGlobalPointerEvent = new OnGlobalPointerEvent(); |
| | 904 | | private static AudioStreamingPayload onAudioStreamingEvent = new AudioStreamingPayload(); |
| | 905 | | private static SetVoiceChatRecordingPayload setVoiceChatRecordingPayload = new SetVoiceChatRecordingPayload(); |
| | 906 | | private static SetScenesLoadRadiusPayload setScenesLoadRadiusPayload = new SetScenesLoadRadiusPayload(); |
| | 907 | | private static ApplySettingsPayload applySettingsPayload = new ApplySettingsPayload(); |
| | 908 | | private static GIFSetupPayload gifSetupPayload = new GIFSetupPayload(); |
| | 909 | | private static JumpInPayload jumpInPayload = new JumpInPayload(); |
| | 910 | | private static GotoEvent gotoEvent = new GotoEvent(); |
| | 911 | | private static SendChatMessageEvent sendChatMessageEvent = new SendChatMessageEvent(); |
| | 912 | | private static BaseResolution baseResEvent = new BaseResolution(); |
| | 913 | | private static AnalyticsPayload analyticsEvent = new AnalyticsPayload(); |
| | 914 | | private static DelightedSurveyEnabledPayload delightedSurveyEnabled = new DelightedSurveyEnabledPayload(); |
| | 915 | | private static ExternalActionSceneEventPayload sceneExternalActionEvent = new ExternalActionSceneEventPayload(); |
| | 916 | | private static MuteUserPayload muteUserEvent = new MuteUserPayload(); |
| | 917 | | private static StoreSceneStateEvent storeSceneState = new StoreSceneStateEvent(); |
| | 918 | | private static CloseUserAvatarPayload closeUserAvatarPayload = new CloseUserAvatarPayload(); |
| | 919 | | private static StringPayload stringPayload = new StringPayload(); |
| | 920 | | private static KillPortableExperiencePayload killPortableExperiencePayload = new KillPortableExperiencePayload() |
| | 921 | | private static SetDisabledPortableExperiencesPayload setDisabledPortableExperiencesPayload = new SetDisabledPort |
| | 922 | | private static RequestWearablesPayload requestWearablesPayload = new RequestWearablesPayload(); |
| | 923 | | private static RequestEmotesPayload requestEmotesPayload = new RequestEmotesPayload(); |
| | 924 | | private static SearchENSOwnerPayload searchEnsOwnerPayload = new SearchENSOwnerPayload(); |
| | 925 | | private static HeadersPayload headersPayload = new HeadersPayload(); |
| | 926 | | private static AvatarStateBase avatarStatePayload = new AvatarStateBase(); |
| | 927 | | private static AvatarStateSceneChanged avatarSceneChangedPayload = new AvatarStateSceneChanged(); |
| | 928 | | public static AvatarOnClickPayload avatarOnClickPayload = new AvatarOnClickPayload(); |
| | 929 | | private static UUIDEvent<EmptyPayload> onPointerHoverEnterEvent = new UUIDEvent<EmptyPayload>(); |
| | 930 | | private static UUIDEvent<EmptyPayload> onPointerHoverExitEvent = new UUIDEvent<EmptyPayload>(); |
| | 931 | | private static TimeReportPayload timeReportPayload = new TimeReportPayload(); |
| | 932 | | private static GetFriendsWithDirectMessagesPayload getFriendsWithDirectMessagesPayload = new GetFriendsWithDirec |
| | 933 | | private static MarkMessagesAsSeenPayload markMessagesAsSeenPayload = new MarkMessagesAsSeenPayload(); |
| | 934 | | private static GetPrivateMessagesPayload getPrivateMessagesPayload = new GetPrivateMessagesPayload(); |
| | 935 | |
|
| | 936 | | public static void SendSceneEvent<T>(string sceneId, string eventType, T payload) |
| | 937 | | { |
| | 938 | | SceneEvent<T> sceneEvent = new SceneEvent<T>(); |
| | 939 | | sceneEvent.sceneId = sceneId; |
| | 940 | | sceneEvent.eventType = eventType; |
| | 941 | | sceneEvent.payload = payload; |
| | 942 | |
|
| | 943 | | SendMessage("SceneEvent", sceneEvent); |
| | 944 | | } |
| | 945 | |
|
| | 946 | | private static void SendAllScenesEvent<T>(string eventType, T payload) |
| | 947 | | { |
| | 948 | | AllScenesEvent<T> allScenesEvent = new AllScenesEvent<T>(); |
| | 949 | | allScenesEvent.eventType = eventType; |
| | 950 | | allScenesEvent.payload = payload; |
| | 951 | |
|
| | 952 | | SendMessage("AllScenesEvent", allScenesEvent); |
| | 953 | | } |
| | 954 | |
|
| | 955 | | public static void ReportPosition(Vector3 position, Quaternion rotation, float playerHeight, Quaternion cameraRo |
| | 956 | | { |
| | 957 | | positionPayload.position = position; |
| | 958 | | positionPayload.rotation = rotation; |
| | 959 | | positionPayload.playerHeight = playerHeight; |
| | 960 | | positionPayload.cameraRotation = cameraRotation; |
| | 961 | |
|
| | 962 | | SendMessage("ReportPosition", positionPayload); |
| | 963 | | } |
| | 964 | |
|
| | 965 | | public static void ReportCameraChanged(CameraMode.ModeId cameraMode) { ReportCameraChanged(cameraMode, null); } |
| | 966 | |
|
| | 967 | | public static void ReportCameraChanged(CameraMode.ModeId cameraMode, string targetSceneId) |
| | 968 | | { |
| | 969 | | cameraModePayload.cameraMode = cameraMode; |
| | 970 | | if (!string.IsNullOrEmpty(targetSceneId)) |
| | 971 | | { |
| | 972 | | SendSceneEvent(targetSceneId, "cameraModeChanged", cameraModePayload); |
| | 973 | | } |
| | 974 | | else |
| | 975 | | { |
| | 976 | | SendAllScenesEvent("cameraModeChanged", cameraModePayload); |
| | 977 | | } |
| | 978 | | } |
| | 979 | |
|
| | 980 | | public static void Web3UseResponse(string id, bool result) |
| | 981 | | { |
| | 982 | | web3UseResponsePayload.id = id; |
| | 983 | | web3UseResponsePayload.result = result; |
| | 984 | | SendMessage("Web3UseResponse", web3UseResponsePayload); |
| | 985 | | } |
| | 986 | |
|
| | 987 | | public static void ReportIdleStateChanged(bool isIdle) |
| | 988 | | { |
| | 989 | | idleStateChangedPayload.isIdle = isIdle; |
| | 990 | | SendAllScenesEvent("idleStateChanged", idleStateChangedPayload); |
| | 991 | | } |
| | 992 | |
|
| | 993 | | public static void ReportControlEvent<T>(T controlEvent) where T : ControlEvent { SendMessage("ControlEvent", co |
| | 994 | |
|
| | 995 | | public static void SendRequestHeadersForUrl(string eventName, string method, string url, Dictionary<string, obje |
| | 996 | | { |
| | 997 | | headersPayload.method = method; |
| | 998 | | headersPayload.url = url; |
| | 999 | | if (metadata != null) |
| | 1000 | | headersPayload.metadata = metadata; |
| | 1001 | | SendMessage(eventName, headersPayload); |
| | 1002 | | } |
| | 1003 | |
|
| | 1004 | | public static void BuilderInWorldMessage(string type, string message) { MessageFromEngine(type, message); } |
| | 1005 | |
|
| | 1006 | | public static void ReportOnClickEvent(string sceneId, string uuid) |
| | 1007 | | { |
| | 1008 | | if (string.IsNullOrEmpty(uuid)) |
| | 1009 | | { |
| | 1010 | | return; |
| | 1011 | | } |
| | 1012 | |
|
| | 1013 | | onClickEvent.uuid = uuid; |
| | 1014 | |
|
| | 1015 | | SendSceneEvent(sceneId, "uuidEvent", onClickEvent); |
| | 1016 | | } |
| | 1017 | |
|
| | 1018 | | // TODO: Add sceneNumber to this response |
| | 1019 | | private static void ReportRaycastResult<T, P>(string sceneId, string queryId, string queryType, P payload) where |
| | 1020 | | { |
| | 1021 | | T response = new T(); |
| | 1022 | | response.queryId = queryId; |
| | 1023 | | response.queryType = queryType; |
| | 1024 | | response.payload = payload; |
| | 1025 | |
|
| | 1026 | | SendSceneEvent<T>(sceneId, "raycastResponse", response); |
| | 1027 | | } |
| | 1028 | |
|
| | 1029 | | public static void ReportRaycastHitFirstResult(string sceneId, string queryId, RaycastType raycastType, RaycastH |
| | 1030 | |
|
| | 1031 | | public static void ReportRaycastHitAllResult(string sceneId, string queryId, RaycastType raycastType, RaycastHit |
| | 1032 | |
|
| | 1033 | | private static OnPointerEventPayload.Hit CreateHitObject(string entityId, string meshName, Vector3 point, |
| | 1034 | | Vector3 normal, float distance) |
| | 1035 | | { |
| | 1036 | | OnPointerEventPayload.Hit hit = new OnPointerEventPayload.Hit(); |
| | 1037 | |
|
| | 1038 | | hit.hitPoint = point; |
| | 1039 | | hit.length = distance; |
| | 1040 | | hit.normal = normal; |
| | 1041 | | hit.worldNormal = normal; |
| | 1042 | | hit.meshName = meshName; |
| | 1043 | | hit.entityId = entityId; |
| | 1044 | |
|
| | 1045 | | return hit; |
| | 1046 | | } |
| | 1047 | |
|
| | 1048 | | private static void SetPointerEventPayload(OnPointerEventPayload pointerEventPayload, ACTION_BUTTON buttonId, |
| | 1049 | | string entityId, string meshName, Ray ray, Vector3 point, Vector3 normal, float distance, |
| | 1050 | | bool isHitInfoValid) |
| | 1051 | | { |
| | 1052 | | pointerEventPayload.origin = ray.origin; |
| | 1053 | | pointerEventPayload.direction = ray.direction; |
| | 1054 | | pointerEventPayload.buttonId = buttonId; |
| | 1055 | |
|
| | 1056 | | if (isHitInfoValid) |
| | 1057 | | pointerEventPayload.hit = CreateHitObject(entityId, meshName, point, normal, distance); |
| | 1058 | | else |
| | 1059 | | pointerEventPayload.hit = null; |
| | 1060 | | } |
| | 1061 | |
|
| | 1062 | | public static void ReportGlobalPointerDownEvent(ACTION_BUTTON buttonId, Ray ray, Vector3 point, Vector3 normal, |
| | 1063 | | float distance, string sceneId, string entityId = "0", string meshName = null, bool isHitInfoValid = false) |
| | 1064 | | { |
| | 1065 | | SetPointerEventPayload((OnPointerEventPayload) onGlobalPointerEventPayload, buttonId, |
| | 1066 | | entityId, meshName, ray, point, normal, distance, |
| | 1067 | | isHitInfoValid); |
| | 1068 | | onGlobalPointerEventPayload.type = OnGlobalPointerEventPayload.InputEventType.DOWN; |
| | 1069 | |
|
| | 1070 | | onGlobalPointerEvent.payload = onGlobalPointerEventPayload; |
| | 1071 | |
|
| | 1072 | | SendSceneEvent(sceneId, "actionButtonEvent", onGlobalPointerEvent); |
| | 1073 | | } |
| | 1074 | |
|
| | 1075 | | public static void ReportGlobalPointerUpEvent(ACTION_BUTTON buttonId, Ray ray, Vector3 point, Vector3 normal, |
| | 1076 | | float distance, string sceneId, string entityId = "0", string meshName = null, bool isHitInfoValid = false) |
| | 1077 | | { |
| | 1078 | | SetPointerEventPayload((OnPointerEventPayload) onGlobalPointerEventPayload, buttonId, |
| | 1079 | | entityId, meshName, ray, point, normal, distance, |
| | 1080 | | isHitInfoValid); |
| | 1081 | | onGlobalPointerEventPayload.type = OnGlobalPointerEventPayload.InputEventType.UP; |
| | 1082 | |
|
| | 1083 | | onGlobalPointerEvent.payload = onGlobalPointerEventPayload; |
| | 1084 | |
|
| | 1085 | | SendSceneEvent(sceneId, "actionButtonEvent", onGlobalPointerEvent); |
| | 1086 | | } |
| | 1087 | |
|
| | 1088 | | public static void ReportOnPointerDownEvent(ACTION_BUTTON buttonId, string sceneId, string uuid, |
| | 1089 | | string entityId, string meshName, Ray ray, Vector3 point, Vector3 normal, float distance) |
| | 1090 | | { |
| | 1091 | | if (string.IsNullOrEmpty(uuid)) |
| | 1092 | | { |
| | 1093 | | return; |
| | 1094 | | } |
| | 1095 | |
|
| | 1096 | | onPointerDownEvent.uuid = uuid; |
| | 1097 | | SetPointerEventPayload(onPointerEventPayload, buttonId, entityId, meshName, ray, point, |
| | 1098 | | normal, distance, isHitInfoValid: true); |
| | 1099 | | onPointerDownEvent.payload = onPointerEventPayload; |
| | 1100 | |
|
| | 1101 | | SendSceneEvent(sceneId, "uuidEvent", onPointerDownEvent); |
| | 1102 | | } |
| | 1103 | |
|
| | 1104 | | public static void ReportOnPointerUpEvent(ACTION_BUTTON buttonId, string sceneId, string uuid, string entityId, |
| | 1105 | | string meshName, Ray ray, Vector3 point, Vector3 normal, float distance) |
| | 1106 | | { |
| | 1107 | | if (string.IsNullOrEmpty(uuid)) |
| | 1108 | | { |
| | 1109 | | return; |
| | 1110 | | } |
| | 1111 | |
|
| | 1112 | | onPointerUpEvent.uuid = uuid; |
| | 1113 | | SetPointerEventPayload(onPointerEventPayload, buttonId, entityId, meshName, ray, point, |
| | 1114 | | normal, distance, isHitInfoValid: true); |
| | 1115 | | onPointerUpEvent.payload = onPointerEventPayload; |
| | 1116 | |
|
| | 1117 | | SendSceneEvent(sceneId, "uuidEvent", onPointerUpEvent); |
| | 1118 | | } |
| | 1119 | |
|
| | 1120 | | public static void ReportOnTextSubmitEvent(string sceneId, string uuid, string text) |
| | 1121 | | { |
| | 1122 | | if (string.IsNullOrEmpty(uuid)) |
| | 1123 | | { |
| | 1124 | | return; |
| | 1125 | | } |
| | 1126 | |
|
| | 1127 | | onTextSubmitEvent.uuid = uuid; |
| | 1128 | | onTextSubmitEvent.payload.text = text; |
| | 1129 | |
|
| | 1130 | | SendSceneEvent(sceneId, "uuidEvent", onTextSubmitEvent); |
| | 1131 | | } |
| | 1132 | |
|
| | 1133 | | public static void ReportOnTextInputChangedEvent(string sceneId, string uuid, string text) |
| | 1134 | | { |
| | 1135 | | if (string.IsNullOrEmpty(uuid)) |
| | 1136 | | { |
| | 1137 | | return; |
| | 1138 | | } |
| | 1139 | |
|
| | 1140 | | onTextInputChangeEvent.uuid = uuid; |
| | 1141 | | onTextInputChangeEvent.payload.value = text; |
| | 1142 | |
|
| | 1143 | | SendSceneEvent(sceneId, "uuidEvent", onTextInputChangeEvent); |
| | 1144 | | } |
| | 1145 | |
|
| | 1146 | | public static void ReportOnTextInputChangedTextEvent(string sceneId, string uuid, string text, bool isSubmit) |
| | 1147 | | { |
| | 1148 | | if (string.IsNullOrEmpty(uuid)) |
| | 1149 | | { |
| | 1150 | | return; |
| | 1151 | | } |
| | 1152 | |
|
| | 1153 | | onTextInputChangeTextEvent.uuid = uuid; |
| | 1154 | | onTextInputChangeTextEvent.payload.value.value = text; |
| | 1155 | | onTextInputChangeTextEvent.payload.value.isSubmit = isSubmit; |
| | 1156 | |
|
| | 1157 | | SendSceneEvent(sceneId, "uuidEvent", onTextInputChangeTextEvent); |
| | 1158 | | } |
| | 1159 | |
|
| | 1160 | | public static void ReportOnFocusEvent(string sceneId, string uuid) |
| | 1161 | | { |
| | 1162 | | if (string.IsNullOrEmpty(uuid)) |
| | 1163 | | { |
| | 1164 | | return; |
| | 1165 | | } |
| | 1166 | |
|
| | 1167 | | onFocusEvent.uuid = uuid; |
| | 1168 | | SendSceneEvent(sceneId, "uuidEvent", onFocusEvent); |
| | 1169 | | } |
| | 1170 | |
|
| | 1171 | | public static void ReportOnBlurEvent(string sceneId, string uuid) |
| | 1172 | | { |
| | 1173 | | if (string.IsNullOrEmpty(uuid)) |
| | 1174 | | { |
| | 1175 | | return; |
| | 1176 | | } |
| | 1177 | |
|
| | 1178 | | onBlurEvent.uuid = uuid; |
| | 1179 | | SendSceneEvent(sceneId, "uuidEvent", onBlurEvent); |
| | 1180 | | } |
| | 1181 | |
|
| | 1182 | | public static void ReportOnScrollChange(string sceneId, string uuid, Vector2 value, int pointerId) |
| | 1183 | | { |
| | 1184 | | if (string.IsNullOrEmpty(uuid)) |
| | 1185 | | { |
| | 1186 | | return; |
| | 1187 | | } |
| | 1188 | |
|
| | 1189 | | onScrollChangeEvent.uuid = uuid; |
| | 1190 | | onScrollChangeEvent.payload.value = value; |
| | 1191 | | onScrollChangeEvent.payload.pointerId = pointerId; |
| | 1192 | |
|
| | 1193 | | SendSceneEvent(sceneId, "uuidEvent", onScrollChangeEvent); |
| | 1194 | | } |
| | 1195 | |
|
| | 1196 | | public static void ReportEvent<T>(string sceneId, T @event) { SendSceneEvent(sceneId, "uuidEvent", @event); } |
| | 1197 | |
|
| | 1198 | | public static void ReportOnMetricsUpdate(string sceneId, MetricsModel current, |
| | 1199 | | MetricsModel limit) |
| | 1200 | | { |
| | 1201 | | onMetricsUpdate.given = current; |
| | 1202 | | onMetricsUpdate.limit = limit; |
| | 1203 | |
|
| | 1204 | | SendSceneEvent(sceneId, "metricsUpdate", onMetricsUpdate); |
| | 1205 | | } |
| | 1206 | |
|
| | 1207 | | public static void ReportOnEnterEvent(string sceneId, string uuid) |
| | 1208 | | { |
| | 1209 | | if (string.IsNullOrEmpty(uuid)) |
| | 1210 | | return; |
| | 1211 | |
|
| | 1212 | | onEnterEvent.uuid = uuid; |
| | 1213 | |
|
| | 1214 | | SendSceneEvent(sceneId, "uuidEvent", onEnterEvent); |
| | 1215 | | } |
| | 1216 | |
|
| | 1217 | | public static void LogOut() { SendMessage("LogOut"); } |
| | 1218 | |
|
| | 1219 | | public static void RedirectToSignUp() { SendMessage("RedirectToSignUp"); } |
| | 1220 | |
|
| | 1221 | | public static void PreloadFinished(string sceneId) { SendMessage("PreloadFinished", sceneId); } |
| | 1222 | |
|
| | 1223 | | public static void ReportMousePosition(Vector3 mousePosition, string id) |
| | 1224 | | { |
| | 1225 | | positionPayload.mousePosition = mousePosition; |
| | 1226 | | positionPayload.id = id; |
| | 1227 | | SendMessage("ReportMousePosition", positionPayload); |
| | 1228 | | } |
| | 1229 | |
|
| | 1230 | | public static void SendScreenshot(string encodedTexture, string id) |
| | 1231 | | { |
| | 1232 | | onSendScreenshot.encodedTexture = encodedTexture; |
| | 1233 | | onSendScreenshot.id = id; |
| | 1234 | | SendMessage("SendScreenshot", onSendScreenshot); |
| | 1235 | | } |
| | 1236 | |
|
| | 1237 | | public static void SetDelightedSurveyEnabled(bool enabled) |
| | 1238 | | { |
| | 1239 | | delightedSurveyEnabled.enabled = enabled; |
| | 1240 | | SendMessage("SetDelightedSurveyEnabled", delightedSurveyEnabled); |
| | 1241 | | } |
| | 1242 | |
|
| | 1243 | | public static void SetScenesLoadRadius(float newRadius) |
| | 1244 | | { |
| | 1245 | | setScenesLoadRadiusPayload.newRadius = newRadius; |
| | 1246 | | SendMessage("SetScenesLoadRadius", setScenesLoadRadiusPayload); |
| | 1247 | | } |
| | 1248 | |
|
| | 1249 | | [System.Serializable] |
| | 1250 | | public class SaveAvatarPayload |
| | 1251 | | { |
| | 1252 | | public string face256; |
| | 1253 | | public string body; |
| | 1254 | | public bool isSignUpFlow; |
| | 1255 | | public AvatarModel avatar; |
| | 1256 | | } |
| | 1257 | |
|
| | 1258 | | public static class RendererAuthenticationType |
| | 1259 | | { |
| | 1260 | | public static string Guest => "guest"; |
| | 1261 | | public static string WalletConnect => "wallet_connect"; |
| | 1262 | | } |
| | 1263 | |
|
| | 1264 | | [System.Serializable] |
| | 1265 | | public class SendAuthenticationPayload |
| | 1266 | | { |
| | 1267 | | public string rendererAuthenticationType; |
| | 1268 | | } |
| | 1269 | |
|
| | 1270 | | [System.Serializable] |
| | 1271 | | public class SendPassportPayload |
| | 1272 | | { |
| | 1273 | | public string name; |
| | 1274 | | public string email; |
| | 1275 | | } |
| | 1276 | |
|
| | 1277 | | [System.Serializable] |
| | 1278 | | public class SendSaveUserUnverifiedNamePayload |
| | 1279 | | { |
| | 1280 | | public string newUnverifiedName; |
| | 1281 | | } |
| | 1282 | |
|
| | 1283 | | [System.Serializable] |
| | 1284 | | public class SendSaveUserDescriptionPayload |
| | 1285 | | { |
| | 1286 | | public string description; |
| | 1287 | |
|
| | 1288 | | public SendSaveUserDescriptionPayload(string description) { this.description = description; } |
| | 1289 | | } |
| | 1290 | |
|
| | 1291 | | [Serializable] |
| | 1292 | | public class SendVideoProgressEvent |
| | 1293 | | { |
| | 1294 | | public string componentId; |
| | 1295 | | public string sceneId; |
| | 1296 | | public string videoTextureId; |
| | 1297 | | public int status; |
| | 1298 | | public float currentOffset; |
| | 1299 | | public float videoLength; |
| | 1300 | | } |
| | 1301 | |
|
| | 1302 | | public static void RequestOwnProfileUpdate() { SendMessage("RequestOwnProfileUpdate"); } |
| | 1303 | |
|
| | 1304 | | public static void SendSaveAvatar(AvatarModel avatar, Texture2D face256Snapshot, Texture2D bodySnapshot, bool is |
| | 1305 | | { |
| | 1306 | | var payload = new SaveAvatarPayload() |
| | 1307 | | { |
| | 1308 | | avatar = avatar, |
| | 1309 | | face256 = System.Convert.ToBase64String(face256Snapshot.EncodeToPNG()), |
| | 1310 | | body = System.Convert.ToBase64String(bodySnapshot.EncodeToPNG()), |
| | 1311 | | isSignUpFlow = isSignUpFlow |
| | 1312 | | }; |
| | 1313 | | SendMessage("SaveUserAvatar", payload); |
| | 1314 | | } |
| | 1315 | |
|
| | 1316 | | public static void SendAuthentication(string rendererAuthenticationType) { SendMessage("SendAuthentication", new |
| | 1317 | |
|
| | 1318 | | public static void SendPassport(string name, string email) { SendMessage("SendPassport", new SendPassportPayload |
| | 1319 | |
|
| | 1320 | | public static void SendSaveUserUnverifiedName(string newName) |
| | 1321 | | { |
| | 1322 | | var payload = new SendSaveUserUnverifiedNamePayload() |
| | 1323 | | { |
| | 1324 | | newUnverifiedName = newName |
| | 1325 | | }; |
| | 1326 | |
|
| | 1327 | | SendMessage("SaveUserUnverifiedName", payload); |
| | 1328 | | } |
| | 1329 | |
|
| | 1330 | | public static void SendSaveUserDescription(string about) { SendMessage("SaveUserDescription", new SendSaveUserDe |
| | 1331 | |
|
| | 1332 | | public static void SendUserAcceptedCollectibles(string airdropId) { SendMessage("UserAcceptedCollectibles", new |
| | 1333 | |
|
| | 1334 | | public static void SaveUserTutorialStep(int newTutorialStep) { SendMessage("SaveUserTutorialStep", new TutorialS |
| | 1335 | |
|
| | 1336 | | public static void SendPerformanceReport(string performanceReportPayload) |
| | 1337 | | { |
| | 1338 | | SendJson("PerformanceReport", performanceReportPayload); |
| | 1339 | | } |
| | 1340 | |
|
| | 1341 | | public static void SendSystemInfoReport() { SendMessage("SystemInfoReport", new SystemInfoReportPayload()); } |
| | 1342 | |
|
| | 1343 | | public static void SendTermsOfServiceResponse(string sceneId, bool accepted, bool dontShowAgain) |
| | 1344 | | { |
| | 1345 | | var payload = new TermsOfServiceResponsePayload() |
| | 1346 | | { |
| | 1347 | | sceneId = sceneId, |
| | 1348 | | accepted = accepted, |
| | 1349 | | dontShowAgain = dontShowAgain |
| | 1350 | | }; |
| | 1351 | | SendMessage("TermsOfServiceResponse", payload); |
| | 1352 | | } |
| | 1353 | |
|
| | 1354 | | public static void SendExpression(string expressionID, long timestamp) |
| | 1355 | | { |
| | 1356 | | SendMessage("TriggerExpression", new SendExpressionPayload() |
| | 1357 | | { |
| | 1358 | | id = expressionID, |
| | 1359 | | timestamp = timestamp |
| | 1360 | | }); |
| | 1361 | | } |
| | 1362 | |
|
| | 1363 | | public static void OpenURL(string url) |
| | 1364 | | { |
| | 1365 | | #if UNITY_WEBGL |
| | 1366 | | SendMessage("OpenWebURL", new OpenURLPayload { url = url }); |
| | 1367 | | #else |
| | 1368 | | Application.OpenURL(url); |
| | 1369 | | #endif |
| | 1370 | | } |
| | 1371 | |
|
| | 1372 | | public static void PublishStatefulScene(ProtocolV2.PublishPayload payload) { MessageFromEngine("PublishSceneStat |
| | 1373 | |
|
| | 1374 | | public static void StartIsolatedMode(IsolatedConfig config) { MessageFromEngine("StartIsolatedMode", JsonConvert |
| | 1375 | |
|
| | 1376 | | public static void StopIsolatedMode(IsolatedConfig config) { MessageFromEngine("StopIsolatedMode", JsonConvert.S |
| | 1377 | |
|
| | 1378 | | public static void SendReportScene(string sceneID) |
| | 1379 | | { |
| | 1380 | | SendMessage("ReportScene", new SendReportScenePayload |
| | 1381 | | { |
| | 1382 | | sceneId = sceneID |
| | 1383 | | }); |
| | 1384 | | } |
| | 1385 | |
|
| | 1386 | | public static void SetHomeScene(string sceneID) |
| | 1387 | | { |
| | 1388 | | SendMessage("SetHomeScene", new SetHomeScenePayload |
| | 1389 | | { |
| | 1390 | | sceneId = sceneID |
| | 1391 | | }); |
| | 1392 | | } |
| | 1393 | |
|
| | 1394 | | public static void SendReportPlayer(string playerId, string playerName) |
| | 1395 | | { |
| | 1396 | | SendMessage("ReportPlayer", new SendReportPlayerPayload |
| | 1397 | | { |
| | 1398 | | userId = playerId, |
| | 1399 | | name = playerName |
| | 1400 | | }); |
| | 1401 | | } |
| | 1402 | |
|
| | 1403 | | public static void SendBlockPlayer(string userId) |
| | 1404 | | { |
| | 1405 | | SendMessage("BlockPlayer", new SendBlockPlayerPayload() |
| | 1406 | | { |
| | 1407 | | userId = userId |
| | 1408 | | }); |
| | 1409 | | } |
| | 1410 | |
|
| | 1411 | | public static void SendUnblockPlayer(string userId) |
| | 1412 | | { |
| | 1413 | | SendMessage("UnblockPlayer", new SendUnblockPlayerPayload() |
| | 1414 | | { |
| | 1415 | | userId = userId |
| | 1416 | | }); |
| | 1417 | | } |
| | 1418 | |
|
| | 1419 | | public static void RequestScenesInfoAroundParcel(Vector2 parcel, int maxScenesArea) |
| | 1420 | | { |
| | 1421 | | SendMessage("RequestScenesInfoInArea", new RequestScenesInfoAroundParcelPayload() |
| | 1422 | | { |
| | 1423 | | parcel = parcel, |
| | 1424 | | scenesAround = maxScenesArea |
| | 1425 | | }); |
| | 1426 | | } |
| | 1427 | |
|
| | 1428 | | public static void SendAudioStreamEvent(string url, bool play, float volume) |
| | 1429 | | { |
| | 1430 | | onAudioStreamingEvent.url = url; |
| | 1431 | | onAudioStreamingEvent.play = play; |
| | 1432 | | onAudioStreamingEvent.volume = volume; |
| | 1433 | | SendMessage("SetAudioStream", onAudioStreamingEvent); |
| | 1434 | | } |
| | 1435 | |
|
| | 1436 | | public static void JoinVoiceChat() { SendMessage("JoinVoiceChat"); } |
| | 1437 | |
|
| | 1438 | | public static void LeaveVoiceChat() { SendMessage("LeaveVoiceChat"); } |
| | 1439 | |
|
| | 1440 | | public static void SendSetVoiceChatRecording(bool recording) |
| | 1441 | | { |
| | 1442 | | setVoiceChatRecordingPayload.recording = recording; |
| | 1443 | | SendMessage("SetVoiceChatRecording", setVoiceChatRecordingPayload); |
| | 1444 | | } |
| | 1445 | |
|
| | 1446 | | public static void ToggleVoiceChatRecording() { SendMessage("ToggleVoiceChatRecording"); } |
| | 1447 | |
|
| | 1448 | | public static void ApplySettings(float voiceChatVolume, int voiceChatAllowCategory) |
| | 1449 | | { |
| | 1450 | | applySettingsPayload.voiceChatVolume = voiceChatVolume; |
| | 1451 | | applySettingsPayload.voiceChatAllowCategory = voiceChatAllowCategory; |
| | 1452 | | SendMessage("ApplySettings", applySettingsPayload); |
| | 1453 | | } |
| | 1454 | |
|
| | 1455 | | public static void RequestGIFProcessor(string gifURL, string gifId, bool isWebGL1) |
| | 1456 | | { |
| | 1457 | | gifSetupPayload.imageSource = gifURL; |
| | 1458 | | gifSetupPayload.id = gifId; |
| | 1459 | | gifSetupPayload.isWebGL1 = isWebGL1; |
| | 1460 | |
|
| | 1461 | | SendMessage("RequestGIFProcessor", gifSetupPayload); |
| | 1462 | | } |
| | 1463 | |
|
| | 1464 | | public static void DeleteGIF(string id) |
| | 1465 | | { |
| | 1466 | | stringPayload.value = id; |
| | 1467 | | SendMessage("DeleteGIF", stringPayload); |
| | 1468 | | } |
| | 1469 | |
|
| | 1470 | | public static void GoTo(int x, int y) |
| | 1471 | | { |
| | 1472 | | gotoEvent.x = x; |
| | 1473 | | gotoEvent.y = y; |
| | 1474 | | SendMessage("GoTo", gotoEvent); |
| | 1475 | | } |
| | 1476 | |
|
| | 1477 | | public static void GoToCrowd() { SendMessage("GoToCrowd"); } |
| | 1478 | |
|
| | 1479 | | public static void GoToMagic() { SendMessage("GoToMagic"); } |
| | 1480 | |
|
| | 1481 | | public static void JumpIn(int x, int y, string serverName, string layerName) |
| | 1482 | | { |
| | 1483 | | jumpInPayload.realm.serverName = serverName; |
| | 1484 | | jumpInPayload.realm.layer = layerName; |
| | 1485 | |
|
| | 1486 | | jumpInPayload.gridPosition.x = x; |
| | 1487 | | jumpInPayload.gridPosition.y = y; |
| | 1488 | |
|
| | 1489 | | SendMessage("JumpIn", jumpInPayload); |
| | 1490 | | } |
| | 1491 | |
|
| | 1492 | | public static void SendChatMessage(ChatMessage message) |
| | 1493 | | { |
| | 1494 | | sendChatMessageEvent.message = message; |
| | 1495 | | SendMessage("SendChatMessage", sendChatMessageEvent); |
| | 1496 | | } |
| | 1497 | |
|
| | 1498 | | public static void UpdateFriendshipStatus(FriendshipUpdateStatusMessage message) { SendMessage("UpdateFriendship |
| | 1499 | |
|
| | 1500 | | public static void ScenesLoadingFeedback(LoadingFeedbackMessage message) { SendMessage("ScenesLoadingFeedback", |
| | 1501 | |
|
| | 1502 | | public static void FetchHotScenes() { SendMessage("FetchHotScenes"); } |
| | 1503 | |
|
| | 1504 | | public static void SetBaseResolution(int resolution) |
| | 1505 | | { |
| | 1506 | | baseResEvent.baseResolution = resolution; |
| | 1507 | | SendMessage("SetBaseResolution", baseResEvent); |
| | 1508 | | } |
| | 1509 | |
|
| | 1510 | | public static void ReportAnalyticsEvent(string eventName) { ReportAnalyticsEvent(eventName, null); } |
| | 1511 | |
|
| | 1512 | | public static void ReportAnalyticsEvent(string eventName, AnalyticsPayload.Property[] eventProperties) |
| | 1513 | | { |
| | 1514 | | analyticsEvent.name = eventName; |
| | 1515 | | analyticsEvent.properties = eventProperties; |
| | 1516 | | SendMessage("Track", analyticsEvent); |
| | 1517 | | } |
| | 1518 | |
|
| | 1519 | | public static void FetchBalanceOfMANA() { SendMessage("FetchBalanceOfMANA"); } |
| | 1520 | |
|
| | 1521 | | public static void SendSceneExternalActionEvent(string sceneId, string type, string payload) |
| | 1522 | | { |
| | 1523 | | sceneExternalActionEvent.type = type; |
| | 1524 | | sceneExternalActionEvent.payload = payload; |
| | 1525 | | SendSceneEvent(sceneId, "externalAction", sceneExternalActionEvent); |
| | 1526 | | } |
| | 1527 | |
|
| | 1528 | | public static void SetMuteUsers(string[] usersId, bool mute) |
| | 1529 | | { |
| | 1530 | | muteUserEvent.usersId = usersId; |
| | 1531 | | muteUserEvent.mute = mute; |
| | 1532 | | SendMessage("SetMuteUsers", muteUserEvent); |
| | 1533 | | } |
| | 1534 | |
|
| | 1535 | | public static void SendCloseUserAvatar(bool isSignUpFlow) |
| | 1536 | | { |
| | 1537 | | closeUserAvatarPayload.isSignUpFlow = isSignUpFlow; |
| | 1538 | | SendMessage("CloseUserAvatar", closeUserAvatarPayload); |
| | 1539 | | } |
| | 1540 | |
|
| | 1541 | | // Warning: Use this method only for PEXs non-associated to smart wearables. |
| | 1542 | | // For PEX associated to smart wearables use 'SetDisabledPortableExperiences'. |
| | 1543 | | public static void KillPortableExperience(string portableExperienceId) |
| | 1544 | | { |
| | 1545 | | killPortableExperiencePayload.portableExperienceId = portableExperienceId; |
| | 1546 | | SendMessage("KillPortableExperience", killPortableExperiencePayload); |
| | 1547 | | } |
| | 1548 | |
|
| | 1549 | | public static void RequestThirdPartyWearables( |
| | 1550 | | string ownedByUser, |
| | 1551 | | string thirdPartyCollectionId, |
| | 1552 | | string context) |
| | 1553 | | { |
| | 1554 | | requestWearablesPayload.filters = new WearablesRequestFiltersPayload |
| | 1555 | | { |
| | 1556 | | ownedByUser = ownedByUser, |
| | 1557 | | thirdPartyId = thirdPartyCollectionId, |
| | 1558 | | collectionIds = null, |
| | 1559 | | wearableIds = null |
| | 1560 | | }; |
| | 1561 | |
|
| | 1562 | | requestWearablesPayload.context = context; |
| | 1563 | |
|
| | 1564 | | SendMessage("RequestWearables", requestWearablesPayload); |
| | 1565 | | } |
| | 1566 | |
|
| | 1567 | | public static void SetDisabledPortableExperiences(string[] idsToDisable) |
| | 1568 | | { |
| | 1569 | | setDisabledPortableExperiencesPayload.idsToDisable = idsToDisable; |
| | 1570 | | SendMessage("SetDisabledPortableExperiences", setDisabledPortableExperiencesPayload); |
| | 1571 | | } |
| | 1572 | |
|
| | 1573 | | public static void RequestWearables( |
| | 1574 | | string ownedByUser, |
| | 1575 | | string[] wearableIds, |
| | 1576 | | string[] collectionIds, |
| | 1577 | | string context) |
| | 1578 | | { |
| | 1579 | | requestWearablesPayload.filters = new WearablesRequestFiltersPayload |
| | 1580 | | { |
| | 1581 | | ownedByUser = ownedByUser, |
| | 1582 | | wearableIds = wearableIds, |
| | 1583 | | collectionIds = collectionIds, |
| | 1584 | | thirdPartyId = null |
| | 1585 | | }; |
| | 1586 | |
|
| | 1587 | | requestWearablesPayload.context = context; |
| | 1588 | |
|
| | 1589 | | SendMessage("RequestWearables", requestWearablesPayload); |
| | 1590 | | } |
| | 1591 | |
|
| | 1592 | | public static void RequestEmotes( |
| | 1593 | | string ownedByUser, |
| | 1594 | | string[] emoteIds, |
| | 1595 | | string[] collectionIds, |
| | 1596 | | string context) |
| | 1597 | | { |
| | 1598 | | requestEmotesPayload.filters = new EmotesRequestFiltersPayload() |
| | 1599 | | { |
| | 1600 | | ownedByUser = ownedByUser, |
| | 1601 | | emoteIds = emoteIds, |
| | 1602 | | collectionIds = collectionIds, |
| | 1603 | | thirdPartyId = null |
| | 1604 | | }; |
| | 1605 | |
|
| | 1606 | | requestEmotesPayload.context = context; |
| | 1607 | |
|
| | 1608 | | SendMessage("RequestEmotes", requestEmotesPayload); |
| | 1609 | | } |
| | 1610 | |
|
| | 1611 | | public static void SearchENSOwner(string name, int maxResults) |
| | 1612 | | { |
| | 1613 | | searchEnsOwnerPayload.name = name; |
| | 1614 | | searchEnsOwnerPayload.maxResults = maxResults; |
| | 1615 | |
|
| | 1616 | | SendMessage("SearchENSOwner", searchEnsOwnerPayload); |
| | 1617 | | } |
| | 1618 | |
|
| | 1619 | | public static void RequestHomeCoordinates() |
| | 1620 | | { |
| | 1621 | | SendMessage("RequestHomeCoordinates"); |
| | 1622 | | } |
| | 1623 | |
|
| | 1624 | | public static void RequestUserProfile(string userId) |
| | 1625 | | { |
| | 1626 | | stringPayload.value = userId; |
| | 1627 | | SendMessage("RequestUserProfile", stringPayload); |
| | 1628 | | } |
| | 1629 | |
|
| | 1630 | | public static void ReportAvatarFatalError() { SendMessage("ReportAvatarFatalError"); } |
| | 1631 | |
|
| | 1632 | | public static void UnpublishScene(Vector2Int sceneCoordinates) |
| | 1633 | | { |
| | 1634 | | var payload = new UnpublishScenePayload() { coordinates = $"{sceneCoordinates.x},{sceneCoordinates.y}" }; |
| | 1635 | | SendMessage("UnpublishScene", payload); |
| | 1636 | | } |
| | 1637 | |
|
| | 1638 | | public static void NotifyStatusThroughChat(string message) |
| | 1639 | | { |
| | 1640 | | stringPayload.value = message; |
| | 1641 | | SendMessage("NotifyStatusThroughChat", stringPayload); |
| | 1642 | | } |
| | 1643 | |
|
| | 1644 | | public static void ReportVideoProgressEvent( |
| | 1645 | | string componentId, |
| | 1646 | | string sceneId, |
| | 1647 | | string videoClipId, |
| | 1648 | | int videoStatus, |
| | 1649 | | float currentOffset, |
| | 1650 | | float length) |
| | 1651 | | { |
| | 1652 | | SendVideoProgressEvent progressEvent = new SendVideoProgressEvent() |
| | 1653 | | { |
| | 1654 | | componentId = componentId, |
| | 1655 | | sceneId = sceneId, |
| | 1656 | | videoTextureId = videoClipId, |
| | 1657 | | status = videoStatus, |
| | 1658 | | currentOffset = currentOffset, |
| | 1659 | | videoLength = length |
| | 1660 | | }; |
| | 1661 | |
|
| | 1662 | | SendMessage("VideoProgressEvent", progressEvent); |
| | 1663 | | } |
| | 1664 | |
|
| | 1665 | | public static void ReportAvatarRemoved(string avatarId) |
| | 1666 | | { |
| | 1667 | | avatarStatePayload.type = "Removed"; |
| | 1668 | | avatarStatePayload.avatarShapeId = avatarId; |
| | 1669 | | SendMessage("ReportAvatarState", avatarStatePayload); |
| | 1670 | | } |
| | 1671 | |
|
| | 1672 | | public static void ReportAvatarSceneChanged(string avatarId, string sceneId) |
| | 1673 | | { |
| | 1674 | | avatarSceneChangedPayload.type = "SceneChanged"; |
| | 1675 | | avatarSceneChangedPayload.avatarShapeId = avatarId; |
| | 1676 | | avatarSceneChangedPayload.sceneId = sceneId; |
| | 1677 | | SendMessage("ReportAvatarState", avatarSceneChangedPayload); |
| | 1678 | | } |
| | 1679 | |
|
| | 1680 | | public static void ReportAvatarClick(string sceneId, string userId, Vector3 rayOrigin, Vector3 rayDirection, flo |
| | 1681 | | { |
| | 1682 | | avatarOnClickPayload.userId = userId; |
| | 1683 | | avatarOnClickPayload.ray.origin = rayOrigin; |
| | 1684 | | avatarOnClickPayload.ray.direction = rayDirection; |
| | 1685 | | avatarOnClickPayload.ray.distance = distance; |
| | 1686 | |
|
| | 1687 | | SendSceneEvent(sceneId, "playerClicked", avatarOnClickPayload); |
| | 1688 | | } |
| | 1689 | |
|
| | 1690 | | public static void ReportOnPointerHoverEnterEvent(string sceneId, string uuid) |
| | 1691 | | { |
| | 1692 | | onPointerHoverEnterEvent.uuid = uuid; |
| | 1693 | | SendSceneEvent(sceneId, "uuidEvent", onPointerHoverEnterEvent); |
| | 1694 | | } |
| | 1695 | |
|
| | 1696 | | public static void ReportOnPointerHoverExitEvent(string sceneId, string uuid) |
| | 1697 | | { |
| | 1698 | | onPointerHoverExitEvent.uuid = uuid; |
| | 1699 | | SendSceneEvent(sceneId, "uuidEvent", onPointerHoverExitEvent); |
| | 1700 | | } |
| | 1701 | |
|
| | 1702 | | public static void ReportTime(float time, bool isPaused, float timeNormalizationFactor, float cycleTime) |
| | 1703 | | { |
| | 1704 | | timeReportPayload.time = time; |
| | 1705 | | timeReportPayload.isPaused = isPaused; |
| | 1706 | | timeReportPayload.timeNormalizationFactor = timeNormalizationFactor; |
| | 1707 | | timeReportPayload.cycleTime = cycleTime; |
| | 1708 | | SendMessage("ReportDecentralandTime", timeReportPayload); |
| | 1709 | | } |
| | 1710 | |
|
| | 1711 | | public static void GetFriendsWithDirectMessages(string userNameOrId, int limit, int skip) |
| | 1712 | | { |
| | 1713 | | getFriendsWithDirectMessagesPayload.userNameOrId = userNameOrId; |
| | 1714 | | getFriendsWithDirectMessagesPayload.limit = limit; |
| | 1715 | | getFriendsWithDirectMessagesPayload.skip = skip; |
| | 1716 | | SendMessage("GetFriendsWithDirectMessages", getFriendsWithDirectMessagesPayload); |
| | 1717 | | } |
| | 1718 | |
|
| | 1719 | | public static void MarkMessagesAsSeen(string userId) |
| | 1720 | | { |
| | 1721 | | markMessagesAsSeenPayload.userId = userId; |
| | 1722 | | SendMessage("MarkMessagesAsSeen", markMessagesAsSeenPayload); |
| | 1723 | | } |
| | 1724 | |
|
| | 1725 | | public static void GetPrivateMessages(string userId, int limit, string fromMessageId) |
| | 1726 | | { |
| | 1727 | | getPrivateMessagesPayload.userId = userId; |
| | 1728 | | getPrivateMessagesPayload.limit = limit; |
| | 1729 | | getPrivateMessagesPayload.fromMessageId = fromMessageId; |
| | 1730 | | SendMessage("GetPrivateMessages", getPrivateMessagesPayload); |
| | 1731 | | } |
| | 1732 | |
|
| | 1733 | | public static void GetUnseenMessagesByUser() |
| | 1734 | | { |
| | 1735 | | SendMessage("GetUnseenMessagesByUser"); |
| | 1736 | | } |
| | 1737 | |
|
| | 1738 | | public static void GetFriends(int limit, int skip) |
| | 1739 | | { |
| | 1740 | | SendMessage("GetFriends", new GetFriendsPayload |
| | 1741 | | { |
| | 1742 | | limit = limit, |
| | 1743 | | skip = skip |
| | 1744 | | }); |
| | 1745 | | } |
| | 1746 | |
|
| | 1747 | | public static void GetFriends(string usernameOrId, int limit) |
| | 1748 | | { |
| | 1749 | | SendMessage("GetFriends", new GetFriendsPayload |
| | 1750 | | { |
| | 1751 | | userNameOrId = usernameOrId, |
| | 1752 | | limit = limit |
| | 1753 | | }); |
| | 1754 | | } |
| | 1755 | |
|
| | 1756 | | public static void GetFriendRequests(int sentLimit, int sentSkip, int receivedLimit, int receivedSkip) |
| | 1757 | | { |
| | 1758 | | SendMessage("GetFriendRequests", new GetFriendRequestsPayload |
| | 1759 | | { |
| | 1760 | | receivedSkip = receivedSkip, |
| | 1761 | | receivedLimit = receivedLimit, |
| | 1762 | | sentSkip = sentSkip, |
| | 1763 | | sentLimit = sentLimit |
| | 1764 | | }); |
| | 1765 | | } |
| | 1766 | | } |
| | 1767 | | } |