Survivalcraft API 1.8.2.3 v1.8.2.3
Survivalcraft 2.4
载入中...
搜索中...
未找到
SubsystemBlockEntities.cs
浏览该文件的文档.
1using Engine;
3
4namespace Game {
6 public Dictionary<Point3, ComponentBlockEntity> m_blockEntities = [];
7
8 public Dictionary<MovingBlock, ComponentBlockEntity> m_movingBlockEntities = [];
9
10 public ComponentBlockEntity GetBlockEntity(int x, int y, int z) {
11 m_blockEntities.TryGetValue(new Point3(x, y, z), out ComponentBlockEntity value);
12 return value;
13 }
14
16 m_blockEntities.TryGetValue(coordinates, out ComponentBlockEntity value);
17 return value;
18 }
19
21 m_movingBlockEntities.TryGetValue(movingBlock, out ComponentBlockEntity value);
22 return value;
23 }
24
25 public override void OnEntityAdded(Entity entity) {
26 ComponentBlockEntity componentBlockEntity = entity.FindComponent<ComponentBlockEntity>();
27 if (componentBlockEntity != null) {
28 if (!MovingBlock.IsNullOrStopped(componentBlockEntity.MovingBlock)) {
29 m_movingBlockEntities.Add(componentBlockEntity.MovingBlock, componentBlockEntity);
30 }
31 else if (componentBlockEntity.Coordinates.Y >= 0) {
32 m_blockEntities.Add(componentBlockEntity.Coordinates, componentBlockEntity);
33 }
34 }
35 }
36
37 public override void OnEntityRemoved(Entity entity) {
38 ComponentBlockEntity componentBlockEntity = entity.FindComponent<ComponentBlockEntity>();
39 if (componentBlockEntity != null) {
40 m_blockEntities.Remove(componentBlockEntity.Coordinates);
41 if (componentBlockEntity.MovingBlock != null) {
42 m_movingBlockEntities.Remove(componentBlockEntity.MovingBlock);
43 }
44 }
45 }
46 }
47}
static bool IsNullOrStopped(MovingBlock movingBlock)
Dictionary< MovingBlock, ComponentBlockEntity > m_movingBlockEntities
ComponentBlockEntity GetBlockEntity(Point3 coordinates)
ComponentBlockEntity GetBlockEntity(MovingBlock movingBlock)
override void OnEntityRemoved(Entity entity)
ComponentBlockEntity GetBlockEntity(int x, int y, int z)
Dictionary< Point3, ComponentBlockEntity > m_blockEntities
override void OnEntityAdded(Entity entity)
Component FindComponent(Type type, string name, bool throwOnError)