Survivalcraft API 1.8.2.3
v1.8.2.3
Survivalcraft 2.4
载入中...
搜索中...
未找到
ComponentLookAroundBehavior.cs
浏览该文件的文档.
1
using
GameEntitySystem
;
2
using
TemplatesDatabase
;
3
4
namespace
Game
{
5
public
class
ComponentLookAroundBehavior
:
ComponentBehavior
,
IUpdateable
{
6
public
SubsystemTime
m_subsystemTime
;
7
8
public
ComponentCreature
m_componentCreature
;
9
10
public
StateMachine
m_stateMachine
=
new
();
11
12
public
Random
m_random
=
new
();
13
14
public
float
m_lookAroundTime
;
15
16
public
float
m_importanceLevel
;
17
18
public
UpdateOrder
UpdateOrder
=>
UpdateOrder
.Default;
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) {
51
m_importanceLevel
= 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
}
Game.ComponentBehavior
定义
ComponentBehavior.cs:4
Game.ComponentBehavior.IsActive
virtual bool IsActive
定义
ComponentBehavior.cs:7
Game.ComponentCreature
定义
ComponentCreature.cs:7
Game.ComponentLookAroundBehavior
定义
ComponentLookAroundBehavior.cs:5
Game.ComponentLookAroundBehavior.UpdateOrder
UpdateOrder UpdateOrder
定义
ComponentLookAroundBehavior.cs:18
Game.ComponentLookAroundBehavior.Load
override void Load(ValuesDictionary valuesDictionary, IdToEntityMap idToEntityMap)
定义
ComponentLookAroundBehavior.cs:26
Game.ComponentLookAroundBehavior.m_lookAroundTime
float m_lookAroundTime
定义
ComponentLookAroundBehavior.cs:14
Game.ComponentLookAroundBehavior.ImportanceLevel
override float ImportanceLevel
定义
ComponentLookAroundBehavior.cs:20
Game.ComponentLookAroundBehavior.m_random
Random m_random
定义
ComponentLookAroundBehavior.cs:12
Game.ComponentLookAroundBehavior.m_subsystemTime
SubsystemTime m_subsystemTime
定义
ComponentLookAroundBehavior.cs:6
Game.ComponentLookAroundBehavior.m_importanceLevel
float m_importanceLevel
定义
ComponentLookAroundBehavior.cs:16
Game.ComponentLookAroundBehavior.m_componentCreature
ComponentCreature m_componentCreature
定义
ComponentLookAroundBehavior.cs:8
Game.ComponentLookAroundBehavior.Update
virtual void Update(float dt)
定义
ComponentLookAroundBehavior.cs:22
Game.ComponentLookAroundBehavior.m_stateMachine
StateMachine m_stateMachine
定义
ComponentLookAroundBehavior.cs:10
Game.Random
定义
Random.cs:5
Game.StateMachine
定义
StateMachine.cs:2
Game.SubsystemTime
定义
SubsystemTime.cs:6
GameEntitySystem.Component.ValuesDictionary
ValuesDictionary ValuesDictionary
定义
Component.cs:12
GameEntitySystem.Component.Project
Project Project
定义
Component.cs:16
GameEntitySystem.Component.Entity
Entity Entity
定义
Component.cs:14
GameEntitySystem.IdToEntityMap
定义
IdToEntityMap.cs:5
Game.IUpdateable
定义
IUpdateable.cs:2
GameEntitySystem
定义
Component.cs:6
Game
定义
ContentFileBridge.cs:4
TemplatesDatabase
定义
Database.cs:6
SurvivalcraftApi 1.8.2.3
Survivalcraft.Windows
Component
ComponentLookAroundBehavior.cs
制作者
1.16.1