-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy pathEditorView.cs
78 lines (68 loc) · 1.96 KB
/
EditorView.cs
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
using Caravel.Core;
using Microsoft.Xna.Framework;
using static Caravel.Core.Entity.Cv_Entity;
using Microsoft.Xna.Framework.Graphics;
using Caravel.Core.Events;
using Caravel.Core.Draw;
using Caravel.Core.Entity;
namespace CaravelEditor
{
public class EditorView : Cv_PlayerView
{
public Cv_EntityID EditorCamera
{
get; private set;
}
public Cv_Renderer EditorRenderer
{
get
{
return Renderer;
}
}
public int SceneVirtualWidth
{
get
{
return Renderer.VirtualWidth;
}
set
{
Renderer.VirtualWidth = value;
}
}
public int SceneVirtualHeight
{
get
{
return Renderer.VirtualHeight;
}
set
{
Renderer.VirtualHeight = value;
}
}
public EditorView(Cv_Player player, SpriteBatch sb) : base(player, new Vector2(1,1), Vector2.Zero, sb)
{
DebugDrawPhysicsShapes = true;
DebugDrawCameras = true;
DebugDrawClickableAreas = true;
}
public void Init()
{
Cv_EventManager.Instance.AddListener<Cv_Event_SceneLoaded>(OnSceneLoaded);
Cv_EventManager.Instance.RemoveListener<Cv_Event_NewCameraComponent>(OnNewCameraComponent);
}
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;
}
}
}
}