Survivalcraft API 1.8.2.3 v1.8.2.3
Survivalcraft 2.4
载入中...
搜索中...
未找到
SubsystemMatchBlockBehavior.cs
浏览该文件的文档.
1using Engine;
3
4namespace Game {
7
9
11
13
14 public Random m_random = new();
15
16 public override int[] HandledBlocks => [108];
17
18 public override bool OnUse(Ray3 ray, ComponentMiner componentMiner) {
19 object obj = componentMiner.Raycast(ray, RaycastMode.Digging);
20 if (obj is TerrainRaycastResult) {
21 CellFace cellFace = ((TerrainRaycastResult)obj).CellFace;
22 if (m_subsystemExplosivesBlockBehavior.IgniteFuse(cellFace.X, cellFace.Y, cellFace.Z)) {
23 m_subsystemAudio.PlaySound("Audio/Match", 1f, m_random.Float(-0.1f, 0.1f), ray.Position, 1f, true);
24 componentMiner.RemoveActiveTool(1);
25 return true;
26 }
27 if (m_subsystemFireBlockBehavior.SetCellOnFire(cellFace.X, cellFace.Y, cellFace.Z, 1f)) {
28 m_subsystemAudio.PlaySound("Audio/Match", 1f, m_random.Float(-0.1f, 0.1f), ray.Position, 1f, true);
29 componentMiner.RemoveActiveTool(1);
30 return true;
31 }
32 }
33 else if (obj is BodyRaycastResult) {
35 if (componentOnFire != null) {
36 if (m_subsystemGameInfo.WorldSettings.GameMode < GameMode.Challenging
37 || m_random.Float(0f, 1f) < 0.33f) {
38 componentOnFire.SetOnFire(componentMiner.ComponentCreature, m_random.Float(6f, 8f));
39 }
40 m_subsystemAudio.PlaySound("Audio/Match", 1f, m_random.Float(-0.1f, 0.1f), ray.Position, 1f, true);
41 componentMiner.RemoveActiveTool(1);
42 return true;
43 }
44 }
45 return false;
46 }
47
48 public override void Load(ValuesDictionary valuesDictionary) {
49 base.Load(valuesDictionary);
50 m_subsystemAudio = Project.FindSubsystem<SubsystemAudio>(true);
51 m_subsystemGameInfo = Project.FindSubsystem<SubsystemGameInfo>(true);
54 }
55 }
56}
ComponentCreature ComponentCreature
virtual void RemoveActiveTool(int removeCount)
virtual object Raycast(Ray3 ray, RaycastMode mode, bool raycastTerrain=true, bool raycastBodies=true, bool raycastMovingBlocks=true, float? Reach=null)
发出射线检测,检测玩家点击到的目标
virtual void SetOnFire(ComponentCreature attacker, float duration)
SubsystemExplosivesBlockBehavior m_subsystemExplosivesBlockBehavior
override bool OnUse(Ray3 ray, ComponentMiner componentMiner)
override void Load(ValuesDictionary valuesDictionary)
Component FindComponent(Type type, string name, bool throwOnError)
ValuesDictionary ValuesDictionary
Vector3 Position
定义 Ray3.cs:3