2 using Microsoft.Xna.Framework;
4 using System.Collections.Generic;
10 partial class SubmarineBody
13 partial
void HandleLevelCollisionProjSpecific(Impact impact)
15 float wallImpact = Vector2.Dot(impact.Velocity, -impact.Normal);
16 int particleAmount = (int)Math.Min(wallImpact, 10);
18 const float BurstParticleThreshold = 5.0f;
20 float velocityFactor = MathHelper.Clamp(wallImpact / 10.0f, 0.0f, 1.0f);
21 for (
int i = 0; i < particleAmount * 5; i++)
23 GameMain.ParticleManager.CreateParticle(
"iceshards",
24 ConvertUnits.ToDisplayUnits(impact.ImpactPos) + Rand.Vector(Rand.Range(1.0f, 50.0f)),
25 (Rand.Vector(0.9f) + impact.Normal) * Rand.Range(100.0f, 10000) * velocityFactor);
27 for (
int i = 0; i < particleAmount; i++)
29 float particleVelocityMultiplier = Rand.Range(0.0f, 1);
30 var p = GameMain.ParticleManager.CreateParticle(
"iceexplosion",
31 ConvertUnits.ToDisplayUnits(impact.ImpactPos) + Rand.Vector(Rand.Range(1.0f, 50.0f)),
32 (Rand.Vector(0.5f) + impact.Normal) * particleVelocityMultiplier * 500 * velocityFactor);
35 p.VelocityChangeMultiplier = particleVelocityMultiplier * Rand.Range(0.0f, 1.0f);
36 p.Size *= Math.Max(particleVelocityMultiplier, 0);
39 if (wallImpact > BurstParticleThreshold)
41 for (
int i = 0; i < particleAmount; i++)
43 GameMain.ParticleManager.CreateParticle(
"iceburst",
44 ConvertUnits.ToDisplayUnits(impact.ImpactPos) + Rand.Vector(Rand.Range(1.0f, 50.0f)),
45 angle: MathUtils.VectorToAngle(impact.Normal.FlipY() + Rand.Vector(0.25f)), speed: 0.0f);
50 partial
void ClientUpdatePosition(
float deltaTime)
52 if (GameMain.Client ==
null) {
return; }
54 Body.CorrectPosition(positionBuffer, out Vector2 newPosition, out Vector2 newVelocity, out _, out _);
55 Vector2 moveAmount = ConvertUnits.ToDisplayUnits(newPosition -
Body.
SimPosition);
56 newVelocity = newVelocity.ClampLength(100.0f);
57 if (!MathUtils.IsValid(newVelocity) || moveAmount.LengthSquared() < 0.0001f)
63 foreach (
Submarine dockedSub
in subsToMove)
65 if (dockedSub == submarine) {
continue; }
67 dockedSub.SubBody.positionBuffer.Clear();
77 closestSub =
Character.Controlled.Submarine;
80 bool displace = moveAmount.LengthSquared() > 100.0f * 100.0f;
83 sub.PhysicsBody.LinearVelocity = newVelocity;
87 sub.PhysicsBody.SetTransform(sub.PhysicsBody.SimPosition + ConvertUnits.ToSimUnits(moveAmount), 0.0f);
88 sub.SubBody.DisplaceCharacters(moveAmount);
92 sub.PhysicsBody.SetTransformIgnoreContacts(sub.PhysicsBody.SimPosition + ConvertUnits.ToSimUnits(moveAmount), 0.0f);
95 if (closestSub !=
null && subsToMove.Contains(closestSub))
97 GameMain.GameScreen.Cam.Position += moveAmount;
98 if (GameMain.GameScreen.Cam.TargetPos != Vector2.Zero) { GameMain.GameScreen.Cam.TargetPos += moveAmount; }
100 if (
Character.Controlled !=
null) {
Character.Controlled.CursorPosition += moveAmount; }
104 private void PlayDamageSounds(Dictionary<Structure, float> damagedStructures, Vector2 impactSimPos,
float impact,
string soundTag)
106 if (impact < MinCollisionImpact) {
return; }
109 float maxDamage = 0.0f;
111 foreach (KeyValuePair<Structure, float> structureDamage
in damagedStructures)
113 if (maxDamageStructure ==
null || structureDamage.Value > maxDamage)
115 maxDamage = structureDamage.Value;
116 maxDamageStructure = structureDamage.Key;
120 if (maxDamageStructure !=
null)
122 PlayDamageSound(impactSimPos, impact, soundTag, maxDamageStructure);
126 private void PlayDamageSound(Vector2 impactSimPos,
float impact,
string soundTag, Structure hitStructure =
null)
128 if (impact < MinCollisionImpact) {
return; }
130 SoundPlayer.PlayDamageSound(
133 ConvertUnits.ToDisplayUnits(impactSimPos),
134 MathHelper.Lerp(2000.0f, 10000.0f, (impact - MinCollisionImpact) / 2.0f),
readonly PhysicsBody Body
IEnumerable< Submarine > GetConnectedSubs()
Returns a list of all submarines that are connected to this one via docking ports,...
static Submarine FindClosest(Vector2 worldPosition, bool ignoreOutposts=false, bool ignoreOutsideLevel=true, bool ignoreRespawnShuttle=false, CharacterTeamType? teamType=null)
If has value, the sub must match the team type.