Exemple #1
0
        public void OnModifiedRenderComponent(Cv_Event eventData)
        {
            var castEventData = (Cv_Event_ModifiedRenderComponent)eventData;

            Cv_EntityID entityId = castEventData.EntityID;

            if (entityId == Cv_EntityID.INVALID_ENTITY)
            {
                Cv_Debug.Error("OnModifiedRenderComponent - Unknown entity ID!");
                return;
            }

            if (Caravel.Logic.State == Cv_GameState.LoadingScene)
            {
                return;
            }

            var sceneNodes = GetEntityNodes(entityId);

            if (sceneNodes == null || sceneNodes.Length <= 0)
            {
                Cv_Debug.Error("Failed to apply changes to scene node for entity " + entityId);
            }
            else
            {
                foreach (var n in sceneNodes)
                {
                    if (!n.VOnChanged())
                    {
                        Cv_Debug.Error("Error applying changes to scene node for entity " + entityId);
                    }
                }
            }
        }
Exemple #2
0
 private void OnSceneLoaded(Cv_Event eventData)
 {
     if (State == Cv_GameState.LoadingScene)
     {
         ChangeState(Cv_GameState.WaitingForPlayersToLoadScene);
     }
 }
Exemple #3
0
        private void OnResumeSound(Cv_Event eventData)
        {
            var resumeEvt = (Cv_Event_ResumeSound)eventData;

            var entity = CaravelApp.Instance.Logic.GetEntity(resumeEvt.EntityID);

            Caravel.SoundManager.ResumeSound(resumeEvt.SoundResource, entity);
        }
Exemple #4
0
        private void OnPauseSound(Cv_Event eventData)
        {
            var pauseEvt = (Cv_Event_PauseSound)eventData;

            var entity = CaravelApp.Instance.Logic.GetEntity(pauseEvt.EntityID);

            Caravel.SoundManager.PauseSound(pauseEvt.SoundResource, entity);
        }
Exemple #5
0
        private void OnStopSound(Cv_Event eventData)
        {
            var stopEvt = (Cv_Event_StopSound)eventData;

            var entity = CaravelApp.Instance.Logic.GetEntity(stopEvt.EntityID);

            Caravel.SoundManager.StopSound(stopEvt.SoundResource, entity);
        }
Exemple #6
0
        public void OnMoveEntity(Cv_Event eventData)
        {
            Cv_HolderNode holderNode = null;

            if (m_HolderNodes.TryGetValue(eventData.EntityID, out holderNode))
            {
                SetNodeTransform(holderNode);
            }
        }
Exemple #7
0
        public void OnNewCameraComponent(Cv_Event eventData)
        {
            var castEventData = (Cv_Event_NewCameraComponent)eventData;
            var cameraNode    = castEventData.CameraNode;
            var isDefault     = castEventData.IsDefault;

            if (isDefault)
            {
                Camera = cameraNode;
            }
        }
Exemple #8
0
        public void OnSceneLoaded(Cv_Event evt)
        {
            var sceneLoadedEvt = evt as Cv_Event_SceneLoaded;

            if (sceneLoadedEvt.SceneName == "Root")
            {
                Caravel.Logic.SetMainScene(sceneLoadedEvt.SceneID);
                var cam = Caravel.Logic.CreateEntity("camera.cve", "_editorCamera", "_EditorDefault");
                EditorCamera = cam.ID;
                Camera       = cam.GetComponent <Cv_CameraComponent>().CameraNode;
            }
        }
Exemple #9
0
        private void OnPlaySound(Cv_Event eventData)
        {
            var playEvt = (Cv_Event_PlaySound)eventData;

            var entity = CaravelApp.Instance.Logic.GetEntity(playEvt.EntityID);

            if (playEvt.Fade && playEvt.Interval > 0)
            {
                if (playEvt.Volume <= 0)
                {
                    Caravel.SoundManager.FadeOutSound(playEvt.SoundResource, playEvt.Interval);
                    return;
                }

                if (entity == null)
                {
                    Cv_Debug.Error("Attempting to play sound without an entity associated.");
                    return;
                }

                if (playEvt.Localized)
                {
                    Caravel.SoundManager.FadeInSound2D(playEvt.SoundResource, entity, playEvt.Listener, playEvt.Emitter,
                                                       playEvt.Interval, playEvt.Looping, playEvt.Volume, playEvt.Pan, playEvt.Pitch);
                }
                else
                {
                    Caravel.SoundManager.FadeInSound(playEvt.SoundResource, entity, playEvt.Interval, playEvt.Looping,
                                                     playEvt.Volume, playEvt.Pan, playEvt.Pitch);
                }
            }
            else
            {
                if (entity == null)
                {
                    Cv_Debug.Warning("Attempting to play sound without an entity associated.");
                    return;
                }

                if (playEvt.Localized)
                {
                    Caravel.SoundManager.PlaySound2D(playEvt.SoundResource, entity, playEvt.Listener, playEvt.Emitter,
                                                     playEvt.Looping, playEvt.Volume, playEvt.Pan, playEvt.Pitch);
                }
                else
                {
                    Caravel.SoundManager.PlaySound(playEvt.SoundResource, entity, playEvt.Looping,
                                                   playEvt.Volume, playEvt.Pan, playEvt.Pitch);
                }
            }
        }
Exemple #10
0
        public void OnNewRenderComponent(Cv_Event eventData)
        {
            var castEventData = (Cv_Event_NewRenderComponent)eventData;
            var entityId      = castEventData.EntityID;
            var sceneNode     = castEventData.SceneNode;
            var parentId      = castEventData.ParentID;

            if (CaravelApp.Instance.Logic.GetEntity(entityId) == null)
            {
                return;
            }

            AddNodeAsChild(parentId, entityId, sceneNode);
        }
Exemple #11
0
        private void OnNewClickableComponent(Cv_Event eventData)
        {
            var castEventData = (Cv_Event_NewClickableComponent)eventData;
            var entityId      = castEventData.EntityID;
            var clickAreaNode = castEventData.ClickAreaNode;
            var parentId      = castEventData.ParentID;

            if (CaravelApp.Instance.Logic.GetEntity(entityId) == null)
            {
                return;
            }

            AddNodeAsChild(parentId, entityId, clickAreaNode);
        }
 internal override void VExecuteFile(string resource, Cv_Event runningEvent)
 {
     try
     {
         throw new NotImplementedException();
     }
     catch (LuaException e)
     {
         Cv_Debug.Error("Error executing Lua script:\n" + e.ToString());
     }
     catch (Exception e)
     {
         Cv_Debug.Error("Error executing Lua script:\n" + e.ToString());
     }
 }
Exemple #13
0
        private void OnNewEntityRequest(Cv_Event eventData)
        {
            Cv_Debug.Assert(IsProxy, "Should only enter RequestNewEntityCallback when game logic is a proxy.");
            if (!IsProxy)
            {
                return;
            }

            Cv_Event_RequestNewEntity data = (Cv_Event_RequestNewEntity)eventData;
            var bundle = data.EntityResourceBundle;

            if (data.EntityResource != null)
            {
                CreateEntity(data.EntityResource, data.EntityName, bundle, data.Visible, data.Parent, null, data.InitialTransform, data.SceneID, data.ServerEntityID);
            }
            else
            {
                CreateEmptyEntity(data.EntityName, bundle, data.Visible, data.Parent, null, data.InitialTransform, data.SceneID, data.ServerEntityID);
            }
        }
Exemple #14
0
 internal abstract void VExecuteFile(string resource, Cv_Event runningEvent);
        internal override void VExecuteString(string resource, string str, bool runInEditor, Cv_Event runningEvent, Cv_Entity runningEntity)
        {
            Cv_Debug.Assert((m_iActiveQueue >= 0 && m_iActiveQueue < NUM_QUEUES), "ScriptManager must have an active script queue.");

            if (str == null)
            {
                Cv_Debug.Error("Invalid script in VExecuteString.");
                return;
            }

            Cv_ScriptExecutionRequest request = new Cv_ScriptExecutionRequest();

            request.Code        = str;
            request.Resource    = resource;
            request.Entity      = runningEntity;
            request.Event       = runningEvent;
            request.RunInEditor = runInEditor;

            lock (m_QueuedScriptLists[m_iActiveQueue])
            {
                m_QueuedScriptLists[m_iActiveQueue].AddLast(request);
            }

            Cv_Debug.Log("LuaScript", "Queued script " + resource + " for entity " + (runningEntity != null ? runningEntity.EntityName : "[null]"));
        }
        internal override void VExecuteStream(string resource, Stream stream, bool runInEditor, Cv_Event runningEvent)
        {
            Cv_Debug.Assert((m_iActiveQueue >= 0 && m_iActiveQueue < NUM_QUEUES), "ScriptManager must have an active script queue.");

            if (stream == null)
            {
                Cv_Debug.Error("Invalid stream in VExecuteStream.");
                return;
            }

            string code;

            using (StreamReader reader = new StreamReader(stream))
            {
                stream.Position = 0;
                code            = reader.ReadToEnd();
            }

            var entity = CaravelApp.Instance.Logic.GetEntity(runningEvent.EntityID);

            Cv_ScriptExecutionRequest request = new Cv_ScriptExecutionRequest();

            request.Code        = code;
            request.Resource    = resource;
            request.Entity      = entity;
            request.Event       = runningEvent;
            request.RunInEditor = runInEditor;

            lock (m_QueuedScriptLists[m_iActiveQueue])
            {
                m_QueuedScriptLists[m_iActiveQueue].AddLast(request);
            }

            Cv_Debug.Log("LuaScript", "Queued script " + resource + " for entity " + (entity != null ? entity.EntityName : "[null]"));
        }
Exemple #17
0
 private void OnStopAllSounds(Cv_Event eventData)
 {
     Caravel.SoundManager.StopAllSounds();
 }
Exemple #18
0
 private void OnResumeAllSounds(Cv_Event eventData)
 {
     Caravel.SoundManager.ResumeAllSounds();
 }
Exemple #19
0
        internal void OnGameState(Cv_Event eventData)
        {
            var newStateEvt = (Cv_Event_ChangeState)eventData;

            GameState = newStateEvt.NewState;
        }
Exemple #20
0
        private void OnDestroyEntityRequest(Cv_Event eventData)
        {
            Cv_Event_RequestDestroyEntity data = (Cv_Event_RequestDestroyEntity)eventData;

            DestroyEntity(data.EntityID);
        }
Exemple #21
0
        public void OnDestroyRenderComponent(Cv_Event eventData)
        {
            Cv_Event_DestroyRenderComponent destroyRender = (Cv_Event_DestroyRenderComponent)eventData;

            RemoveNode(destroyRender.SceneNode);
        }
Exemple #22
0
        public void OnDestroyClickableComponent(Cv_Event eventData)
        {
            Cv_Event_DestroyClickableComponent destroyCamera = (Cv_Event_DestroyClickableComponent)eventData;

            RemoveNode(destroyCamera.ClickAreaNode);
        }
Exemple #23
0
        public void OnDestroyEntity(Cv_Event eventData)
        {
            Cv_Event_DestroyEntity destroyEntity = (Cv_Event_DestroyEntity)eventData;

            RemoveNode(destroyEntity.EntityID);
        }
Exemple #24
0
 internal abstract void VExecuteString(string resource, string str, bool runInEditor, Cv_Event runningEvent, Cv_Entity runningEntity);
Exemple #25
0
 internal abstract void VExecuteStream(string resource, Stream stream, bool runInEditor, Cv_Event runningEvent);
Exemple #26
0
 private void OnPauseAllSounds(Cv_Event eventData)
 {
     Caravel.SoundManager.PauseAllSounds();
 }