< Summary

Class:EntryPoint_World
Assembly:EntryPoint_World
File(s):/tmp/workspace/unity-renderer/unity-renderer/Assets/Scripts/MainScripts/DCL/WorldRuntime/EntryPoint_World/EntryPoint_World.cs
Covered lines:79
Uncovered lines:14
Coverable lines:93
Total lines:365
Line coverage:84.9% (79 of 93)
Covered branches:0
Total branches:0

Metrics

MethodBranch coverage Crap Score Cyclomatic complexity NPath complexity Sequence coverage
EntryPoint_World(...)0%110100%
OpenNftDialog(...)0%2100%
OpenExternalUrl(...)0%2100%
EntityComponentDestroy(...)0%110100%
SharedComponentAttach(...)0%110100%
Query(...)0%110100%
SharedComponentUpdate(...)0%110100%
SharedComponentDispose(...)0%110100%
SharedComponentCreate(...)0%110100%
EntityComponentCreateOrUpdate(...)0%110100%
SetEntityParent(...)0%110100%
SetEntityId(...)0%2100%
SetSceneId(...)0%110100%
SetTag(...)0%110100%
CreateEntity()0%110100%
RemoveEntity()0%110100%
SceneReady()0%110100%
GetSceneMessageInstance()0%2.012087.5%

File(s)

/tmp/workspace/unity-renderer/unity-renderer/Assets/Scripts/MainScripts/DCL/WorldRuntime/EntryPoint_World/EntryPoint_World.cs

#LineLine coverage
 1using System;
 2using System.Runtime.InteropServices;
 3using DCL;
 4using DCL.Interface;
 5using DCL.Models;
 6using UnityEngine;
 7using Ray = DCL.Models.Ray;
 8
 9public class EntryPoint_World
 10{
 11    private static string currentEntityId;
 12    private static string currentSceneId;
 13    private static string currentTag;
 14
 15    private static IMessageQueueHandler queueHandler;
 16
 17    delegate void JS_Delegate_VIS(int a, string b);
 18
 19    delegate void JS_Delegate_VSS(string a, string b);
 20
 21    delegate void JS_Delegate_VSSS(string a, string b, string c);
 22
 23    delegate void JS_Delegate_VS(string a);
 24
 25    delegate void JS_Delegate_Query(Protocol.QueryPayload a);
 26
 27    delegate void JS_Delegate_V();
 28
 529    public EntryPoint_World(IMessageQueueHandler queueHandler)
 30    {
 531        EntryPoint_World.queueHandler = queueHandler;
 32#if UNITY_WEBGL && !UNITY_EDITOR
 33        SetCallback_CreateEntity(CreateEntity);
 34        SetCallback_RemoveEntity(RemoveEntity);
 35        SetCallback_SceneReady(SceneReady);
 36
 37        SetCallback_SetEntityId(SetEntityId);
 38        SetCallback_SetSceneId(SetSceneId);
 39        SetCallback_SetTag(SetTag);
 40
 41        SetCallback_SetEntityParent(SetEntityParent);
 42
 43        SetCallback_EntityComponentCreateOrUpdate(EntityComponentCreateOrUpdate);
 44        SetCallback_EntityComponentDestroy(EntityComponentDestroy);
 45
 46        SetCallback_SharedComponentCreate(SharedComponentCreate);
 47        SetCallback_SharedComponentAttach(SharedComponentAttach);
 48        SetCallback_SharedComponentUpdate(SharedComponentUpdate);
 49        SetCallback_SharedComponentDispose(SharedComponentDispose);
 50
 51        SetCallback_OpenExternalUrl(OpenExternalUrl);
 52        SetCallback_OpenNftDialog(OpenNftDialog);
 53
 54        SetCallback_Query(Query);
 55#endif
 556    }
 57
 58    [MonoPInvokeCallback(typeof(JS_Delegate_VSSS))]
 59    internal static void OpenNftDialog(string contactAddress, string comment, string tokenId)
 60    {
 061        QueuedSceneMessage_Scene queuedMessage = GetSceneMessageInstance();
 62
 063        Protocol.OpenNftDialog payload = new Protocol.OpenNftDialog
 64        {
 65            contactAddress = contactAddress,
 66            comment = comment,
 67            tokenId = tokenId
 68        };
 69
 070        queuedMessage.payload = payload;
 071        queuedMessage.method = MessagingTypes.OPEN_NFT_DIALOG;
 72
 073        queueHandler.EnqueueSceneMessage(queuedMessage);
 074    }
 75
 76    [MonoPInvokeCallback(typeof(JS_Delegate_VS))]
 77    internal static void OpenExternalUrl(string url)
 78    {
 079        QueuedSceneMessage_Scene queuedMessage = GetSceneMessageInstance();
 80
 081        Protocol.OpenExternalUrl payload = new Protocol.OpenExternalUrl
 82        {
 83            url = url
 84        };
 85
 086        queuedMessage.payload = payload;
 087        queuedMessage.method = MessagingTypes.OPEN_EXTERNAL_URL;
 88
 089        queueHandler.EnqueueSceneMessage(queuedMessage);
 090    }
 91
 92    [MonoPInvokeCallback(typeof(JS_Delegate_VS))]
 93    internal static void EntityComponentDestroy(string name)
 94    {
 195        QueuedSceneMessage_Scene queuedMessage = GetSceneMessageInstance();
 96
 197        Protocol.EntityComponentDestroy payload = new Protocol.EntityComponentDestroy
 98        {
 99            entityId = currentEntityId,
 100            name = name
 101        };
 102
 1103        queuedMessage.payload = payload;
 1104        queuedMessage.method = MessagingTypes.ENTITY_COMPONENT_DESTROY;
 105
 1106        queueHandler.EnqueueSceneMessage(queuedMessage);
 1107    }
 108
 109    [MonoPInvokeCallback(typeof(JS_Delegate_VSS))]
 110    internal static void SharedComponentAttach(string id, string name)
 111    {
 1112        QueuedSceneMessage_Scene queuedMessage = GetSceneMessageInstance();
 113
 1114        Protocol.SharedComponentAttach payload = new Protocol.SharedComponentAttach
 115        {
 116            entityId = currentEntityId,
 117            id = id,
 118            name = name
 119        };
 120
 1121        queuedMessage.payload = payload;
 1122        queuedMessage.method = MessagingTypes.SHARED_COMPONENT_ATTACH;
 123
 1124        queueHandler.EnqueueSceneMessage(queuedMessage);
 1125    }
 126
 127    [MonoPInvokeCallback(typeof(JS_Delegate_Query))]
 128    internal static void Query(Protocol.QueryPayload payload)
 129    {
 1130        QueuedSceneMessage_Scene queuedMessage = GetSceneMessageInstance();
 131
 1132        string queryId = Convert.ToString(payload.raycastPayload.id);
 133
 1134        RaycastType raycastType = (RaycastType) payload.raycastPayload.raycastType;
 135
 1136        Ray ray = new Ray()
 137        {
 138            origin = payload.raycastPayload.origin,
 139            direction = payload.raycastPayload.direction,
 140            distance = payload.raycastPayload.distance
 141        };
 142
 1143        queuedMessage.method = MessagingTypes.QUERY;
 1144        queuedMessage.payload = new QueryMessage()
 145        {
 146            payload = new RaycastQuery()
 147            {
 148                id = queryId,
 149                raycastType = raycastType,
 150                ray = ray,
 151                sceneId = currentSceneId
 152            }
 153        };
 154
 1155        queueHandler.EnqueueSceneMessage(queuedMessage);
 1156    }
 157
 158    [MonoPInvokeCallback(typeof(JS_Delegate_VSS))]
 159    internal static void SharedComponentUpdate(string id, string json)
 160    {
 1161        QueuedSceneMessage_Scene queuedMessage = GetSceneMessageInstance();
 162
 1163        Protocol.SharedComponentUpdate payload =
 164            new Protocol.SharedComponentUpdate
 165            {
 166                componentId = id,
 167                json = json
 168            };
 169
 1170        queuedMessage.payload = payload;
 1171        queuedMessage.method = MessagingTypes.SHARED_COMPONENT_UPDATE;
 172
 1173        queueHandler.EnqueueSceneMessage(queuedMessage);
 1174    }
 175
 176    [MonoPInvokeCallback(typeof(JS_Delegate_VS))]
 177    internal static void SharedComponentDispose(string id)
 178    {
 1179        QueuedSceneMessage_Scene queuedMessage = GetSceneMessageInstance();
 180
 1181        Protocol.SharedComponentDispose payload =
 182            new Protocol.SharedComponentDispose
 183            {
 184                id = id
 185            };
 186
 1187        queuedMessage.payload = payload;
 1188        queuedMessage.method = MessagingTypes.SHARED_COMPONENT_DISPOSE;
 189
 1190        queueHandler.EnqueueSceneMessage(queuedMessage);
 1191    }
 192
 193    [MonoPInvokeCallback(typeof(JS_Delegate_VIS))]
 194    internal static void SharedComponentCreate(int classId, string id)
 195    {
 1196        QueuedSceneMessage_Scene queuedMessage = GetSceneMessageInstance();
 197
 1198        Protocol.SharedComponentCreate payload =
 199            new Protocol.SharedComponentCreate
 200            {
 201                id = id,
 202                classId = classId
 203            };
 204
 1205        queuedMessage.payload = payload;
 1206        queuedMessage.method = MessagingTypes.SHARED_COMPONENT_CREATE;
 207
 1208        queueHandler.EnqueueSceneMessage(queuedMessage);
 1209    }
 210
 211    [MonoPInvokeCallback(typeof(JS_Delegate_VIS))]
 212    internal static void EntityComponentCreateOrUpdate(int classId, string json)
 213    {
 1214        QueuedSceneMessage_Scene queuedMessage = GetSceneMessageInstance();
 215
 1216        Protocol.EntityComponentCreateOrUpdate payload =
 217            new Protocol.EntityComponentCreateOrUpdate
 218            {
 219                entityId = currentEntityId,
 220                classId = classId,
 221                json = json
 222            };
 223
 1224        queuedMessage.payload = payload;
 1225        queuedMessage.method = MessagingTypes.ENTITY_COMPONENT_CREATE_OR_UPDATE;
 226
 1227        queueHandler.EnqueueSceneMessage(queuedMessage);
 1228    }
 229
 230    [MonoPInvokeCallback(typeof(JS_Delegate_VS))]
 231    internal static void SetEntityParent(string parentId)
 232    {
 1233        QueuedSceneMessage_Scene queuedMessage = GetSceneMessageInstance();
 234
 1235        Protocol.SetEntityParent payload =
 236            new Protocol.SetEntityParent
 237            {
 238                entityId = currentEntityId,
 239                parentId = parentId
 240            };
 241
 1242        queuedMessage.payload = payload;
 1243        queuedMessage.method = MessagingTypes.ENTITY_REPARENT;
 244
 1245        queueHandler.EnqueueSceneMessage(queuedMessage);
 1246    }
 247
 248    [MonoPInvokeCallback(typeof(JS_Delegate_VS))]
 0249    internal static void SetEntityId(string id) { currentEntityId = id; }
 250
 251    [MonoPInvokeCallback(typeof(JS_Delegate_VS))]
 10252    internal static void SetSceneId(string id) { currentSceneId = id; }
 253
 254    [MonoPInvokeCallback(typeof(JS_Delegate_VS))]
 10255    internal static void SetTag(string id) { currentTag = id; }
 256
 257    [MonoPInvokeCallback(typeof(JS_Delegate_V))]
 258    internal static void CreateEntity()
 259    {
 4260        QueuedSceneMessage_Scene queuedMessage = GetSceneMessageInstance();
 261
 4262        Protocol.CreateEntity payload =
 263            new Protocol.CreateEntity
 264            {
 265                entityId = currentEntityId
 266            };
 267
 4268        queuedMessage.payload = payload;
 4269        queuedMessage.method = MessagingTypes.ENTITY_CREATE;
 270
 4271        queueHandler.EnqueueSceneMessage(queuedMessage);
 4272    }
 273
 274    [MonoPInvokeCallback(typeof(JS_Delegate_V))]
 275    internal static void RemoveEntity()
 276    {
 2277        QueuedSceneMessage_Scene queuedMessage = GetSceneMessageInstance();
 2278        Protocol.RemoveEntity payload =
 279            new Protocol.RemoveEntity()
 280            {
 281                entityId = currentEntityId
 282            };
 283
 2284        queuedMessage.payload = payload;
 2285        queuedMessage.method = MessagingTypes.ENTITY_DESTROY;
 286
 2287        queueHandler.EnqueueSceneMessage(queuedMessage);
 2288    }
 289
 290    [MonoPInvokeCallback(typeof(JS_Delegate_V))]
 291    internal static void SceneReady()
 292    {
 1293        QueuedSceneMessage_Scene queuedMessage = GetSceneMessageInstance();
 1294        queuedMessage.method = MessagingTypes.INIT_DONE;
 1295        queuedMessage.payload = new Protocol.SceneReady();
 296
 1297        queueHandler.EnqueueSceneMessage(queuedMessage);
 1298    }
 299
 300    internal static QueuedSceneMessage_Scene GetSceneMessageInstance()
 301    {
 302        QueuedSceneMessage_Scene message;
 303
 15304        var sceneMessagesPool = queueHandler.sceneMessagesPool;
 305
 15306        if (sceneMessagesPool.Count > 0)
 0307            message = sceneMessagesPool.Dequeue();
 308        else
 15309            message = new QueuedSceneMessage_Scene();
 310
 15311        message.sceneId = currentSceneId;
 15312        message.tag = currentTag;
 15313        message.type = QueuedSceneMessage.Type.SCENE_MESSAGE;
 314
 15315        return message;
 316    }
 317
 318    [DllImport("__Internal")]
 319    private static extern void SetCallback_CreateEntity(JS_Delegate_V callback);
 320
 321    [DllImport("__Internal")]
 322    private static extern void SetCallback_RemoveEntity(JS_Delegate_V callback);
 323
 324    [DllImport("__Internal")]
 325    private static extern void SetCallback_SceneReady(JS_Delegate_V callback);
 326
 327    [DllImport("__Internal")]
 328    private static extern void SetCallback_SetEntityId(JS_Delegate_VS callback);
 329
 330    [DllImport("__Internal")]
 331    private static extern void SetCallback_SetSceneId(JS_Delegate_VS callback);
 332
 333    [DllImport("__Internal")]
 334    private static extern void SetCallback_SetEntityParent(JS_Delegate_VS callback);
 335
 336    [DllImport("__Internal")]
 337    private static extern void SetCallback_EntityComponentCreateOrUpdate(JS_Delegate_VIS callback);
 338
 339    [DllImport("__Internal")]
 340    private static extern void SetCallback_SharedComponentAttach(JS_Delegate_VSS callback);
 341
 342    [DllImport("__Internal")]
 343    private static extern void SetCallback_EntityComponentDestroy(JS_Delegate_VS callback);
 344
 345    [DllImport("__Internal")]
 346    private static extern void SetCallback_OpenExternalUrl(JS_Delegate_VS callback);
 347
 348    [DllImport("__Internal")]
 349    private static extern void SetCallback_OpenNftDialog(JS_Delegate_VSSS callback);
 350
 351    [DllImport("__Internal")]
 352    private static extern void SetCallback_SharedComponentUpdate(JS_Delegate_VSS callback);
 353
 354    [DllImport("__Internal")]
 355    private static extern void SetCallback_SharedComponentDispose(JS_Delegate_VS callback);
 356
 357    [DllImport("__Internal")]
 358    private static extern void SetCallback_SharedComponentCreate(JS_Delegate_VIS callback);
 359
 360    [DllImport("__Internal")]
 361    private static extern void SetCallback_SetTag(JS_Delegate_VS callback);
 362
 363    [DllImport("__Internal")]
 364    private static extern void SetCallback_Query(JS_Delegate_Query callback);
 365}