Survivalcraft API 1.8.2.3 v1.8.2.3
Survivalcraft 2.4
载入中...
搜索中...
未找到
ComponentBoat.cs
浏览该文件的文档.
1using Engine;
4
5namespace Game {
8
10
12
14
16
17 public float m_turnSpeed;
18
19 public float MoveOrder { get; set; }
20
21 public float TurnOrder { get; set; }
22
23 public float Health { get; set; }
24
26
27 public void Injure(float amount, ComponentCreature attacker, bool ignoreInvulnerability) {
28 if (amount > 0f) {
29 Health = Math.Max(Health - amount, 0f);
30 }
31 }
32
33 public virtual void Update(float dt) {
34 if (m_componentDamage.Hitpoints < 0.33f) {
35 m_componentBody.Density = 1.15f;
36 if (m_componentDamage.Hitpoints - m_componentDamage.HitpointsChange >= 0.33f
37 && m_componentBody.ImmersionFactor > 0f) {
38 m_subsystemAudio.PlaySound("Audio/Sinking", 1f, 0f, m_componentBody.Position, 4f, true);
39 }
40 }
41 else if (m_componentDamage.Hitpoints < 0.66f) {
42 m_componentBody.Density = 0.7f;
43 if (m_componentDamage.Hitpoints - m_componentDamage.HitpointsChange >= 0.66f
44 && m_componentBody.ImmersionFactor > 0f) {
45 m_subsystemAudio.PlaySound("Audio/Sinking", 1f, 0f, m_componentBody.Position, 4f, true);
46 }
47 }
48 bool num = m_componentBody.ImmersionFactor > 0.95f;
49 bool num2 = !num
50 && m_componentBody.ImmersionFactor > 0.01f
51 && !m_componentBody.StandingOnValue.HasValue
52 && m_componentBody.StandingOnBody == null;
53 m_turnSpeed += 2.5f * m_subsystemTime.GameTimeDelta * (1f * TurnOrder - m_turnSpeed);
54 Quaternion rotation = m_componentBody.Rotation;
55 float num3 = MathF.Atan2(
56 2f * rotation.Y * rotation.W - 2f * rotation.X * rotation.Z,
57 1f - 2f * rotation.Y * rotation.Y - 2f * rotation.Z * rotation.Z
58 );
59 if (num2) {
60 num3 -= m_turnSpeed * dt;
61 }
62 m_componentBody.Rotation = Quaternion.CreateFromAxisAngle(Vector3.UnitY, num3);
63 if (num2 && MoveOrder != 0f) {
64 m_componentBody.Velocity += dt * 3f * MoveOrder * m_componentBody.Matrix.Forward;
65 }
66 if (num) {
67 m_componentDamage.Damage(0.005f * dt);
68 if (m_componentMount.Rider != null) {
69 m_componentMount.Rider.StartDismounting();
70 }
71 }
72 MoveOrder = 0f;
73 TurnOrder = 0f;
74 }
75
76 public override void Load(ValuesDictionary valuesDictionary, IdToEntityMap idToEntityMap) {
77 m_subsystemTime = Project.FindSubsystem<SubsystemTime>(true);
78 m_subsystemAudio = Project.FindSubsystem<SubsystemAudio>(true);
79 m_componentMount = Entity.FindComponent<ComponentMount>(true);
80 m_componentBody = Entity.FindComponent<ComponentBody>(true);
81 m_componentDamage = Entity.FindComponent<ComponentDamage>(true);
82 }
83 }
84}
ComponentMount m_componentMount
override void Load(ValuesDictionary valuesDictionary, IdToEntityMap idToEntityMap)
virtual void Update(float dt)
SubsystemTime m_subsystemTime
SubsystemAudio m_subsystemAudio
void Injure(float amount, ComponentCreature attacker, bool ignoreInvulnerability)
ComponentDamage m_componentDamage
ComponentBody m_componentBody
ValuesDictionary ValuesDictionary
static Quaternion CreateFromAxisAngle(Vector3 axis, float angle)
static readonly Vector3 UnitY