Survivalcraft API 1.8.2.3 v1.8.2.3
Survivalcraft 2.4
载入中...
搜索中...
未找到
ComponentStubbornSteedBehavior.cs
浏览该文件的文档.
3
4namespace Game {
7
9
11
13
15
17
19
20 public float m_importanceLevel;
21
22 public bool m_isSaddled;
23
24 public Random m_random = new();
25
27
29
30 public double m_stubbornEndTime;
31
33
34 public override float ImportanceLevel => m_importanceLevel;
35
36 public virtual void Update(float dt) {
37 m_stateMachine.Update();
38 if (!IsActive) {
39 m_stateMachine.TransitionTo("Inactive");
40 }
41 if (m_subsystemTime.PeriodicGameTimeEvent(1.0, m_periodicEventOffset)) {
42 m_importanceLevel = m_subsystemGameInfo.TotalElapsedGameTime < m_stubbornEndTime
43 && m_componentEatPickableBehavior.Satiation <= 0f
44 && m_componentMount.Rider != null
45 ? 210f
46 : 0f;
47 }
48 }
49
50 public override void Load(ValuesDictionary valuesDictionary, IdToEntityMap idToEntityMap) {
51 m_subsystemTime = Project.FindSubsystem<SubsystemTime>(true);
52 m_subsystemGameInfo = Project.FindSubsystem<SubsystemGameInfo>(true);
53 m_componentCreature = Entity.FindComponent<ComponentCreature>(true);
54 m_componentMount = Entity.FindComponent<ComponentMount>(true);
57 m_stubbornProbability = valuesDictionary.GetValue<float>("StubbornProbability");
58 m_stubbornEndTime = valuesDictionary.GetValue<double>("StubbornEndTime");
59 m_periodicEventOffset = m_random.Float(0f, 100f);
60 m_isSaddled = Entity.ValuesDictionary.DatabaseObject.Name.EndsWith("_Saddled");
61 m_stateMachine.AddState(
62 "Inactive",
63 null,
64 delegate {
65 if (m_subsystemTime.PeriodicGameTimeEvent(1.0, m_periodicEventOffset)
66 && m_componentMount.Rider != null
67 && m_random.Float(0f, 1f) < m_stubbornProbability
68 && (!m_isSaddled || m_componentEatPickableBehavior.Satiation <= 0f)) {
69 m_stubbornEndTime = m_subsystemGameInfo.TotalElapsedGameTime + m_random.Float(60f, 120f);
70 }
71 if (IsActive) {
72 m_stateMachine.TransitionTo("Stubborn");
73 }
74 },
75 null
76 );
77 m_stateMachine.AddState(
78 "Stubborn",
79 null,
80 delegate {
81 if (m_componentSteedBehavior.WasOrderIssued) {
82 m_componentCreature.ComponentCreatureModel.HeadShakeOrder = m_random.Float(0.6f, 1f);
83 m_componentCreature.ComponentCreatureSounds.PlayPainSound();
84 }
85 },
86 null
87 );
88 m_stateMachine.TransitionTo("Inactive");
89 }
90
91 public override void Save(ValuesDictionary valuesDictionary, EntityToIdMap entityToIdMap) {
92 valuesDictionary.SetValue("StubbornEndTime", m_stubbornEndTime);
93 }
94 }
95}
override void Save(ValuesDictionary valuesDictionary, EntityToIdMap entityToIdMap)
override void Load(ValuesDictionary valuesDictionary, IdToEntityMap idToEntityMap)
ValuesDictionary ValuesDictionary