Survivalcraft API 1.8.2.3 v1.8.2.3
Survivalcraft 2.4
载入中...
搜索中...
未找到
ComponentPickableGathererPlayer.cs
浏览该文件的文档.
3
4namespace Game {
7
9
11
13
14 public override bool CanGatherPickable(Pickable pickable) {
15 if (m_componentHealth.Health <= 0) {
16 return false;
17 }
18 if (pickable.FlyToPosition.HasValue) {
19 return false;
20 }
21 if (pickable.ToRemove) {
22 return false;
23 }
24 double pickableTimeExisted = m_subsystemGameInfo.TotalElapsedGameTime - pickable.CreationTime;
25 if (pickableTimeExisted < pickable.TimeWaitToAutoPick) {
26 return false;
27 }
28 if (pickable.Value == m_experienceBlockIndex) {
29 return true;
30 }
32 }
33
34 public override void GatherPickable(Pickable pickable) {
35 SubsystemBlockBehavior[] blockBehaviors = m_subsystemBlockBehaviors.GetBlockBehaviors(Terrain.ExtractContents(pickable.Value));
36 for (int i = 0; i < blockBehaviors.Length; i++) {
37 if (pickable.ToRemove) {
38 break;
39 }
40 blockBehaviors[i].OnPickableGathered(pickable, this, pickable.Position - Position);
41 }
42 if (!pickable.ToRemove) {
43 pickable.Count = ComponentInventoryBase.AcquireItems(m_inventory, pickable.Value, pickable.Count);
44 if (pickable.Count == 0) {
45 pickable.ToRemove = true;
46 m_subsystemAudio.PlaySound("Audio/PickableCollected", 0.7f, -0.4f, Position, 2f, false);
47 }
48 }
49 }
50
51 public override void Update(float dt) {
52 if (m_inventory == null) {
53 m_inventory = m_componentPlayer.ComponentMiner.Inventory;
54 }
55 base.Update(dt);
56 }
57
58 public override void Load(ValuesDictionary valuesDictionary, IdToEntityMap idToEntityMap) {
59 base.Load(valuesDictionary, idToEntityMap);
60 m_componentPlayer = Entity.FindComponent<ComponentPlayer>(true);
62 m_componentHealth = Entity.FindComponent<ComponentHealth>(true);
63 }
64 }
65}
static int GetBlockIndex(string BlockName, bool throwIfNotFound=false)
通过方块名称来获取方块的Index
static int FindAcquireSlotForItem(IInventory inventory, int value)
static int AcquireItems(IInventory inventory, int value, int count)
override void Load(ValuesDictionary valuesDictionary, IdToEntityMap idToEntityMap)
Vector3? FlyToPosition
virtual double TimeWaitToAutoPick
virtual void OnPickableGathered(Pickable pickable, ComponentPickableGatherer target, Vector3 distanceToTarget)
static int ExtractContents(int value)
ValuesDictionary ValuesDictionary