| | 1 | | using System; |
| | 2 | | using System.Collections.Generic; |
| | 3 | | using DCL.Helpers; |
| | 4 | | using DCL.Models; |
| | 5 | | using UnityEngine; |
| | 6 | | using Ray = UnityEngine.Ray; |
| | 7 | |
|
| | 8 | | #if UNITY_WEBGL && !UNITY_EDITOR |
| | 9 | | using System.Runtime.InteropServices; |
| | 10 | | #endif |
| | 11 | |
|
| | 12 | | namespace DCL.Interface |
| | 13 | | { |
| | 14 | | /** |
| | 15 | | * This class contains the outgoing interface of Decentraland. |
| | 16 | | * You must call those functions to interact with the WebInterface. |
| | 17 | | * |
| | 18 | | * The messages comming from the WebInterface instead, are reported directly to |
| | 19 | | * the handler GameObject by name. |
| | 20 | | */ |
| | 21 | | public static class WebInterface |
| | 22 | | { |
| 1 | 23 | | public static bool VERBOSE = false; |
| | 24 | | public static System.Action<string, string> OnMessageFromEngine; |
| | 25 | |
|
| | 26 | | [System.Serializable] |
| | 27 | | private class ReportPositionPayload |
| | 28 | | { |
| | 29 | | /** Camera position, world space */ |
| | 30 | | public Vector3 position; |
| | 31 | |
|
| | 32 | | /** Camera rotation */ |
| | 33 | | public Quaternion rotation; |
| | 34 | |
|
| | 35 | | /** Camera height, relative to the feet of the avatar or ground */ |
| | 36 | | public float playerHeight; |
| | 37 | |
|
| | 38 | | public Vector3 mousePosition; |
| | 39 | |
|
| | 40 | | public string id; |
| | 41 | | } |
| | 42 | |
|
| | 43 | | [System.Serializable] |
| | 44 | | public abstract class ControlEvent |
| | 45 | | { |
| | 46 | | public string eventType; |
| | 47 | | } |
| | 48 | |
|
| | 49 | | public abstract class ControlEvent<T> : ControlEvent |
| | 50 | | { |
| | 51 | | public T payload; |
| | 52 | |
|
| | 53 | | protected ControlEvent(string eventType, T payload) |
| | 54 | | { |
| | 55 | | this.eventType = eventType; |
| | 56 | | this.payload = payload; |
| | 57 | | } |
| | 58 | | } |
| | 59 | |
|
| | 60 | | [System.Serializable] |
| | 61 | | public class StartStatefulMode : ControlEvent<StartStatefulMode.Payload> |
| | 62 | | { |
| | 63 | | [System.Serializable] |
| | 64 | | public class Payload |
| | 65 | | { |
| | 66 | | public string sceneId; |
| | 67 | | } |
| | 68 | |
|
| 16 | 69 | | public StartStatefulMode(string sceneId) : base("StartStatefulMode", new Payload() { sceneId = sceneId }) { |
| | 70 | | } |
| | 71 | |
|
| | 72 | | [System.Serializable] |
| | 73 | | public class StopStatefulMode : ControlEvent<StopStatefulMode.Payload> |
| | 74 | | { |
| | 75 | | [System.Serializable] |
| | 76 | | public class Payload |
| | 77 | | { |
| | 78 | | public string sceneId; |
| | 79 | | } |
| | 80 | |
|
| 10 | 81 | | public StopStatefulMode(string sceneId) : base("StopStatefulMode", new Payload() { sceneId = sceneId }) { } |
| | 82 | | } |
| | 83 | |
|
| | 84 | | [System.Serializable] |
| | 85 | | public class SceneReady : ControlEvent<SceneReady.Payload> |
| | 86 | | { |
| | 87 | | [System.Serializable] |
| | 88 | | public class Payload |
| | 89 | | { |
| | 90 | | public string sceneId; |
| | 91 | | } |
| | 92 | |
|
| 1372 | 93 | | public SceneReady(string sceneId) : base("SceneReady", new Payload() { sceneId = sceneId }) { } |
| | 94 | | } |
| | 95 | |
|
| | 96 | | [System.Serializable] |
| | 97 | | public class ActivateRenderingACK : ControlEvent<object> |
| | 98 | | { |
| 2 | 99 | | public ActivateRenderingACK() : base("ActivateRenderingACK", null) { } |
| | 100 | | } |
| | 101 | |
|
| | 102 | | [System.Serializable] |
| | 103 | | public class DeactivateRenderingACK : ControlEvent<object> |
| | 104 | | { |
| 2 | 105 | | public DeactivateRenderingACK() : base("DeactivateRenderingACK", null) { } |
| | 106 | | } |
| | 107 | |
|
| | 108 | | [System.Serializable] |
| | 109 | | public class SceneEvent<T> |
| | 110 | | { |
| | 111 | | public string sceneId; |
| | 112 | | public string eventType; |
| | 113 | | public T payload; |
| | 114 | | } |
| | 115 | |
|
| | 116 | | [System.Serializable] |
| | 117 | | public class AllScenesEvent<T> |
| | 118 | | { |
| | 119 | | public string eventType; |
| | 120 | | public T payload; |
| | 121 | | } |
| | 122 | |
|
| | 123 | | [System.Serializable] |
| | 124 | | public class UUIDEvent<TPayload> |
| | 125 | | where TPayload : class, new() |
| | 126 | | { |
| | 127 | | public string uuid; |
| | 128 | | public TPayload payload = new TPayload(); |
| | 129 | | } |
| | 130 | |
|
| | 131 | | public enum ACTION_BUTTON |
| | 132 | | { |
| | 133 | | POINTER, |
| | 134 | | PRIMARY, |
| | 135 | | SECONDARY, |
| | 136 | | ANY |
| | 137 | | } |
| | 138 | |
|
| | 139 | | [System.Serializable] |
| | 140 | | public class OnClickEvent : UUIDEvent<OnClickEventPayload> { }; |
| | 141 | |
|
| | 142 | | [System.Serializable] |
| | 143 | | public class CameraModePayload |
| | 144 | | { |
| | 145 | | public CameraMode.ModeId cameraMode; |
| | 146 | | }; |
| | 147 | |
|
| | 148 | | [System.Serializable] |
| | 149 | | public class IdleStateChangedPayload |
| | 150 | | { |
| | 151 | | public bool isIdle; |
| | 152 | | }; |
| | 153 | |
|
| | 154 | | [System.Serializable] |
| | 155 | | public class OnPointerDownEvent : UUIDEvent<OnPointerEventPayload> { }; |
| | 156 | |
|
| | 157 | | [System.Serializable] |
| | 158 | | public class OnGlobalPointerEvent |
| | 159 | | { |
| 0 | 160 | | public OnGlobalPointerEventPayload payload = new OnGlobalPointerEventPayload(); |
| | 161 | | }; |
| | 162 | |
|
| | 163 | | [System.Serializable] |
| | 164 | | public class OnPointerUpEvent : UUIDEvent<OnPointerEventPayload> { }; |
| | 165 | |
|
| | 166 | | [System.Serializable] |
| | 167 | | private class OnTextSubmitEvent : UUIDEvent<OnTextSubmitEventPayload> { }; |
| | 168 | |
|
| | 169 | | [System.Serializable] |
| | 170 | | private class OnTextInputChangeEvent : UUIDEvent<OnTextInputChangeEventPayload> { }; |
| | 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 | | { |
| 1 | 206 | | public string type = "StoreSceneState"; |
| 1 | 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 OnScrollChangeEventPayload |
| | 258 | | { |
| | 259 | | public Vector2 value; |
| | 260 | | public int pointerId; |
| | 261 | | } |
| | 262 | |
|
| | 263 | | [System.Serializable] |
| | 264 | | public class EmptyPayload { } |
| | 265 | |
|
| | 266 | | [System.Serializable] |
| | 267 | | public class MetricsModel |
| | 268 | | { |
| | 269 | | public int meshes; |
| | 270 | | public int bodies; |
| | 271 | | public int materials; |
| | 272 | | public int textures; |
| | 273 | | public int triangles; |
| | 274 | | public int entities; |
| | 275 | |
|
| | 276 | | public static MetricsModel operator + (MetricsModel lhs, MetricsModel rhs) |
| | 277 | | { |
| 0 | 278 | | return new MetricsModel() |
| | 279 | | { |
| | 280 | | meshes = lhs.meshes + rhs.meshes, |
| | 281 | | bodies = lhs.bodies + rhs.bodies, |
| | 282 | | materials = lhs.materials + rhs.materials, |
| | 283 | | textures = lhs.textures + rhs.textures, |
| | 284 | | triangles = lhs.triangles + rhs.triangles, |
| | 285 | | entities = lhs.entities + rhs.entities |
| | 286 | | }; |
| | 287 | | } |
| | 288 | | } |
| | 289 | |
|
| | 290 | | [System.Serializable] |
| | 291 | | private class OnMetricsUpdate |
| | 292 | | { |
| 1 | 293 | | public MetricsModel given = new MetricsModel(); |
| 1 | 294 | | public MetricsModel limit = new MetricsModel(); |
| | 295 | | } |
| | 296 | |
|
| | 297 | | [System.Serializable] |
| | 298 | | public class OnEnterEventPayload { } |
| | 299 | |
|
| | 300 | | [System.Serializable] |
| | 301 | | public class TransformPayload |
| | 302 | | { |
| 0 | 303 | | public Vector3 position = Vector3.zero; |
| 0 | 304 | | public Quaternion rotation = Quaternion.identity; |
| 0 | 305 | | public Vector3 scale = Vector3.one; |
| | 306 | | } |
| | 307 | |
|
| | 308 | | public class OnSendScreenshot |
| | 309 | | { |
| | 310 | | public string id; |
| | 311 | | public string encodedTexture; |
| | 312 | | }; |
| | 313 | |
|
| | 314 | | [System.Serializable] |
| | 315 | | public class GotoEvent |
| | 316 | | { |
| | 317 | | public int x; |
| | 318 | | public int y; |
| | 319 | | }; |
| | 320 | |
|
| | 321 | | [System.Serializable] |
| | 322 | | public class BaseResolution |
| | 323 | | { |
| | 324 | | public int baseResolution; |
| | 325 | | }; |
| | 326 | |
|
| | 327 | | //----------------------------------------------------- |
| | 328 | | // Raycast |
| | 329 | | [System.Serializable] |
| | 330 | | public class RayInfo |
| | 331 | | { |
| | 332 | | public Vector3 origin; |
| | 333 | | public Vector3 direction; |
| | 334 | | public float distance; |
| | 335 | | } |
| | 336 | |
|
| | 337 | | [System.Serializable] |
| | 338 | | public class RaycastHitInfo |
| | 339 | | { |
| | 340 | | public bool didHit; |
| | 341 | | public RayInfo ray; |
| | 342 | |
|
| | 343 | | public Vector3 hitPoint; |
| | 344 | | public Vector3 hitNormal; |
| | 345 | | } |
| | 346 | |
|
| | 347 | | [System.Serializable] |
| | 348 | | public class HitEntityInfo |
| | 349 | | { |
| | 350 | | public string entityId; |
| | 351 | | public string meshName; |
| | 352 | | } |
| | 353 | |
|
| | 354 | | [System.Serializable] |
| | 355 | | public class RaycastHitEntity : RaycastHitInfo |
| | 356 | | { |
| | 357 | | public HitEntityInfo entity; |
| | 358 | | } |
| | 359 | |
|
| | 360 | | [System.Serializable] |
| | 361 | | public class RaycastHitEntities : RaycastHitInfo |
| | 362 | | { |
| | 363 | | public RaycastHitEntity[] entities; |
| | 364 | | } |
| | 365 | |
|
| | 366 | | [System.Serializable] |
| | 367 | | public class RaycastResponse<T> where T : RaycastHitInfo |
| | 368 | | { |
| | 369 | | public string queryId; |
| | 370 | | public string queryType; |
| | 371 | | public T payload; |
| | 372 | | } |
| | 373 | |
|
| | 374 | | // Note (Zak): We need to explicitly define this classes for the JsonUtility to |
| | 375 | | // be able to serialize them |
| | 376 | | [System.Serializable] |
| | 377 | | public class RaycastHitFirstResponse : RaycastResponse<RaycastHitEntity> { } |
| | 378 | |
|
| | 379 | | [System.Serializable] |
| | 380 | | public class RaycastHitAllResponse : RaycastResponse<RaycastHitEntities> { } |
| | 381 | |
|
| | 382 | | [System.Serializable] |
| | 383 | | public class SendExpressionPayload |
| | 384 | | { |
| | 385 | | public string id; |
| | 386 | | public long timestamp; |
| | 387 | | } |
| | 388 | |
|
| | 389 | | [System.Serializable] |
| | 390 | | public class UserAcceptedCollectiblesPayload |
| | 391 | | { |
| | 392 | | public string id; |
| | 393 | | } |
| | 394 | |
|
| | 395 | | [System.Serializable] |
| | 396 | | public class SendBlockPlayerPayload |
| | 397 | | { |
| | 398 | | public string userId; |
| | 399 | | } |
| | 400 | |
|
| | 401 | | [System.Serializable] |
| | 402 | | public class SendUnblockPlayerPayload |
| | 403 | | { |
| | 404 | | public string userId; |
| | 405 | | } |
| | 406 | |
|
| | 407 | | [System.Serializable] |
| | 408 | | public class TutorialStepPayload |
| | 409 | | { |
| | 410 | | public int tutorialStep; |
| | 411 | | } |
| | 412 | |
|
| | 413 | | [System.Serializable] |
| | 414 | | public class PerformanceReportPayload |
| | 415 | | { |
| | 416 | | public string samples; |
| | 417 | | public bool fpsIsCapped; |
| | 418 | | public int hiccupsInThousandFrames; |
| | 419 | | public float hiccupsTime; |
| | 420 | | public float totalTime; |
| | 421 | | } |
| | 422 | |
|
| | 423 | | [System.Serializable] |
| | 424 | | public class SystemInfoReportPayload |
| | 425 | | { |
| 123 | 426 | | public string graphicsDeviceName = SystemInfo.graphicsDeviceName; |
| 123 | 427 | | public string graphicsDeviceVersion = SystemInfo.graphicsDeviceVersion; |
| 123 | 428 | | public int graphicsMemorySize = SystemInfo.graphicsMemorySize; |
| 123 | 429 | | public string processorType = SystemInfo.processorType; |
| 123 | 430 | | public int processorCount = SystemInfo.processorCount; |
| 123 | 431 | | public int systemMemorySize = SystemInfo.systemMemorySize; |
| | 432 | | } |
| | 433 | |
|
| | 434 | | [System.Serializable] |
| | 435 | | public class GenericAnalyticPayload |
| | 436 | | { |
| | 437 | | public string eventName; |
| | 438 | | public Dictionary<object, object> data; |
| | 439 | | } |
| | 440 | |
|
| | 441 | | [System.Serializable] |
| | 442 | | public class PerformanceHiccupPayload |
| | 443 | | { |
| | 444 | | public int hiccupsInThousandFrames; |
| | 445 | | public float hiccupsTime; |
| | 446 | | public float totalTime; |
| | 447 | | } |
| | 448 | |
|
| | 449 | | [System.Serializable] |
| | 450 | | public class TermsOfServiceResponsePayload |
| | 451 | | { |
| | 452 | | public string sceneId; |
| | 453 | | public bool dontShowAgain; |
| | 454 | | public bool accepted; |
| | 455 | | } |
| | 456 | |
|
| | 457 | | [System.Serializable] |
| | 458 | | public class OpenURLPayload |
| | 459 | | { |
| | 460 | | public string url; |
| | 461 | | } |
| | 462 | |
|
| | 463 | | [System.Serializable] |
| | 464 | | public class GIFSetupPayload |
| | 465 | | { |
| | 466 | | public string imageSource; |
| | 467 | | public string id; |
| | 468 | | public bool isWebGL1; |
| | 469 | | } |
| | 470 | |
|
| | 471 | | [System.Serializable] |
| | 472 | | public class RequestScenesInfoAroundParcelPayload |
| | 473 | | { |
| | 474 | | public Vector2 parcel; |
| | 475 | | public int scenesAround; |
| | 476 | | } |
| | 477 | |
|
| | 478 | | [System.Serializable] |
| | 479 | | public class AudioStreamingPayload |
| | 480 | | { |
| | 481 | | public string url; |
| | 482 | | public bool play; |
| | 483 | | public float volume; |
| | 484 | | } |
| | 485 | |
|
| | 486 | | [System.Serializable] |
| | 487 | | public class SetScenesLoadRadiusPayload |
| | 488 | | { |
| | 489 | | public float newRadius; |
| | 490 | | } |
| | 491 | |
|
| | 492 | | [System.Serializable] |
| | 493 | | public class SetVoiceChatRecordingPayload |
| | 494 | | { |
| | 495 | | public bool recording; |
| | 496 | | } |
| | 497 | |
|
| | 498 | | [System.Serializable] |
| | 499 | | public class ApplySettingsPayload |
| | 500 | | { |
| | 501 | | public float voiceChatVolume; |
| | 502 | | public int voiceChatAllowCategory; |
| | 503 | | } |
| | 504 | |
|
| | 505 | | [System.Serializable] |
| | 506 | | public class JumpInPayload |
| | 507 | | { |
| 0 | 508 | | public FriendsController.UserStatus.Realm realm = new FriendsController.UserStatus.Realm(); |
| | 509 | | public Vector2 gridPosition; |
| | 510 | | } |
| | 511 | |
|
| | 512 | | [System.Serializable] |
| | 513 | | public class LoadingFeedbackMessage |
| | 514 | | { |
| | 515 | | public string message; |
| | 516 | | public int loadPercentage; |
| | 517 | | } |
| | 518 | |
|
| | 519 | | [System.Serializable] |
| | 520 | | public class AnalyticsPayload |
| | 521 | | { |
| | 522 | | [System.Serializable] |
| | 523 | | public class Property |
| | 524 | | { |
| | 525 | | public string key; |
| | 526 | | public string value; |
| | 527 | |
|
| 209 | 528 | | public Property(string key, string value) |
| | 529 | | { |
| 209 | 530 | | this.key = key; |
| 209 | 531 | | this.value = value; |
| 209 | 532 | | } |
| | 533 | | } |
| | 534 | |
|
| | 535 | | public string name; |
| | 536 | | public Property[] properties; |
| | 537 | | } |
| | 538 | |
|
| | 539 | | [System.Serializable] |
| | 540 | | public class DelightedSurveyEnabledPayload |
| | 541 | | { |
| | 542 | | public bool enabled; |
| | 543 | | } |
| | 544 | |
|
| | 545 | | [System.Serializable] |
| | 546 | | public class ExternalActionSceneEventPayload |
| | 547 | | { |
| | 548 | | public string type; |
| | 549 | | public string payload; |
| | 550 | | } |
| | 551 | |
|
| | 552 | | [System.Serializable] |
| | 553 | | public class MuteUserPayload |
| | 554 | | { |
| | 555 | | public string[] usersId; |
| | 556 | | public bool mute; |
| | 557 | | } |
| | 558 | |
|
| | 559 | | [System.Serializable] |
| | 560 | | public class CloseUserAvatarPayload |
| | 561 | | { |
| | 562 | | public bool isSignUpFlow; |
| | 563 | | } |
| | 564 | |
|
| | 565 | | [System.Serializable] |
| | 566 | | public class StringPayload |
| | 567 | | { |
| | 568 | | public string value; |
| | 569 | | } |
| | 570 | |
|
| | 571 | | [System.Serializable] |
| | 572 | | public class KillPortableExperiencePayload |
| | 573 | | { |
| | 574 | | public string portableExperienceId; |
| | 575 | | } |
| | 576 | |
|
| | 577 | | [System.Serializable] |
| | 578 | | public class WearablesRequestFiltersPayload |
| | 579 | | { |
| | 580 | | public string ownedByUser; |
| | 581 | | public string[] wearableIds; |
| | 582 | | public string[] collectionIds; |
| | 583 | | } |
| | 584 | |
|
| | 585 | | [System.Serializable] |
| | 586 | | public class RequestWearablesPayload |
| | 587 | | { |
| | 588 | | public WearablesRequestFiltersPayload filters; |
| | 589 | | public string context; |
| | 590 | | } |
| | 591 | |
|
| | 592 | | [System.Serializable] |
| | 593 | | public class HeadersPayload |
| | 594 | | { |
| | 595 | | public string method; |
| | 596 | | public string url; |
| | 597 | | } |
| | 598 | |
|
| | 599 | | [System.Serializable] |
| | 600 | | public class SearchENSOwnerPayload |
| | 601 | | { |
| | 602 | | public string name; |
| | 603 | | public int maxResults; |
| | 604 | | } |
| | 605 | |
|
| | 606 | | [System.Serializable] |
| | 607 | | public class UnpublishScenePayload |
| | 608 | | { |
| | 609 | | public string coordinates; |
| | 610 | | } |
| | 611 | |
|
| | 612 | | #if UNITY_WEBGL && !UNITY_EDITOR |
| | 613 | | /** |
| | 614 | | * This method is called after the first render. It marks the loading of the |
| | 615 | | * rest of the JS client. |
| | 616 | | */ |
| | 617 | | [DllImport("__Internal")] public static extern void StartDecentraland(); |
| | 618 | | [DllImport("__Internal")] public static extern void MessageFromEngine(string type, string message); |
| | 619 | | [DllImport("__Internal")] public static extern string GetGraphicCard(); |
| | 620 | | [DllImport("__Internal")] public static extern bool CheckURLParam(string targetParam); |
| | 621 | | #else |
| 1 | 622 | | private static bool hasQueuedMessages = false; |
| 1 | 623 | | private static List<(string, string)> queuedMessages = new List<(string, string)>(); |
| 123 | 624 | | public static void StartDecentraland() { } |
| 0 | 625 | | public static bool CheckURLParam(string targetParam) { return false; } |
| | 626 | | public static void MessageFromEngine(string type, string message) |
| | 627 | | { |
| 5091 | 628 | | if (OnMessageFromEngine != null) |
| | 629 | | { |
| 2576 | 630 | | if (hasQueuedMessages) |
| | 631 | | { |
| 30 | 632 | | ProcessQueuedMessages(); |
| | 633 | | } |
| 2576 | 634 | | OnMessageFromEngine.Invoke(type, message); |
| 2576 | 635 | | if (VERBOSE) |
| | 636 | | { |
| 0 | 637 | | Debug.Log("MessageFromEngine called with: " + type + ", " + message); |
| | 638 | | } |
| 0 | 639 | | } |
| | 640 | | else |
| | 641 | | { |
| 2515 | 642 | | lock (queuedMessages) |
| | 643 | | { |
| 2515 | 644 | | queuedMessages.Add((type, message)); |
| 2515 | 645 | | } |
| 2515 | 646 | | hasQueuedMessages = true; |
| | 647 | | } |
| 5091 | 648 | | } |
| | 649 | |
|
| | 650 | | private static void ProcessQueuedMessages() |
| | 651 | | { |
| 30 | 652 | | hasQueuedMessages = false; |
| 30 | 653 | | lock (queuedMessages) |
| | 654 | | { |
| 5086 | 655 | | foreach ((string type, string payload) in queuedMessages) |
| | 656 | | { |
| 2513 | 657 | | MessageFromEngine(type, payload); |
| | 658 | | } |
| 30 | 659 | | queuedMessages.Clear(); |
| 30 | 660 | | } |
| 30 | 661 | | } |
| | 662 | |
|
| 0 | 663 | | public static string GetGraphicCard() => "In Editor Graphic Card"; |
| | 664 | | #endif |
| | 665 | |
|
| | 666 | | public static void SendMessage(string type) |
| | 667 | | { |
| | 668 | | // sending an empty JSON object to be compatible with other messages |
| 12 | 669 | | MessageFromEngine(type, "{}"); |
| 12 | 670 | | } |
| | 671 | |
|
| | 672 | | public static void SendMessage<T>(string type, T message) |
| | 673 | | { |
| 2561 | 674 | | string messageJson = JsonUtility.ToJson(message); |
| | 675 | |
|
| 2561 | 676 | | if (VERBOSE) |
| | 677 | | { |
| 0 | 678 | | Debug.Log($"Sending message: " + messageJson); |
| | 679 | | } |
| | 680 | |
|
| 2561 | 681 | | MessageFromEngine(type, messageJson); |
| 2561 | 682 | | } |
| | 683 | |
|
| 1 | 684 | | private static ReportPositionPayload positionPayload = new ReportPositionPayload(); |
| 1 | 685 | | private static CameraModePayload cameraModePayload = new CameraModePayload(); |
| 1 | 686 | | private static IdleStateChangedPayload idleStateChangedPayload = new IdleStateChangedPayload(); |
| 1 | 687 | | private static OnMetricsUpdate onMetricsUpdate = new OnMetricsUpdate(); |
| 1 | 688 | | private static OnClickEvent onClickEvent = new OnClickEvent(); |
| 1 | 689 | | private static OnPointerDownEvent onPointerDownEvent = new OnPointerDownEvent(); |
| 1 | 690 | | private static OnPointerUpEvent onPointerUpEvent = new OnPointerUpEvent(); |
| 1 | 691 | | private static OnTextSubmitEvent onTextSubmitEvent = new OnTextSubmitEvent(); |
| 1 | 692 | | private static OnTextInputChangeEvent onTextInputChangeEvent = new OnTextInputChangeEvent(); |
| 1 | 693 | | private static OnScrollChangeEvent onScrollChangeEvent = new OnScrollChangeEvent(); |
| 1 | 694 | | private static OnFocusEvent onFocusEvent = new OnFocusEvent(); |
| 1 | 695 | | private static OnBlurEvent onBlurEvent = new OnBlurEvent(); |
| 1 | 696 | | private static OnEnterEvent onEnterEvent = new OnEnterEvent(); |
| 1 | 697 | | private static OnSendScreenshot onSendScreenshot = new OnSendScreenshot(); |
| 1 | 698 | | private static OnPointerEventPayload onPointerEventPayload = new OnPointerEventPayload(); |
| 1 | 699 | | private static OnGlobalPointerEventPayload onGlobalPointerEventPayload = new OnGlobalPointerEventPayload(); |
| 1 | 700 | | private static OnGlobalPointerEvent onGlobalPointerEvent = new OnGlobalPointerEvent(); |
| 1 | 701 | | private static AudioStreamingPayload onAudioStreamingEvent = new AudioStreamingPayload(); |
| 1 | 702 | | private static SetVoiceChatRecordingPayload setVoiceChatRecordingPayload = new SetVoiceChatRecordingPayload(); |
| 1 | 703 | | private static SetScenesLoadRadiusPayload setScenesLoadRadiusPayload = new SetScenesLoadRadiusPayload(); |
| 1 | 704 | | private static ApplySettingsPayload applySettingsPayload = new ApplySettingsPayload(); |
| 1 | 705 | | private static GIFSetupPayload gifSetupPayload = new GIFSetupPayload(); |
| 1 | 706 | | private static JumpInPayload jumpInPayload = new JumpInPayload(); |
| 1 | 707 | | private static GotoEvent gotoEvent = new GotoEvent(); |
| 1 | 708 | | private static SendChatMessageEvent sendChatMessageEvent = new SendChatMessageEvent(); |
| 1 | 709 | | private static BaseResolution baseResEvent = new BaseResolution(); |
| 1 | 710 | | private static AnalyticsPayload analyticsEvent = new AnalyticsPayload(); |
| 1 | 711 | | private static DelightedSurveyEnabledPayload delightedSurveyEnabled = new DelightedSurveyEnabledPayload(); |
| 1 | 712 | | private static ExternalActionSceneEventPayload sceneExternalActionEvent = new ExternalActionSceneEventPayload(); |
| 1 | 713 | | private static MuteUserPayload muteUserEvent = new MuteUserPayload(); |
| 1 | 714 | | private static StoreSceneStateEvent storeSceneState = new StoreSceneStateEvent(); |
| 1 | 715 | | private static CloseUserAvatarPayload closeUserAvatarPayload = new CloseUserAvatarPayload(); |
| 1 | 716 | | private static StringPayload stringPayload = new StringPayload(); |
| 1 | 717 | | private static KillPortableExperiencePayload killPortableExperiencePayload = new KillPortableExperiencePayload() |
| 1 | 718 | | private static RequestWearablesPayload requestWearablesPayload = new RequestWearablesPayload(); |
| 1 | 719 | | private static SearchENSOwnerPayload searchEnsOwnerPayload = new SearchENSOwnerPayload(); |
| 1 | 720 | | private static HeadersPayload headersPayload = new HeadersPayload(); |
| | 721 | |
|
| | 722 | | public static void SendSceneEvent<T>(string sceneId, string eventType, T payload) |
| | 723 | | { |
| 258 | 724 | | SceneEvent<T> sceneEvent = new SceneEvent<T>(); |
| 258 | 725 | | sceneEvent.sceneId = sceneId; |
| 258 | 726 | | sceneEvent.eventType = eventType; |
| 258 | 727 | | sceneEvent.payload = payload; |
| | 728 | |
|
| 258 | 729 | | SendMessage("SceneEvent", sceneEvent); |
| 258 | 730 | | } |
| | 731 | |
|
| | 732 | | private static void SendAllScenesEvent<T>(string eventType, T payload) |
| | 733 | | { |
| 649 | 734 | | AllScenesEvent<T> allScenesEvent = new AllScenesEvent<T>(); |
| 649 | 735 | | allScenesEvent.eventType = eventType; |
| 649 | 736 | | allScenesEvent.payload = payload; |
| | 737 | |
|
| 649 | 738 | | SendMessage("AllScenesEvent", allScenesEvent); |
| 649 | 739 | | } |
| | 740 | |
|
| | 741 | | public static void ReportPosition(Vector3 position, Quaternion rotation, float playerHeight) |
| | 742 | | { |
| 545 | 743 | | positionPayload.position = position; |
| 545 | 744 | | positionPayload.rotation = rotation; |
| 545 | 745 | | positionPayload.playerHeight = playerHeight; |
| | 746 | |
|
| 545 | 747 | | SendMessage("ReportPosition", positionPayload); |
| 545 | 748 | | } |
| | 749 | |
|
| | 750 | | public static void ReportCameraChanged(CameraMode.ModeId cameraMode) |
| | 751 | | { |
| 206 | 752 | | cameraModePayload.cameraMode = cameraMode; |
| 206 | 753 | | SendAllScenesEvent("cameraModeChanged", cameraModePayload); |
| 206 | 754 | | } |
| | 755 | |
|
| | 756 | | public static void ReportIdleStateChanged(bool isIdle) |
| | 757 | | { |
| 443 | 758 | | idleStateChangedPayload.isIdle = isIdle; |
| 443 | 759 | | SendAllScenesEvent("idleStateChanged", idleStateChangedPayload); |
| 443 | 760 | | } |
| | 761 | |
|
| 1402 | 762 | | public static void ReportControlEvent<T>(T controlEvent) where T : ControlEvent { SendMessage("ControlEvent", co |
| | 763 | |
|
| | 764 | | public static void SendRequestHeadersForUrl(string eventName, string method, string url) |
| | 765 | | { |
| 27 | 766 | | headersPayload.method = method; |
| 27 | 767 | | headersPayload.url = url; |
| 27 | 768 | | SendMessage(eventName, headersPayload ); |
| 27 | 769 | | } |
| | 770 | |
|
| 10 | 771 | | public static void BuilderInWorldMessage(string type, string message) { MessageFromEngine(type, message); } |
| | 772 | |
|
| | 773 | | public static void ReportOnClickEvent(string sceneId, string uuid) |
| | 774 | | { |
| 7 | 775 | | if (string.IsNullOrEmpty(uuid)) |
| | 776 | | { |
| 0 | 777 | | return; |
| | 778 | | } |
| | 779 | |
|
| 7 | 780 | | onClickEvent.uuid = uuid; |
| | 781 | |
|
| 7 | 782 | | SendSceneEvent(sceneId, "uuidEvent", onClickEvent); |
| 7 | 783 | | } |
| | 784 | |
|
| | 785 | | private static void ReportRaycastResult<T, P>(string sceneId, string queryId, string queryType, P payload) where |
| | 786 | | { |
| 0 | 787 | | T response = new T(); |
| 0 | 788 | | response.queryId = queryId; |
| 0 | 789 | | response.queryType = queryType; |
| 0 | 790 | | response.payload = payload; |
| | 791 | |
|
| 0 | 792 | | SendSceneEvent<T>(sceneId, "raycastResponse", response); |
| 0 | 793 | | } |
| | 794 | |
|
| 0 | 795 | | public static void ReportRaycastHitFirstResult(string sceneId, string queryId, RaycastType raycastType, RaycastH |
| | 796 | |
|
| 0 | 797 | | public static void ReportRaycastHitAllResult(string sceneId, string queryId, RaycastType raycastType, RaycastHit |
| | 798 | |
|
| | 799 | | private static OnPointerEventPayload.Hit CreateHitObject(string entityId, string meshName, Vector3 point, Vector |
| | 800 | | { |
| 20 | 801 | | OnPointerEventPayload.Hit hit = new OnPointerEventPayload.Hit(); |
| | 802 | |
|
| 20 | 803 | | hit.hitPoint = point; |
| 20 | 804 | | hit.length = distance; |
| 20 | 805 | | hit.normal = normal; |
| 20 | 806 | | hit.worldNormal = normal; |
| 20 | 807 | | hit.meshName = meshName; |
| 20 | 808 | | hit.entityId = entityId; |
| | 809 | |
|
| 20 | 810 | | return hit; |
| | 811 | | } |
| | 812 | |
|
| | 813 | | private static void SetPointerEventPayload(OnPointerEventPayload pointerEventPayload, ACTION_BUTTON buttonId, st |
| | 814 | | { |
| 20 | 815 | | pointerEventPayload.origin = ray.origin; |
| 20 | 816 | | pointerEventPayload.direction = ray.direction; |
| 20 | 817 | | pointerEventPayload.buttonId = buttonId; |
| | 818 | |
|
| 20 | 819 | | if (isHitInfoValid) |
| 20 | 820 | | pointerEventPayload.hit = CreateHitObject(entityId, meshName, point, normal, distance); |
| | 821 | | else |
| 0 | 822 | | pointerEventPayload.hit = null; |
| 0 | 823 | | } |
| | 824 | |
|
| | 825 | | public static void ReportGlobalPointerDownEvent(ACTION_BUTTON buttonId, Ray ray, Vector3 point, Vector3 normal, |
| | 826 | | { |
| 11 | 827 | | SetPointerEventPayload((OnPointerEventPayload) onGlobalPointerEventPayload, buttonId, entityId, meshName, ra |
| 11 | 828 | | onGlobalPointerEventPayload.type = OnGlobalPointerEventPayload.InputEventType.DOWN; |
| | 829 | |
|
| 11 | 830 | | onGlobalPointerEvent.payload = onGlobalPointerEventPayload; |
| | 831 | |
|
| 11 | 832 | | SendSceneEvent(sceneId, "pointerEvent", onGlobalPointerEvent); |
| 11 | 833 | | } |
| | 834 | |
|
| | 835 | | public static void ReportGlobalPointerUpEvent(ACTION_BUTTON buttonId, Ray ray, Vector3 point, Vector3 normal, fl |
| | 836 | | { |
| 3 | 837 | | SetPointerEventPayload((OnPointerEventPayload) onGlobalPointerEventPayload, buttonId, entityId, meshName, ra |
| 3 | 838 | | onGlobalPointerEventPayload.type = OnGlobalPointerEventPayload.InputEventType.UP; |
| | 839 | |
|
| 3 | 840 | | onGlobalPointerEvent.payload = onGlobalPointerEventPayload; |
| | 841 | |
|
| 3 | 842 | | SendSceneEvent(sceneId, "pointerEvent", onGlobalPointerEvent); |
| 3 | 843 | | } |
| | 844 | |
|
| | 845 | | public static void ReportOnPointerDownEvent(ACTION_BUTTON buttonId, string sceneId, string uuid, string entityId |
| | 846 | | { |
| 4 | 847 | | if (string.IsNullOrEmpty(uuid)) |
| | 848 | | { |
| 0 | 849 | | return; |
| | 850 | | } |
| | 851 | |
|
| 4 | 852 | | onPointerDownEvent.uuid = uuid; |
| 4 | 853 | | SetPointerEventPayload(onPointerEventPayload, buttonId, entityId, meshName, ray, point, normal, distance, is |
| 4 | 854 | | onPointerDownEvent.payload = onPointerEventPayload; |
| | 855 | |
|
| 4 | 856 | | SendSceneEvent(sceneId, "uuidEvent", onPointerDownEvent); |
| 4 | 857 | | } |
| | 858 | |
|
| | 859 | | public static void ReportOnPointerUpEvent(ACTION_BUTTON buttonId, string sceneId, string uuid, string entityId, |
| | 860 | | { |
| 2 | 861 | | if (string.IsNullOrEmpty(uuid)) |
| | 862 | | { |
| 0 | 863 | | return; |
| | 864 | | } |
| | 865 | |
|
| 2 | 866 | | onPointerUpEvent.uuid = uuid; |
| 2 | 867 | | SetPointerEventPayload(onPointerEventPayload, buttonId, entityId, meshName, ray, point, normal, distance, is |
| 2 | 868 | | onPointerUpEvent.payload = onPointerEventPayload; |
| | 869 | |
|
| 2 | 870 | | SendSceneEvent(sceneId, "uuidEvent", onPointerUpEvent); |
| 2 | 871 | | } |
| | 872 | |
|
| | 873 | | public static void ReportOnTextSubmitEvent(string sceneId, string uuid, string text) |
| | 874 | | { |
| 1 | 875 | | if (string.IsNullOrEmpty(uuid)) |
| | 876 | | { |
| 1 | 877 | | return; |
| | 878 | | } |
| | 879 | |
|
| 0 | 880 | | onTextSubmitEvent.uuid = uuid; |
| 0 | 881 | | onTextSubmitEvent.payload.text = text; |
| | 882 | |
|
| 0 | 883 | | SendSceneEvent(sceneId, "uuidEvent", onTextSubmitEvent); |
| 0 | 884 | | } |
| | 885 | |
|
| | 886 | | public static void ReportOnTextInputChangedEvent(string sceneId, string uuid, string text) |
| | 887 | | { |
| 17 | 888 | | if (string.IsNullOrEmpty(uuid)) |
| | 889 | | { |
| 17 | 890 | | return; |
| | 891 | | } |
| | 892 | |
|
| 0 | 893 | | onTextInputChangeEvent.uuid = uuid; |
| 0 | 894 | | onTextInputChangeEvent.payload.value = text; |
| | 895 | |
|
| 0 | 896 | | SendSceneEvent(sceneId, "uuidEvent", onTextInputChangeEvent); |
| 0 | 897 | | } |
| | 898 | |
|
| | 899 | | public static void ReportOnFocusEvent(string sceneId, string uuid) |
| | 900 | | { |
| 3 | 901 | | if (string.IsNullOrEmpty(uuid)) |
| | 902 | | { |
| 3 | 903 | | return; |
| | 904 | | } |
| | 905 | |
|
| 0 | 906 | | onFocusEvent.uuid = uuid; |
| 0 | 907 | | SendSceneEvent(sceneId, "uuidEvent", onFocusEvent); |
| 0 | 908 | | } |
| | 909 | |
|
| | 910 | | public static void ReportOnBlurEvent(string sceneId, string uuid) |
| | 911 | | { |
| 1 | 912 | | if (string.IsNullOrEmpty(uuid)) |
| | 913 | | { |
| 1 | 914 | | return; |
| | 915 | | } |
| | 916 | |
|
| 0 | 917 | | onBlurEvent.uuid = uuid; |
| 0 | 918 | | SendSceneEvent(sceneId, "uuidEvent", onBlurEvent); |
| 0 | 919 | | } |
| | 920 | |
|
| | 921 | | public static void ReportOnScrollChange(string sceneId, string uuid, Vector2 value, int pointerId) |
| | 922 | | { |
| 15 | 923 | | if (string.IsNullOrEmpty(uuid)) |
| | 924 | | { |
| 13 | 925 | | return; |
| | 926 | | } |
| | 927 | |
|
| 2 | 928 | | onScrollChangeEvent.uuid = uuid; |
| 2 | 929 | | onScrollChangeEvent.payload.value = value; |
| 2 | 930 | | onScrollChangeEvent.payload.pointerId = pointerId; |
| | 931 | |
|
| 2 | 932 | | SendSceneEvent(sceneId, "uuidEvent", onScrollChangeEvent); |
| 2 | 933 | | } |
| | 934 | |
|
| 0 | 935 | | public static void ReportEvent<T>(string sceneId, T @event) { SendSceneEvent(sceneId, "uuidEvent", @event); } |
| | 936 | |
|
| | 937 | | public static void ReportOnMetricsUpdate(string sceneId, MetricsModel current, |
| | 938 | | MetricsModel limit) |
| | 939 | | { |
| 143 | 940 | | onMetricsUpdate.given = current; |
| 143 | 941 | | onMetricsUpdate.limit = limit; |
| | 942 | |
|
| 143 | 943 | | SendSceneEvent(sceneId, "metricsUpdate", onMetricsUpdate); |
| 143 | 944 | | } |
| | 945 | |
|
| | 946 | | public static void ReportOnEnterEvent(string sceneId, string uuid) |
| | 947 | | { |
| 0 | 948 | | if (string.IsNullOrEmpty(uuid)) |
| 0 | 949 | | return; |
| | 950 | |
|
| 0 | 951 | | onEnterEvent.uuid = uuid; |
| | 952 | |
|
| 0 | 953 | | SendSceneEvent(sceneId, "uuidEvent", onEnterEvent); |
| 0 | 954 | | } |
| | 955 | |
|
| 0 | 956 | | public static void LogOut() { SendMessage("LogOut"); } |
| | 957 | |
|
| 0 | 958 | | public static void RedirectToSignUp() { SendMessage("RedirectToSignUp"); } |
| | 959 | |
|
| 0 | 960 | | public static void PreloadFinished(string sceneId) { SendMessage("PreloadFinished", sceneId); } |
| | 961 | |
|
| | 962 | | public static void ReportMousePosition(Vector3 mousePosition, string id) |
| | 963 | | { |
| 0 | 964 | | positionPayload.mousePosition = mousePosition; |
| 0 | 965 | | positionPayload.id = id; |
| 0 | 966 | | SendMessage("ReportMousePosition", positionPayload); |
| 0 | 967 | | } |
| | 968 | |
|
| | 969 | | public static void SendScreenshot(string encodedTexture, string id) |
| | 970 | | { |
| 0 | 971 | | onSendScreenshot.encodedTexture = encodedTexture; |
| 0 | 972 | | onSendScreenshot.id = id; |
| 0 | 973 | | SendMessage("SendScreenshot", onSendScreenshot); |
| 0 | 974 | | } |
| | 975 | |
|
| | 976 | | public static void SetDelightedSurveyEnabled(bool enabled) |
| | 977 | | { |
| 78 | 978 | | delightedSurveyEnabled.enabled = enabled; |
| 78 | 979 | | SendMessage("SetDelightedSurveyEnabled", delightedSurveyEnabled); |
| 78 | 980 | | } |
| | 981 | |
|
| | 982 | | public static void SetScenesLoadRadius(float newRadius) |
| | 983 | | { |
| 1 | 984 | | setScenesLoadRadiusPayload.newRadius = newRadius; |
| 1 | 985 | | SendMessage("SetScenesLoadRadius", setScenesLoadRadiusPayload); |
| 1 | 986 | | } |
| | 987 | |
|
| | 988 | | [System.Serializable] |
| | 989 | | public class SaveAvatarPayload |
| | 990 | | { |
| | 991 | | public string face; |
| | 992 | | public string face128; |
| | 993 | | public string face256; |
| | 994 | | public string body; |
| | 995 | | public bool isSignUpFlow; |
| | 996 | | public AvatarModel avatar; |
| | 997 | | } |
| | 998 | |
|
| | 999 | | public static class RendererAuthenticationType |
| | 1000 | | { |
| 0 | 1001 | | public static string Guest => "guest"; |
| 0 | 1002 | | public static string WalletConnect => "wallet_connect"; |
| | 1003 | | } |
| | 1004 | |
|
| | 1005 | | [System.Serializable] |
| | 1006 | | public class SendAuthenticationPayload |
| | 1007 | | { |
| | 1008 | | public string rendererAuthenticationType; |
| | 1009 | | } |
| | 1010 | |
|
| | 1011 | | [System.Serializable] |
| | 1012 | | public class SendPassportPayload |
| | 1013 | | { |
| | 1014 | | public string name; |
| | 1015 | | public string email; |
| | 1016 | | } |
| | 1017 | |
|
| | 1018 | | [System.Serializable] |
| | 1019 | | public class SendSaveUserUnverifiedNamePayload |
| | 1020 | | { |
| | 1021 | | public string newUnverifiedName; |
| | 1022 | | } |
| | 1023 | |
|
| | 1024 | | [System.Serializable] |
| | 1025 | | public class SendSaveUserDescriptionPayload |
| | 1026 | | { |
| | 1027 | | public string description; |
| | 1028 | |
|
| 0 | 1029 | | public SendSaveUserDescriptionPayload(string description) |
| | 1030 | | { |
| 0 | 1031 | | this.description = description; |
| 0 | 1032 | | } |
| | 1033 | | } |
| | 1034 | |
|
| | 1035 | | [Serializable] |
| | 1036 | | public class SendVideoProgressEvent |
| | 1037 | | { |
| | 1038 | | public string componentId; |
| | 1039 | | public string sceneId; |
| | 1040 | | public string videoTextureId; |
| | 1041 | | public int status; |
| | 1042 | | public float currentOffset; |
| | 1043 | | public float videoLength; |
| | 1044 | | } |
| | 1045 | |
|
| 2 | 1046 | | public static void RequestOwnProfileUpdate() { SendMessage("RequestOwnProfileUpdate"); } |
| | 1047 | |
|
| | 1048 | | public static void SendSaveAvatar(AvatarModel avatar, Texture2D faceSnapshot, Texture2D face128Snapshot, Texture |
| | 1049 | | { |
| 1 | 1050 | | var payload = new SaveAvatarPayload() |
| | 1051 | | { |
| | 1052 | | avatar = avatar, |
| | 1053 | | face = System.Convert.ToBase64String(faceSnapshot.EncodeToPNG()), |
| | 1054 | | face128 = System.Convert.ToBase64String(face128Snapshot.EncodeToPNG()), |
| | 1055 | | face256 = System.Convert.ToBase64String(face256Snapshot.EncodeToPNG()), |
| | 1056 | | body = System.Convert.ToBase64String(bodySnapshot.EncodeToPNG()), |
| | 1057 | | isSignUpFlow = isSignUpFlow |
| | 1058 | | }; |
| 1 | 1059 | | SendMessage("SaveUserAvatar", payload); |
| 1 | 1060 | | } |
| | 1061 | |
|
| 0 | 1062 | | public static void SendAuthentication(string rendererAuthenticationType) { SendMessage("SendAuthentication", new |
| | 1063 | |
|
| 2 | 1064 | | public static void SendPassport(string name, string email) { SendMessage("SendPassport", new SendPassportPayload |
| | 1065 | |
|
| | 1066 | | public static void SendSaveUserUnverifiedName(string newName) |
| | 1067 | | { |
| 0 | 1068 | | var payload = new SendSaveUserUnverifiedNamePayload() |
| | 1069 | | { |
| | 1070 | | newUnverifiedName = newName |
| | 1071 | | }; |
| | 1072 | |
|
| 0 | 1073 | | SendMessage("SaveUserUnverifiedName", payload); |
| 0 | 1074 | | } |
| | 1075 | |
|
| | 1076 | | public static void SendSaveUserDescription(string about) |
| | 1077 | | { |
| 0 | 1078 | | SendMessage("SaveUserDescription", new SendSaveUserDescriptionPayload(about)); |
| 0 | 1079 | | } |
| | 1080 | |
|
| 2 | 1081 | | public static void SendUserAcceptedCollectibles(string airdropId) { SendMessage("UserAcceptedCollectibles", new |
| | 1082 | |
|
| 52 | 1083 | | public static void SaveUserTutorialStep(int newTutorialStep) { SendMessage("SaveUserTutorialStep", new TutorialS |
| | 1084 | |
|
| | 1085 | | public static void SendPerformanceReport(string encodedFrameTimesInMS, bool usingFPSCap, int hiccupsInThousandFr |
| | 1086 | | { |
| 0 | 1087 | | SendMessage("PerformanceReport", new PerformanceReportPayload() |
| | 1088 | | { |
| | 1089 | | samples = encodedFrameTimesInMS, |
| | 1090 | | fpsIsCapped = usingFPSCap, |
| | 1091 | | hiccupsInThousandFrames = hiccupsInThousandFrames, |
| | 1092 | | hiccupsTime = hiccupsTime, |
| | 1093 | | totalTime = totalTime |
| | 1094 | | }); |
| 0 | 1095 | | } |
| | 1096 | |
|
| 246 | 1097 | | public static void SendSystemInfoReport() { SendMessage("SystemInfoReport", new SystemInfoReportPayload()); } |
| | 1098 | |
|
| | 1099 | | public static void SendTermsOfServiceResponse(string sceneId, bool accepted, bool dontShowAgain) |
| | 1100 | | { |
| 2 | 1101 | | var payload = new TermsOfServiceResponsePayload() |
| | 1102 | | { |
| | 1103 | | sceneId = sceneId, |
| | 1104 | | accepted = accepted, |
| | 1105 | | dontShowAgain = dontShowAgain |
| | 1106 | | }; |
| 2 | 1107 | | SendMessage("TermsOfServiceResponse", payload); |
| 2 | 1108 | | } |
| | 1109 | |
|
| | 1110 | | public static void SendExpression(string expressionID, long timestamp) |
| | 1111 | | { |
| 2 | 1112 | | SendMessage("TriggerExpression", new SendExpressionPayload() |
| | 1113 | | { |
| | 1114 | | id = expressionID, |
| | 1115 | | timestamp = timestamp |
| | 1116 | | }); |
| 2 | 1117 | | } |
| | 1118 | |
|
| 0 | 1119 | | public static void ReportMotdClicked() { SendMessage("MotdConfirmClicked"); } |
| | 1120 | |
|
| 6 | 1121 | | public static void OpenURL(string url) { SendMessage("OpenWebURL", new OpenURLPayload { url = url }); } |
| | 1122 | |
|
| 0 | 1123 | | public static void SendReportScene(string sceneID) { SendMessage("ReportScene", sceneID); } |
| | 1124 | |
|
| 4 | 1125 | | public static void SendReportPlayer(string playerName) { SendMessage("ReportPlayer", playerName); } |
| | 1126 | |
|
| | 1127 | | public static void SendBlockPlayer(string userId) |
| | 1128 | | { |
| 1 | 1129 | | SendMessage("BlockPlayer", new SendBlockPlayerPayload() |
| | 1130 | | { |
| | 1131 | | userId = userId |
| | 1132 | | }); |
| 1 | 1133 | | } |
| | 1134 | |
|
| | 1135 | | public static void SendUnblockPlayer(string userId) |
| | 1136 | | { |
| 0 | 1137 | | SendMessage("UnblockPlayer", new SendUnblockPlayerPayload() |
| | 1138 | | { |
| | 1139 | | userId = userId |
| | 1140 | | }); |
| 0 | 1141 | | } |
| | 1142 | |
|
| | 1143 | | public static void RequestScenesInfoAroundParcel(Vector2 parcel, int maxScenesArea) |
| | 1144 | | { |
| 0 | 1145 | | SendMessage("RequestScenesInfoInArea", new RequestScenesInfoAroundParcelPayload() |
| | 1146 | | { |
| | 1147 | | parcel = parcel, |
| | 1148 | | scenesAround = maxScenesArea |
| | 1149 | | }); |
| 0 | 1150 | | } |
| | 1151 | |
|
| | 1152 | | public static void SendAudioStreamEvent(string url, bool play, float volume) |
| | 1153 | | { |
| 3 | 1154 | | onAudioStreamingEvent.url = url; |
| 3 | 1155 | | onAudioStreamingEvent.play = play; |
| 3 | 1156 | | onAudioStreamingEvent.volume = volume; |
| 3 | 1157 | | SendMessage("SetAudioStream", onAudioStreamingEvent); |
| 3 | 1158 | | } |
| | 1159 | |
|
| | 1160 | | public static void SendSetVoiceChatRecording(bool recording) |
| | 1161 | | { |
| 0 | 1162 | | setVoiceChatRecordingPayload.recording = recording; |
| 0 | 1163 | | SendMessage("SetVoiceChatRecording", setVoiceChatRecordingPayload); |
| 0 | 1164 | | } |
| | 1165 | |
|
| 0 | 1166 | | public static void ToggleVoiceChatRecording() { SendMessage("ToggleVoiceChatRecording"); } |
| | 1167 | |
|
| | 1168 | | public static void ApplySettings(float voiceChatVolume, int voiceChatAllowCategory) |
| | 1169 | | { |
| 6 | 1170 | | applySettingsPayload.voiceChatVolume = voiceChatVolume; |
| 6 | 1171 | | applySettingsPayload.voiceChatAllowCategory = voiceChatAllowCategory; |
| 6 | 1172 | | SendMessage("ApplySettings", applySettingsPayload); |
| 6 | 1173 | | } |
| | 1174 | |
|
| | 1175 | | public static void RequestGIFProcessor(string gifURL, string gifId, bool isWebGL1) |
| | 1176 | | { |
| 0 | 1177 | | gifSetupPayload.imageSource = gifURL; |
| 0 | 1178 | | gifSetupPayload.id = gifId; |
| 0 | 1179 | | gifSetupPayload.isWebGL1 = isWebGL1; |
| | 1180 | |
|
| 0 | 1181 | | SendMessage("RequestGIFProcessor", gifSetupPayload); |
| 0 | 1182 | | } |
| | 1183 | |
|
| | 1184 | | public static void DeleteGIF(string id) |
| | 1185 | | { |
| 0 | 1186 | | stringPayload.value = id; |
| 0 | 1187 | | SendMessage("DeleteGIF", stringPayload); |
| 0 | 1188 | | } |
| | 1189 | |
|
| | 1190 | | public static void GoTo(int x, int y) |
| | 1191 | | { |
| 2 | 1192 | | gotoEvent.x = x; |
| 2 | 1193 | | gotoEvent.y = y; |
| 2 | 1194 | | SendMessage("GoTo", gotoEvent); |
| 2 | 1195 | | } |
| | 1196 | |
|
| 0 | 1197 | | public static void GoToCrowd() { SendMessage("GoToCrowd"); } |
| | 1198 | |
|
| 0 | 1199 | | public static void GoToMagic() { SendMessage("GoToMagic"); } |
| | 1200 | |
|
| | 1201 | | public static void JumpIn(int x, int y, string serverName, string layerName) |
| | 1202 | | { |
| 1 | 1203 | | jumpInPayload.realm.serverName = serverName; |
| 1 | 1204 | | jumpInPayload.realm.layer = layerName; |
| | 1205 | |
|
| 1 | 1206 | | jumpInPayload.gridPosition.x = x; |
| 1 | 1207 | | jumpInPayload.gridPosition.y = y; |
| | 1208 | |
|
| 1 | 1209 | | SendMessage("JumpIn", jumpInPayload); |
| 1 | 1210 | | } |
| | 1211 | |
|
| | 1212 | | public static void SendChatMessage(ChatMessage message) |
| | 1213 | | { |
| 5 | 1214 | | sendChatMessageEvent.message = message; |
| 5 | 1215 | | SendMessage("SendChatMessage", sendChatMessageEvent); |
| 5 | 1216 | | } |
| | 1217 | |
|
| 8 | 1218 | | public static void UpdateFriendshipStatus(FriendsController.FriendshipUpdateStatusMessage message) { SendMessage |
| | 1219 | |
|
| 0 | 1220 | | public static void ScenesLoadingFeedback(LoadingFeedbackMessage message) { SendMessage("ScenesLoadingFeedback", |
| | 1221 | |
|
| 6 | 1222 | | public static void FetchHotScenes() { SendMessage("FetchHotScenes"); } |
| | 1223 | |
|
| | 1224 | | public static void SetBaseResolution(int resolution) |
| | 1225 | | { |
| 2 | 1226 | | baseResEvent.baseResolution = resolution; |
| 2 | 1227 | | SendMessage("SetBaseResolution", baseResEvent); |
| 2 | 1228 | | } |
| | 1229 | |
|
| 0 | 1230 | | public static void ReportAnalyticsEvent(string eventName) { ReportAnalyticsEvent(eventName, null); } |
| | 1231 | |
|
| | 1232 | | public static void ReportAnalyticsEvent(string eventName, AnalyticsPayload.Property[] eventProperties) |
| | 1233 | | { |
| 60 | 1234 | | analyticsEvent.name = eventName; |
| 60 | 1235 | | analyticsEvent.properties = eventProperties; |
| 60 | 1236 | | SendMessage("Track", analyticsEvent); |
| 60 | 1237 | | } |
| | 1238 | |
|
| 4 | 1239 | | public static void FetchBalanceOfMANA() { SendMessage("FetchBalanceOfMANA"); } |
| | 1240 | |
|
| | 1241 | | public static void SendSceneExternalActionEvent(string sceneId, string type, string payload) |
| | 1242 | | { |
| 78 | 1243 | | sceneExternalActionEvent.type = type; |
| 78 | 1244 | | sceneExternalActionEvent.payload = payload; |
| 78 | 1245 | | SendSceneEvent(sceneId, "externalAction", sceneExternalActionEvent); |
| 78 | 1246 | | } |
| | 1247 | |
|
| | 1248 | | public static void SetMuteUsers(string[] usersId, bool mute) |
| | 1249 | | { |
| 0 | 1250 | | muteUserEvent.usersId = usersId; |
| 0 | 1251 | | muteUserEvent.mute = mute; |
| 0 | 1252 | | SendMessage("SetMuteUsers", muteUserEvent); |
| 0 | 1253 | | } |
| | 1254 | |
|
| | 1255 | | public static void SendCloseUserAvatar(bool isSignUpFlow) |
| | 1256 | | { |
| 0 | 1257 | | closeUserAvatarPayload.isSignUpFlow = isSignUpFlow; |
| 0 | 1258 | | SendMessage("CloseUserAvatar", closeUserAvatarPayload); |
| 0 | 1259 | | } |
| | 1260 | |
|
| | 1261 | | public static void KillPortableExperience(string portableExperienceId) |
| | 1262 | | { |
| 0 | 1263 | | killPortableExperiencePayload.portableExperienceId = portableExperienceId; |
| 0 | 1264 | | SendMessage("KillPortableExperience", killPortableExperiencePayload); |
| 0 | 1265 | | } |
| | 1266 | |
|
| | 1267 | | public static void RequestWearables( |
| | 1268 | | string ownedByUser, |
| | 1269 | | string[] wearableIds, |
| | 1270 | | string[] collectionIds, |
| | 1271 | | string context) |
| | 1272 | | { |
| 2 | 1273 | | requestWearablesPayload.filters = new WearablesRequestFiltersPayload |
| | 1274 | | { |
| | 1275 | | ownedByUser = ownedByUser, |
| | 1276 | | wearableIds = wearableIds, |
| | 1277 | | collectionIds = collectionIds |
| | 1278 | | }; |
| | 1279 | |
|
| 2 | 1280 | | requestWearablesPayload.context = context; |
| | 1281 | |
|
| 2 | 1282 | | SendMessage("RequestWearables", requestWearablesPayload); |
| 2 | 1283 | | } |
| | 1284 | |
|
| | 1285 | | public static void SearchENSOwner(string name, int maxResults) |
| | 1286 | | { |
| 6 | 1287 | | searchEnsOwnerPayload.name = name; |
| 6 | 1288 | | searchEnsOwnerPayload.maxResults = maxResults; |
| | 1289 | |
|
| 6 | 1290 | | SendMessage("SearchENSOwner", searchEnsOwnerPayload); |
| 6 | 1291 | | } |
| | 1292 | |
|
| | 1293 | | public static void RequestUserProfile(string userId) |
| | 1294 | | { |
| 16 | 1295 | | stringPayload.value = userId; |
| 16 | 1296 | | SendMessage("RequestUserProfile", stringPayload); |
| 16 | 1297 | | } |
| | 1298 | |
|
| 12 | 1299 | | public static void ReportAvatarFatalError() { SendMessage("ReportAvatarFatalError"); } |
| | 1300 | |
|
| | 1301 | | public static void UnpublishScene(Vector2Int sceneCoordinates) |
| | 1302 | | { |
| 2 | 1303 | | var payload = new UnpublishScenePayload() { coordinates = $"{sceneCoordinates.x},{sceneCoordinates.y}" }; |
| 2 | 1304 | | SendMessage("UnpublishScene", payload); |
| 2 | 1305 | | } |
| | 1306 | |
|
| | 1307 | | public static void NotifyStatusThroughChat(string message) |
| | 1308 | | { |
| 0 | 1309 | | stringPayload.value = message; |
| 0 | 1310 | | SendMessage("NotifyStatusThroughChat", stringPayload); |
| 0 | 1311 | | } |
| | 1312 | | public static void ReportVideoProgressEvent( |
| | 1313 | | string componentId, |
| | 1314 | | string sceneId, |
| | 1315 | | string videoClipId, |
| | 1316 | | int videoStatus, |
| | 1317 | | float currentOffset, |
| | 1318 | | float length) |
| | 1319 | | { |
| 30 | 1320 | | SendVideoProgressEvent progressEvent = new SendVideoProgressEvent() |
| | 1321 | | { |
| | 1322 | | componentId = componentId, |
| | 1323 | | sceneId = sceneId, |
| | 1324 | | videoTextureId = videoClipId, |
| | 1325 | | status = videoStatus, |
| | 1326 | | currentOffset = currentOffset, |
| | 1327 | | videoLength = length |
| | 1328 | | }; |
| | 1329 | |
|
| 30 | 1330 | | SendMessage("VideoProgressEvent", progressEvent); |
| 30 | 1331 | | } |
| | 1332 | | } |
| | 1333 | | } |