コード例 #1
0
ファイル: ParcelScene.cs プロジェクト: eyesnareinc/explorer
        public void SharedComponentUpdate(string id, string json, out CleanableYieldInstruction yieldInstruction)
        {
            ProfilingEvents.OnMessageDecodeStart?.Invoke("ComponentUpdated");
            BaseDisposable newComponent = SharedComponentUpdate(id, json);

            ProfilingEvents.OnMessageDecodeEnds?.Invoke("ComponentUpdated");

            yieldInstruction = null;

            if (newComponent != null && newComponent.isRoutineRunning)
            {
                yieldInstruction = newComponent.yieldInstruction;
            }
        }
コード例 #2
0
ファイル: ParcelScene.cs プロジェクト: menduz/explorer
        public BaseDisposable SharedComponentUpdate(string id, string json, out CleanableYieldInstruction yieldInstruction)
        {
            SceneController.i.OnMessageDecodeStart?.Invoke("ComponentUpdated");
            BaseDisposable newComponent = SharedComponentUpdate(id, json);

            SceneController.i.OnMessageDecodeEnds?.Invoke("ComponentUpdated");

            yieldInstruction = null;

            if (newComponent != null && newComponent.isRoutineRunning)
            {
                yieldInstruction = newComponent.yieldInstruction;
            }

            return(newComponent);
        }
コード例 #3
0
ファイル: ParcelScene.cs プロジェクト: menduz/explorer
        public BaseComponent EntityComponentCreateOrUpdate(string entityId, string name, int classIdNum, string data, out CleanableYieldInstruction yieldInstruction)
        {
            yieldInstruction = null;

            SceneController.i.OnMessageDecodeStart?.Invoke("UpdateEntityComponent");
            createEntityComponentMessage.name     = name;
            createEntityComponentMessage.classId  = classIdNum;
            createEntityComponentMessage.entityId = entityId;
            createEntityComponentMessage.json     = data;

            SceneController.i.OnMessageDecodeEnds?.Invoke("UpdateEntityComponent");

            DecentralandEntity entity = GetEntityForUpdate(createEntityComponentMessage.entityId);

            if (entity == null)
            {
                Debug.LogError($"scene '{sceneData.id}': Can't create entity component if the entity {createEntityComponentMessage.entityId} doesn't exist!");
                return(null);
            }

            CLASS_ID_COMPONENT classId = (CLASS_ID_COMPONENT)createEntityComponentMessage.classId;

            if (classId == CLASS_ID_COMPONENT.TRANSFORM)
            {
                MessageDecoder.DecodeTransform(data, ref DCLTransform.model);

                if (entity.OnTransformChange != null)
                {
                    entity.OnTransformChange.Invoke(DCLTransform.model);
                }
                else
                {
                    entity.gameObject.transform.localPosition = DCLTransform.model.position;
                    entity.gameObject.transform.localRotation = DCLTransform.model.rotation;
                    entity.gameObject.transform.localScale    = DCLTransform.model.scale;

                    SceneController.i.boundariesChecker?.AddEntityToBeChecked(entity);
                }

                return(null);
            }

            BaseComponent       newComponent = null;
            DCLComponentFactory factory      = ownerController.componentFactory;

            Assert.IsNotNull(factory, "Factory is null?");

            // HACK: (Zak) will be removed when we separate each
            // uuid component as a different class id
            if (classId == CLASS_ID_COMPONENT.UUID_CALLBACK)
            {
                string type = "";

                OnPointerEvent.Model model = JsonUtility.FromJson <OnPointerEvent.Model>(createEntityComponentMessage.json);

                type = model.type;

                if (!entity.uuidComponents.ContainsKey(type))
                {
                    //NOTE(Brian): We have to contain it in a gameObject or it will be pooled with the components attached.
                    var go = new GameObject("UUID Component");
                    go.transform.SetParent(entity.gameObject.transform, false);

                    switch (type)
                    {
                    case OnClick.NAME:
                        newComponent = Utils.GetOrCreateComponent <OnClick>(go);
                        break;

                    case OnPointerDown.NAME:
                        newComponent = Utils.GetOrCreateComponent <OnPointerDown>(go);
                        break;

                    case OnPointerUp.NAME:
                        newComponent = Utils.GetOrCreateComponent <OnPointerUp>(go);
                        break;
                    }

                    if (newComponent != null)
                    {
                        UUIDComponent uuidComponent = newComponent as UUIDComponent;

                        if (uuidComponent != null)
                        {
                            uuidComponent.Setup(this, entity, model);
                            entity.uuidComponents.Add(type, uuidComponent);
                        }
                        else
                        {
                            Debug.LogError("uuidComponent is not of UUIDComponent type!");
                        }
                    }
                    else
                    {
                        Debug.LogError("EntityComponentCreateOrUpdate: Invalid UUID type!");
                    }
                }
                else
                {
                    newComponent = EntityUUIDComponentUpdate(entity, type, model);
                }
            }
            else
            {
                if (!entity.components.ContainsKey(classId))
                {
                    newComponent = factory.CreateItemFromId <BaseComponent>(classId);

                    if (newComponent != null)
                    {
                        newComponent.scene  = this;
                        newComponent.entity = entity;

                        entity.components.Add(classId, newComponent);

                        newComponent.transform.SetParent(entity.gameObject.transform, false);
                        newComponent.UpdateFromJSON(createEntityComponentMessage.json);
                    }
                }
                else
                {
                    newComponent = EntityComponentUpdate(entity, classId, createEntityComponentMessage.json);
                }
            }

            if (newComponent != null && newComponent.isRoutineRunning)
            {
                yieldInstruction = newComponent.yieldInstruction;
            }

            return(newComponent);
        }
コード例 #4
0
 public bool ProcessMessage(QueuedSceneMessage_Scene msgObject, out CleanableYieldInstruction yieldInstruction)
 {
     yieldInstruction = null;
     return(true);
 }