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); } } } }
private void OnSceneLoaded(Cv_Event eventData) { if (State == Cv_GameState.LoadingScene) { ChangeState(Cv_GameState.WaitingForPlayersToLoadScene); } }
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); }
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); }
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); }
public void OnMoveEntity(Cv_Event eventData) { Cv_HolderNode holderNode = null; if (m_HolderNodes.TryGetValue(eventData.EntityID, out holderNode)) { SetNodeTransform(holderNode); } }
public void OnNewCameraComponent(Cv_Event eventData) { var castEventData = (Cv_Event_NewCameraComponent)eventData; var cameraNode = castEventData.CameraNode; var isDefault = castEventData.IsDefault; if (isDefault) { Camera = cameraNode; } }
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; } }
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); } } }
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); }
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()); } }
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); } }
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]")); }
private void OnStopAllSounds(Cv_Event eventData) { Caravel.SoundManager.StopAllSounds(); }
private void OnResumeAllSounds(Cv_Event eventData) { Caravel.SoundManager.ResumeAllSounds(); }
internal void OnGameState(Cv_Event eventData) { var newStateEvt = (Cv_Event_ChangeState)eventData; GameState = newStateEvt.NewState; }
private void OnDestroyEntityRequest(Cv_Event eventData) { Cv_Event_RequestDestroyEntity data = (Cv_Event_RequestDestroyEntity)eventData; DestroyEntity(data.EntityID); }
public void OnDestroyRenderComponent(Cv_Event eventData) { Cv_Event_DestroyRenderComponent destroyRender = (Cv_Event_DestroyRenderComponent)eventData; RemoveNode(destroyRender.SceneNode); }
public void OnDestroyClickableComponent(Cv_Event eventData) { Cv_Event_DestroyClickableComponent destroyCamera = (Cv_Event_DestroyClickableComponent)eventData; RemoveNode(destroyCamera.ClickAreaNode); }
public void OnDestroyEntity(Cv_Event eventData) { Cv_Event_DestroyEntity destroyEntity = (Cv_Event_DestroyEntity)eventData; RemoveNode(destroyEntity.EntityID); }
internal abstract void VExecuteString(string resource, string str, bool runInEditor, Cv_Event runningEvent, Cv_Entity runningEntity);
internal abstract void VExecuteStream(string resource, Stream stream, bool runInEditor, Cv_Event runningEvent);
private void OnPauseAllSounds(Cv_Event eventData) { Caravel.SoundManager.PauseAllSounds(); }