Survivalcraft API 1.8.2.3 v1.8.2.3
Survivalcraft 2.4
载入中...
搜索中...
未找到
ComponentBlockEntity.cs
浏览该文件的文档.
1using Engine;
4
5namespace Game {
8
10
12 public MovingBlock MovingBlock { get; set; }
13
15
16 public int m_blockValue;
17
18 public virtual int BlockValue {
19 get {
20 if (!MovingBlock.IsNullOrStopped(MovingBlock)) {
22 return m_blockValue;
23 }
24 TerrainChunk chunkAtCell = m_subsystemTerrain.Terrain.GetChunkAtCell(Coordinates.X, Coordinates.Z);
25 if (chunkAtCell != null
26 && chunkAtCell.State == TerrainChunkState.Valid) {
27 int value = m_subsystemTerrain.Terrain.GetCellValue(Coordinates.X, Coordinates.Y, Coordinates.Z);
28 if (value != 0) {
29 m_blockValue = value;
30 }
31 }
32 return m_blockValue;
33 }
34 set {
35 m_blockValue = value;
36 if (!MovingBlock.IsNullOrStopped(MovingBlock)) {
37 MovingBlock.Value = value;
38 return;
39 }
40 TerrainChunk chunkAtCell = m_subsystemTerrain.Terrain.GetChunkAtCell(Coordinates.X, Coordinates.Z);
41 if (chunkAtCell != null
42 && chunkAtCell.State == TerrainChunkState.Valid) {
43 m_subsystemTerrain.ChangeCell(Coordinates.X, Coordinates.Y, Coordinates.Z, value);
44 }
45 }
46 }
47
48 public virtual Vector3 Position {
49 get {
50 if (!MovingBlock.IsNullOrStopped(MovingBlock)) {
51 return MovingBlock.Position;
52 }
53 return new Vector3(Coordinates);
54 }
55 }
56
57 public Point3 Coordinates { get; set; }
58
59 public virtual void GatherPickable(WorldItem worldItem) {
60 if (m_inventoryToGatherPickable == null) {
61 return;
62 }
63 Pickable pickable = worldItem as Pickable;
64 int num = pickable?.Count ?? 1;
66 if (num2 < num) {
67 m_subsystemAudio.PlaySound("Audio/PickableCollected", 1f, 0f, worldItem.Position, 3f, true);
68 }
69 if (num2 <= 0) {
70 worldItem.ToRemove = true;
71 }
72 else if (pickable != null) {
73 pickable.Count = num2;
74 }
75 }
76
77 public override void Load(ValuesDictionary valuesDictionary, IdToEntityMap idToEntityMap) {
79 m_subsystemTerrain = Project.FindSubsystem<SubsystemTerrain>(true);
80 m_subsystemAudio = Project.FindSubsystem<SubsystemAudio>(true);
81 Coordinates = valuesDictionary.GetValue<Point3>("Coordinates");
82 MovingBlock = MovingBlock.LoadFromValuesDictionary(Project, valuesDictionary);
83 }
84
85 public override void Save(ValuesDictionary valuesDictionary, EntityToIdMap entityToIdMap) {
86 valuesDictionary.SetValue("Coordinates", Coordinates);
87 MovingBlock?.SetValuesDicionary(valuesDictionary);
88 }
89 }
90}
Engine.Vector3 Vector3
override void Load(ValuesDictionary valuesDictionary, IdToEntityMap idToEntityMap)
virtual void GatherPickable(WorldItem worldItem)
SubsystemMovingBlocks m_subsystemMovingBlocks
override void Save(ValuesDictionary valuesDictionary, EntityToIdMap entityToIdMap)
static int AcquireItems(IInventory inventory, int value, int count)
TerrainChunkState State
ValuesDictionary ValuesDictionary