Survivalcraft API 1.8.2.3 v1.8.2.3
Survivalcraft 2.4
载入中...
搜索中...
未找到
ComponentUdder.cs
浏览该文件的文档.
3
4namespace Game {
5 public class ComponentUdder : Component {
7
9
11
12 public double m_lastMilkingTime;
13
14 public bool HasMilk {
15 get {
16 if (!(m_lastMilkingTime < 0.0)) {
17 return m_subsystemGameInfo.TotalElapsedGameTime - m_lastMilkingTime >= m_milkRegenerationTime;
18 }
19 return true;
20 }
21 }
22
23 public virtual bool Milk(ComponentMiner milker) {
24 if (milker != null) {
25 Entity.FindComponent<ComponentHerdBehavior>()?.CallNearbyCreaturesHelp(milker.ComponentCreature, 20f, 20f, true);
26 }
27 if (HasMilk) {
28 m_componentCreature.ComponentCreatureSounds.PlayIdleSound(false);
29 m_lastMilkingTime = m_subsystemGameInfo.TotalElapsedGameTime;
30 return true;
31 }
32 m_componentCreature.ComponentCreatureSounds.PlayPainSound();
33 return false;
34 }
35
36 public override void Load(ValuesDictionary valuesDictionary, IdToEntityMap idToEntityMap) {
37 m_subsystemGameInfo = Project.FindSubsystem<SubsystemGameInfo>(true);
38 m_componentCreature = Entity.FindComponent<ComponentCreature>(true);
39 m_milkRegenerationTime = valuesDictionary.GetValue<float>("MilkRegenerationTime");
40 m_lastMilkingTime = valuesDictionary.GetValue<double>("LastMilkingTime");
41 }
42
43 public override void Save(ValuesDictionary valuesDictionary, EntityToIdMap entityToIdMap) {
44 valuesDictionary.SetValue("LastMilkingTime", m_lastMilkingTime);
45 }
46 }
47}
ComponentCreature ComponentCreature
SubsystemGameInfo m_subsystemGameInfo
override void Load(ValuesDictionary valuesDictionary, IdToEntityMap idToEntityMap)
override void Save(ValuesDictionary valuesDictionary, EntityToIdMap entityToIdMap)
virtual bool Milk(ComponentMiner milker)
ComponentCreature m_componentCreature
ValuesDictionary ValuesDictionary