Survivalcraft API 1.8.2.3 v1.8.2.3
Survivalcraft 2.4
载入中...
搜索中...
未找到
SubsystemFurnaceBlockBehavior.cs
浏览该文件的文档.
1using Engine;
3
4namespace Game {
7
8 public Dictionary<Point3, FireParticleSystem> m_particleSystemsByCell = [];
9
10 public override int[] HandledBlocks => [64, 65];
11
12 public override void OnBlockAdded(int value, int oldValue, int x, int y, int z) {
13 if (Terrain.ExtractContents(oldValue) != 64
14 && Terrain.ExtractContents(oldValue) != 65) {
15 base.OnBlockAdded(value, oldValue, x, y, z);
16 }
17 if (Terrain.ExtractContents(value) == 65) {
18 AddFire(value, x, y, z);
19 }
20 }
21
22 public override void OnBlockRemoved(int value, int newValue, int x, int y, int z) {
23 if (Terrain.ExtractContents(newValue) != 64
24 && Terrain.ExtractContents(newValue) != 65) {
25 base.OnBlockRemoved(value, newValue, x, y, z);
26 }
27 if (Terrain.ExtractContents(value) == 65) {
28 RemoveFire(x, y, z);
29 }
30 }
31
32 public override void OnBlockGenerated(int value, int x, int y, int z, bool isLoaded) {
33 if (Terrain.ExtractContents(value) == 65) {
34 AddFire(value, x, y, z);
35 }
36 }
37
38 public override void OnChunkDiscarding(TerrainChunk chunk) {
39 List<Point3> list = new();
40 foreach (Point3 key in m_particleSystemsByCell.Keys) {
41 if (key.X >= chunk.Origin.X
42 && key.X < chunk.Origin.X + 16
43 && key.Z >= chunk.Origin.Y
44 && key.Z < chunk.Origin.Y + 16) {
45 list.Add(key);
46 }
47 }
48 foreach (Point3 item in list) {
49 RemoveFire(item.X, item.Y, item.Z);
50 }
51 }
52
53 public override bool InteractBlockEntity(ComponentBlockEntity blockEntity, ComponentMiner componentMiner) {
54 if (blockEntity != null
55 && componentMiner.ComponentPlayer != null) {
56 ComponentFurnace componentFurnace = blockEntity.Entity.FindComponent<ComponentFurnace>(true);
57 componentMiner.ComponentPlayer.ComponentGui.ModalPanelWidget = new FurnaceWidget(componentMiner.Inventory, componentFurnace);
58 AudioManager.PlaySound("Audio/UI/ButtonClick", 1f, 0f, 0f);
59 return true;
60 }
61 return false;
62 }
63
64 public override void Load(ValuesDictionary valuesDictionary) {
65 base.Load(valuesDictionary);
66 m_subsystemParticles = Project.FindSubsystem<SubsystemParticles>(true);
67 m_databaseObject = Project.GameDatabase.Database.FindDatabaseObject("Furnace", Project.GameDatabase.EntityTemplateType, true);
68 }
69
70 public void AddFire(int value, int x, int y, int z) {
71 /*
72 var v = new Vector3(0.5f, 0.2f, 0.5f);
73 float size = 0.15f;
74 var fireParticleSystem = new FireParticleSystem(new Vector3(x, y, z) + v, size, 16f);
75 m_subsystemParticles.AddParticleSystem(fireParticleSystem);
76 m_particleSystemsByCell[new Point3(x, y, z)] = fireParticleSystem;
77 */
78 }
79
80 public void RemoveFire(int x, int y, int z) {
81 /*
82 var key = new Point3(x, y, z);
83 FireParticleSystem particleSystem = m_particleSystemsByCell[key];
84 m_subsystemParticles.RemoveParticleSystem(particleSystem);
85 m_particleSystemsByCell.Remove(key);
86 */
87 }
88 }
89}
static void PlaySound(string name, float volume, float pitch, float pan)
ComponentPlayer ComponentPlayer
override bool InteractBlockEntity(ComponentBlockEntity blockEntity, ComponentMiner componentMiner)
Dictionary< Point3, FireParticleSystem > m_particleSystemsByCell
override void Load(ValuesDictionary valuesDictionary)
override void OnBlockRemoved(int value, int newValue, int x, int y, int z)
override void OnChunkDiscarding(TerrainChunk chunk)
override void OnBlockGenerated(int value, int x, int y, int z, bool isLoaded)
override void OnBlockAdded(int value, int oldValue, int x, int y, int z)
static int ExtractContents(int value)
Component FindComponent(Type type, string name, bool throwOnError)
ValuesDictionary ValuesDictionary