Exemplo n.º 1
0
        public static void SpawnSceneObjects(int newSceneId, int oldSceneId)
        {
            if (newSceneId == oldSceneId)
            {
                _logger.Info($"Objects for scene {newSceneId} already loaded");
                return;
            }

            _logger.Info($"Loading objects for scene {newSceneId}");
            ParentManager.Instance.ParentCommand = ParentCommand.None;

            if (oldSceneId != 0 && LoaderAdapter.LoaderType == typeof(ApiLoader))
            {
                AMQPClient.UnSubscribeLogicChange(oldSceneId);
                AMQPClient.UnSubscribeCompilationError(oldSceneId);
                AMQPClient.UnSubscribeObjectChange(oldSceneId);
            }

            GameStateData.ClearObjects();
            ProjectData.ObjectsAreChanged = false;
            Data.ServerData.Scene location      = ProjectData.ProjectStructure.Scenes.GetProjectScene(newSceneId);
            LogicInstance         logicInstance = new LogicInstance(newSceneId);

            GameStateData.RefreshLogic(logicInstance, location.AssemblyBytes);
            CreateSpawnEntities(location.SceneObjects, newSceneId);

            if (LoaderAdapter.LoaderType == typeof(ApiLoader))
            {
                AMQPClient.SubscribeLogicChange(newSceneId);
                AMQPClient.SubscribeCompilationError(newSceneId);
                AMQPClient.SubscribeObjectChange(ProjectData.ProjectId, newSceneId);
            }
        }
Exemplo n.º 2
0
        public static void ReloadSceneObjects()
        {
            _logger.Info($"Reloading objects on scene {ProjectData.SceneId}");
            ParentManager.Instance.ParentCommand = ParentCommand.None;
            GameStateData.ClearObjects();
            ProjectData.ObjectsAreChanged = false;
            Data.ServerData.Scene location      = ProjectData.ProjectStructure.Scenes.GetProjectScene(ProjectData.SceneId);
            LogicInstance         logicInstance = new LogicInstance(ProjectData.SceneId);

            GameStateData.RefreshLogic(logicInstance, location.AssemblyBytes);
            CreateSpawnEntities(location.SceneObjects, ProjectData.SceneId);
        }
Exemplo n.º 3
0
        private static List <PrefabObject> GetUsingObjects(int sceneId)
        {
            CheckSceneId();
            Data.ServerData.Scene currentLocation = ProjectData.ProjectStructure.Scenes.Find(location => location.Id == sceneId);
            List <PrefabObject>   usingObjects    = new List <PrefabObject>();

            foreach (PrefabObject prefabObject in ProjectData.ProjectStructure.Objects)
            {
                foreach (ObjectDto objectDto in currentLocation.SceneObjects)
                {
                    if (objectDto.ObjectId != prefabObject.Id)
                    {
                        continue;
                    }

                    if (!usingObjects.Contains(prefabObject))
                    {
                        usingObjects.Add(prefabObject);
                    }
                }
            }

            return(usingObjects);
        }