Survivalcraft API 1.8.2.3 v1.8.2.3
Survivalcraft 2.4
载入中...
搜索中...
未找到
ComponentHowlBehavior.cs
浏览该文件的文档.
1using Engine;
4
5namespace Game {
8
10
12
14
16
18
19 public float m_importanceLevel;
20
21 public string m_howlSoundName;
22
23 public float m_howlTime;
24
25 public float m_howlDuration;
26
27 public Random m_random = new();
28
30
31 public override float ImportanceLevel => m_importanceLevel;
32
33 public virtual void Update(float dt) {
34 m_stateMachine.Update();
35 }
36
37 public override void Load(ValuesDictionary valuesDictionary, IdToEntityMap idToEntityMap) {
38 m_subsystemSky = Project.FindSubsystem<SubsystemSky>(true);
39 m_subsystemTime = Project.FindSubsystem<SubsystemTime>(true);
40 m_subsystemAudio = Project.FindSubsystem<SubsystemAudio>(true);
41 m_componentCreature = Entity.FindComponent<ComponentCreature>(true);
43 m_howlSoundName = valuesDictionary.GetValue<string>("HowlSoundName");
44 m_stateMachine.AddState(
45 "Inactive",
46 delegate { m_importanceLevel = 0f; },
47 delegate {
48 if (IsActive) {
49 m_stateMachine.TransitionTo("Howl");
50 }
51 if (m_subsystemSky.SkyLightIntensity < 0.1f) {
52 if (m_random.Float(0f, 1f) < 0.015f * m_subsystemTime.GameTimeDelta) {
53 m_importanceLevel = m_random.Float(1f, 3f);
54 }
55 }
56 else {
58 }
59 },
60 null
61 );
62 m_stateMachine.AddState(
63 "Howl",
64 delegate {
65 m_howlTime = 0f;
66 m_howlDuration = m_random.Float(5f, 6f);
69 },
70 delegate {
71 if (!IsActive) {
72 m_stateMachine.TransitionTo("Inactive");
73 }
74 m_componentCreature.ComponentLocomotion.LookOrder = new Vector2(m_componentCreature.ComponentLocomotion.LookOrder.X, 2f);
75 float num = m_howlTime + m_subsystemTime.GameTimeDelta;
76 if (m_howlTime <= 0.5f
77 && num > 0.5f) {
78 m_subsystemAudio.PlayRandomSound(
80 1f,
81 m_random.Float(-0.1f, 0.1f),
82 m_componentCreature.ComponentBody.Position,
83 10f,
84 true
85 );
86 }
87 m_howlTime = num;
90 }
91 },
92 null
93 );
94 m_stateMachine.TransitionTo("Inactive");
95 }
96 }
97}
override void Load(ValuesDictionary valuesDictionary, IdToEntityMap idToEntityMap)
ValuesDictionary ValuesDictionary