Survivalcraft API 1.8.2.3 v1.8.2.3
Survivalcraft 2.4
载入中...
搜索中...
未找到
ComponentLookAroundBehavior.cs
浏览该文件的文档.
3
4namespace Game {
7
9
11
12 public Random m_random = new();
13
14 public float m_lookAroundTime;
15
16 public float m_importanceLevel;
17
19
20 public override float ImportanceLevel => m_importanceLevel;
21
22 public virtual void Update(float dt) {
23 m_stateMachine.Update();
24 }
25
26 public override void Load(ValuesDictionary valuesDictionary, IdToEntityMap idToEntityMap) {
27 m_subsystemTime = Project.FindSubsystem<SubsystemTime>(true);
28 m_componentCreature = Entity.FindComponent<ComponentCreature>(true);
29 m_stateMachine.AddState(
30 "Inactive",
31 delegate { m_importanceLevel = m_random.Float(0f, 1f); },
32 delegate {
33 if (m_componentCreature.ComponentBody.StandingOnValue.HasValue
34 && m_random.Float(0f, 1f) < 0.05f * m_subsystemTime.GameTimeDelta) {
35 m_importanceLevel = m_random.Float(1f, 5f);
36 }
37 if (IsActive) {
38 m_stateMachine.TransitionTo("LookAround");
39 }
40 },
41 null
42 );
43 m_stateMachine.AddState(
44 "LookAround",
45 delegate { m_lookAroundTime = m_random.Float(8f, 15f); },
46 delegate {
47 if (!IsActive) {
48 m_stateMachine.TransitionTo("Inactive");
49 }
50 else if (m_lookAroundTime <= 0f) {
52 }
53 else if (m_random.Float(0f, 1f) < 0.1f * m_subsystemTime.GameTimeDelta) {
54 m_componentCreature.ComponentCreatureSounds.PlayIdleSound(false);
55 }
56 m_componentCreature.ComponentCreatureModel.LookRandomOrder = true;
57 m_lookAroundTime -= m_subsystemTime.GameTimeDelta;
58 },
59 null
60 );
61 m_stateMachine.TransitionTo("Inactive");
62 }
63 }
64}
override void Load(ValuesDictionary valuesDictionary, IdToEntityMap idToEntityMap)
ValuesDictionary ValuesDictionary