Esempio n. 1
0
        /// <summary>
        /// Sent to a component when its parent entity is added to a scene
        /// </summary>
        /// <param name="manager">The <see cref="SceneManager"/> that added the entity to the scene.</param>
        public override void AddedToScene(SceneManager manager)
        {
            // First we need to get the current rendering camera.
            MsgGetRenderEntity camMsg = ObjectPool.Aquire <MsgGetRenderEntity>();

            this.parentEntity.Game.SendInterfaceMessage(camMsg, InterfaceType.Camera);

            // If the ID we received is not empty, then we're good to go
            if (camMsg.EntityID != QSGame.UniqueIDEmpty)
            {
                MsgAttachSkyToCamera attachCamMsg = ObjectPool.Aquire <MsgAttachSkyToCamera>();
                attachCamMsg.CameraEntityID = camMsg.EntityID;
                attachCamMsg.UniqueTarget   = this.parentEntity.UniqueID;
                this.parentEntity.Game.SendMessage(attachCamMsg);
            }
        }
Esempio n. 2
0
        /// <summary>
        /// Handles a message sent to this component.
        /// </summary>
        /// <param name="message">Message to be handled</param>
        /// <returns>True, if handled, otherwise false</returns>
        /// <exception cref="ArgumentException">Thrown if a <see cref="MessageType"/> is not handled properly."/></exception>
        public override bool ExecuteMessage(IMessage message)
        {
            if (message.UniqueTarget != this.parentEntity.UniqueID)
            {
                return(false);
            }

            switch (message.Type)
            {
            case MessageType.SkyAttachToCamera:
            {
                MsgAttachSkyToCamera attachMsg = message as MsgAttachSkyToCamera;
                message.TypeCheck(attachMsg);

                CameraEntityID = attachMsg.CameraEntityID;
            }
                return(true);

            default:
                return(false);
            }
        }