Esempio n. 1
0
        /// <summary>
        /// Adds an SquidSceneComponent to the Scenecomponents collection
        /// </summary>
        /// <param name="component">The SquidSceneComponent to add</param>
        public void AddComponent(SquidSceneComponent component)
        {
            //conkerjo. i think we should check if it's already owned by a scene and throw an exception here

            component.SetOwner(this);
            SceneComponents.Add(component);
        }
        internal static object DeepCopySquidSceneComponent(Type type, SquidSceneComponent cloneFrom)
        {
            //Create a new instance of the component
            SquidSceneComponent comp = (SquidSceneComponent)type.Assembly.CreateInstance(type.FullName);

            //CopyPropertiesTo(comp, cloneFrom);
            cloneFrom.CopyValuesTo(comp);
            return(comp);
        }
Esempio n. 3
0
        /// <summary>
        /// Calls Update on all enabled SceneItems and their Corresponding Components along with the SceneComponents
        /// </summary>
        /// <param name="elapsed">The elapsed game time since the last Update</param>
        internal static void UpdateSquidEngine(float elapsed)
        {
            if (SceneManager.ActiveScene == null || !SceneManager.ActiveScene.Enabled)
            {
                return;
            }

            // Unload the scenes in the queue (this will prevent a flicker from happening when unloading
            // scenes during update
            if (SceneManager.ScenesToUnload.Count > 0)
            {
                foreach (SquidScene oldScene in SceneManager.ScenesToUnload)
                {
                    oldScene.Unload();
                    oldScene.ContentManager.Unload();
                    oldScene.ContentManager.Dispose();

                    SceneManager.Scenes.Remove(oldScene);
                    if (oldScene == SceneManager.ActiveScene)
                    {
                        SceneManager.ActiveScene = null;
                    }
                    if (SceneManager.ActiveScene == null && SceneManager.Scenes.Count > 0) //Pick the top scene
                    {
                        SceneManager.ActiveScene = SceneManager.Scenes[SceneManager.Scenes.Count - 1];
                    }
                }

                SceneManager.ScenesToUnload.Clear();
            }

            SquidProfiler.StartProfiling(SquidProfilerNames.ICE_CORE_MAIN_UPDATE);
            // Differentiate between being in Milkshake and a running game
            if (SceneManager.ActiveScene.isInGame == false)
            {
                SceneManager.ActiveScene.isInGame = true;
            }
            if (SceneManager.ActiveScene._hasBeenUpdatedOnce == false)
            {
                SceneManager.ActiveScene._hasBeenUpdatedOnce = true;
            }
            SceneManager.ActiveScene.RemoveItems();
            SceneManager.ActiveScene.RegisterItems();

            //Pump input
            Input.InputCore.Update(elapsed);

            //First update any scene components
            for (int i = 0; i < SceneManager.ActiveScene.SceneComponents.Count; i++)
            {
                SquidSceneComponent comp = SceneManager.ActiveScene.SceneComponents[i];
                if (comp.Enabled == false)
                {
                    continue;
                }
                comp.Update(elapsed);
                if (activeSceneChanged == true)
                {
                    SquidProfiler.StopProfiling(SquidProfilerNames.ICE_CORE_MAIN_UPDATE);
                    return;
                }
            }

            // Physics.CollisionManager.CheckAndProcessCollisions();
            // Update Spatial Data
            for (int i = 0; i < SceneManager.ActiveScene.SceneItems.Count; i++)
            {
                SceneItem _item = SceneManager.ActiveScene.SceneItems[i];
                if (_item.IsTemplate == true)
                {
                    continue;
                }
                _item.Update(elapsed);
            }

            for (int i = 0; i < SceneManager.ActiveScene.SceneItems.Count; i++)
            {
                SceneItem _item = SceneManager.ActiveScene.SceneItems[i];
                if (_item.IsTemplate == true)
                {
                    continue;
                }
                // Update all its components
                UpdateItemsComponents(_item);
                if (_item.MarkForDelete == true)
                {
                    _itemsToDelete.Add(_item);
                }
                if (activeSceneChanged == true)
                {
                    SquidProfiler.StopProfiling(SquidProfilerNames.ICE_CORE_MAIN_UPDATE);
                    return;
                }
            }

            for (int i = 0; i < SceneManager.ActiveScene.ActiveCameras.Count; i++)
            {
                SceneManager.ActiveScene.ActiveCameras[i].Update(elapsed);
            }

            //if(SceneManager.networkSession != null)
            //{
            //UpdateNetworkToSend(elapsed);
            //}

            SquidProfiler.StopProfiling(SquidProfilerNames.ICE_CORE_MAIN_UPDATE);
        }