3 using Microsoft.Xna.Framework;
4 using System.Collections.Generic;
10 const int MaxFakeFireSources = 10;
11 const float MinFakeFireSourceInterval = 30.0f, MaxFakeFireSourceInterval = 240.0f;
12 private float createFireSourceTimer;
13 private readonly List<DummyFireSource> fakeFireSources =
new List<DummyFireSource>();
23 const float MinSoundInterval = 60.0f, MaxSoundInterval = 240.0f;
25 private float soundTimer;
27 const float MinFloodInterval = 60.0f, MaxFloodInterval = 240.0f;
28 private float createFloodTimer;
29 private float currentFloodState;
30 private float currentFloodDuration;
32 private float fakeBrokenInterval = 30.0f;
33 private float fakeBrokenTimer = 0.0f;
35 private float invisibleCharacterInterval = 30.0f;
36 private float invisibleCharacterTimer = 0.0f;
40 get {
return currentFloodType; }
43 partial
void UpdateProjSpecific(
CharacterHealth characterHealth,
Limb targetLimb,
float deltaTime)
46 UpdateFloods(deltaTime);
47 UpdateSounds(characterHealth.
Character, deltaTime);
48 UpdateFires(characterHealth.
Character, deltaTime);
49 UpdateInvisibleCharacters(deltaTime);
50 UpdateFakeBroken(deltaTime);
53 private void UpdateSounds(Character character,
float deltaTime)
55 if (soundTimer < MathHelper.Lerp(MaxSoundInterval, MinSoundInterval,
Strength / 100.0f))
57 soundTimer += deltaTime;
61 float impactStrength = MathHelper.Lerp(0.1f, 1.0f,
Strength / 100.0f);
62 SoundPlayer.PlayDamageSound(
"StructureBlunt", Rand.Range(10.0f, 1000.0f), character.WorldPosition + Rand.Vector(500.0f));
63 GameMain.GameScreen.Cam.Shake = impactStrength * 10.0f;
64 GameMain.GameScreen.Cam.AngularVelocity = Rand.Range(-impactStrength, impactStrength);
68 private void UpdateFloods(
float deltaTime)
70 if (currentFloodDuration > 0.0f)
72 currentFloodDuration -= deltaTime;
73 switch (currentFloodType)
76 currentFloodState += deltaTime;
78 foreach (Hull hull
in Hull.HullList)
80 for (
int i = hull.FakeFireSources.Count - 1; i >= 0; i--)
82 hull.FakeFireSources[i].Extinguish(deltaTime, 50.0f);
84 hull.DrawSurface = hull.Rect.Y - hull.Rect.Height + MathHelper.Lerp(0.0f, 15.0f, currentFloodState / 10.0f);
88 currentFloodState += deltaTime;
90 foreach (Hull hull
in Hull.HullList)
92 for (
int i = hull.FakeFireSources.Count - 1; i >= 0; i--)
94 hull.FakeFireSources[i].Extinguish(deltaTime, 200.0f);
96 hull.DrawSurface = hull.Rect.Y - MathHelper.Lerp(hull.Rect.Height, 0.0f, currentFloodState / 10.0f);
101 foreach (Hull hull
in Hull.HullList)
103 hull.DrawSurface = hull.Rect.Y - hull.Rect.Height;
110 if (createFloodTimer < MathHelper.Lerp(MaxFloodInterval, MinFloodInterval,
Strength / 100.0f))
113 createFloodTimer += deltaTime;
118 if (Rand.Range(0.0f, 100.0f) <
Strength)
120 if (Rand.Range(0.0f, 1.0f) < 0.5f)
122 currentFloodType =
FloodType.HideFlooding;
130 currentFloodDuration = Rand.Range(20.0f, 100.0f);
132 createFloodTimer = 0.0f;
135 private void UpdateFires(Character character,
float deltaTime)
137 createFireSourceTimer += deltaTime;
138 fakeFireSources.RemoveAll(fs => fs.Removed);
139 if (fakeFireSources.Count < MaxFakeFireSources &&
140 character.Submarine !=
null &&
141 createFireSourceTimer > MathHelper.Lerp(MaxFakeFireSourceInterval, MinFakeFireSourceInterval,
Strength / 100.0f))
143 Hull fireHull = Hull.HullList.GetRandomUnsynced(h => h.Submarine == character.Submarine);
144 if (fireHull !=
null)
146 var fakeFire =
new DummyFireSource(Vector2.One * 500.0f,
new Vector2(Rand.Range(fireHull.WorldRect.X, fireHull.WorldRect.Right), fireHull.WorldPosition.Y + 1), fireHull, isNetworkMessage:
true)
148 CausedByPsychosis =
true,
149 DamagesItems =
false,
150 DamagesCharacters =
false
152 fakeFireSources.Add(fakeFire);
153 createFireSourceTimer = 0.0f;
158 private void UpdateInvisibleCharacters(
float deltaTime)
160 invisibleCharacterTimer -= deltaTime;
161 if (invisibleCharacterTimer > 0.0f) {
return; }
163 foreach (Character c
in Character.CharacterList)
165 if (c.IsDead || c ==
Character.Controlled) {
continue; }
166 if (c.WorldPosition.X < GameMain.GameScreen.Cam.WorldView.X || c.WorldPosition.X > GameMain.GameScreen.Cam.WorldView.Right) {
continue; }
167 if (c.WorldPosition.Y < GameMain.GameScreen.Cam.WorldView.Y - GameMain.GameScreen.Cam.WorldView.Height || c.WorldPosition.Y > GameMain.GameScreen.Cam.WorldView.Y) {
continue; }
168 if (Rand.Range(0.0f, 500.0f) <
Strength)
170 c.InvisibleTimer = 60.0f;
174 invisibleCharacterTimer = invisibleCharacterInterval;
178 private void UpdateFakeBroken(
float deltaTime)
180 fakeBrokenTimer -= deltaTime;
181 if (fakeBrokenTimer > 0.0f) {
return; }
183 foreach (Item item
in Item.ItemList)
185 var repairable = item.GetComponent<
Repairable>();
186 if (repairable ==
null) {
continue; }
187 if (ShouldFakeBrokenItem(item))
193 fakeBrokenTimer = fakeBrokenInterval;
196 private bool ShouldFakeBrokenItem(Item item)
198 return Rand.Range(0.0f, 1000.0f) <
Strength;
FloodType CurrentFloodType
readonly Character Character
static Character? Controlled