Survivalcraft API 1.8.2.3 v1.8.2.3
Survivalcraft 2.4
载入中...
搜索中...
未找到
ComponentAimingSights.cs
浏览该文件的文档.
1using Engine;
5
6namespace Game {
9
11
13
15
17
18 public static int[] m_drawOrders = [2000];
19
20 public bool IsSightsVisible { get; set; }
21
23
24 public int[] DrawOrders => m_drawOrders;
25
26 public virtual void ShowAimingSights(Vector3 position, Vector3 direction) {
27 IsSightsVisible = true;
28 m_sightsPosition = position;
29 m_sightsDirection = direction;
30 }
31
32 public virtual void Update(float dt) {
33 IsSightsVisible = false;
34 }
35
36 public virtual void Draw(Camera camera, int drawOrder) {
37 if (camera.GameWidget != m_componentPlayer.GameWidget) {
38 return;
39 }
40 if (m_componentPlayer.ComponentHealth.Health > 0f
41 && m_componentPlayer.ComponentGui.ControlsContainerWidget.IsVisible) {
42 if (IsSightsVisible) {
43 Texture2D texture = ContentManager.Get<Texture2D>("Textures/Gui/Sights");
44 float s = 8f;
48 Vector3 p = v + s * (-vector - v2);
49 Vector3 p2 = v + s * (vector - v2);
50 Vector3 p3 = v + s * (vector + v2);
51 Vector3 p4 = v + s * (-vector + v2);
52 TexturedBatch3D texturedBatch3D = m_primitivesRenderer3D.TexturedBatch(texture, false, 0, DepthStencilState.None);
53 int count = texturedBatch3D.TriangleVertices.Count;
54 texturedBatch3D.QueueQuad(
55 p,
56 p2,
57 p3,
58 p4,
59 new Vector2(0f, 0f),
60 new Vector2(1f, 0f),
61 new Vector2(1f, 1f),
62 new Vector2(0f, 1f),
64 );
65 texturedBatch3D.TransformTriangles(camera.ViewMatrix, count);
66 }
67 bool isCrosshairVisible = !SettingsManager.HideCrosshair;
69 "IsCrosshairVisible",
70 loader => {
71 loader.IsCrosshairVisible(this, ref isCrosshairVisible);
72 return false;
73 }
74 );
75 if (isCrosshairVisible
76 && !camera.UsesMovementControls
78 && (SettingsManager.LookControlMode == LookControlMode.SplitTouch || !m_componentPlayer.ComponentInput.IsControlledByTouch)) {
79 Subtexture subtexture = ContentManager.Get<Subtexture>("Textures/Atlas/Crosshair");
80 float s2 = 1.25f;
81 Vector3 v3 = camera.ViewPosition + camera.ViewDirection * 50f;
83 Vector3 v4 = Vector3.Normalize(Vector3.Cross(camera.ViewDirection, vector2));
84 Vector3 p5 = v3 + s2 * (-vector2 - v4);
85 Vector3 p6 = v3 + s2 * (vector2 - v4);
86 Vector3 p7 = v3 + s2 * (vector2 + v4);
87 Vector3 p8 = v3 + s2 * (-vector2 + v4);
88 TexturedBatch3D texturedBatch3D2 = m_primitivesRenderer3D.TexturedBatch(subtexture.Texture, false, 0, DepthStencilState.None);
89 int count2 = texturedBatch3D2.TriangleVertices.Count;
90 texturedBatch3D2.QueueQuad(
91 p5,
92 p6,
93 p7,
94 p8,
95 new Vector2(subtexture.TopLeft.X, subtexture.TopLeft.Y),
96 new Vector2(subtexture.BottomRight.X, subtexture.TopLeft.Y),
97 new Vector2(subtexture.BottomRight.X, subtexture.BottomRight.Y),
98 new Vector2(subtexture.TopLeft.X, subtexture.BottomRight.Y),
100 );
101 texturedBatch3D2.TransformTriangles(camera.ViewMatrix, count2);
102 }
103 }
106 }
107
108 public override void Load(ValuesDictionary valuesDictionary, IdToEntityMap idToEntityMap) {
109 m_componentPlayer = Entity.FindComponent<ComponentPlayer>(true);
110 }
111 }
112}
static readonly DepthStencilState None
GameWidget GameWidget
bool UsesMovementControls
Matrix ViewMatrix
Vector3 ViewDirection
Matrix ProjectionMatrix
readonly PrimitivesRenderer2D m_primitivesRenderer2D
virtual void Draw(Camera camera, int drawOrder)
override void Load(ValuesDictionary valuesDictionary, IdToEntityMap idToEntityMap)
virtual void ShowAimingSights(Vector3 position, Vector3 direction)
readonly PrimitivesRenderer3D m_primitivesRenderer3D
static object Get(Type type, string name)
static LookControlMode LookControlMode
readonly Texture2D Texture
readonly Vector2 BottomRight
readonly Vector2 TopLeft
ValuesDictionary ValuesDictionary
static void HookAction(string HookName, Func< ModLoader, bool > action)
执行Hook
static Color White
static Vector3 Cross(Vector3 v1, Vector3 v2)
static Vector3 Normalize(Vector3 v)
static readonly Vector3 UnitY