More accurate and reliable submarine-level collisions, looping OnUse sounds bugfix, new music clips, item sprites removed from limbs when someone else loots the item, Camera.WorldView fix, checking vector.LengthSquared before normalizing to avoid creating a NaN vector
This commit is contained in:
@@ -312,8 +312,12 @@ namespace Subsurface
|
||||
//limb.body.ApplyTorque(limb.Mass * -20.0f * character.animController.Dir * dir);
|
||||
}
|
||||
|
||||
limb.body.ApplyLinearImpulse(limb.Mass * 10.0f *
|
||||
Vector2.Normalize(attackPosition - limb.SimPosition));
|
||||
Vector2 diff = attackPosition - limb.SimPosition;
|
||||
if (diff.LengthSquared() > 0.00001f)
|
||||
{
|
||||
limb.body.ApplyLinearImpulse(limb.Mass * 10.0f *
|
||||
Vector2.Normalize(attackPosition - limb.SimPosition));
|
||||
}
|
||||
|
||||
steeringManager.SteeringSeek(attackPosition + (limb.SimPosition-Position), 5.0f);
|
||||
|
||||
|
||||
@@ -64,6 +64,9 @@ namespace Subsurface
|
||||
private Vector2 DoSteeringSeek(Vector2 target, float speed = 1.0f)
|
||||
{
|
||||
Vector2 targetVel = target - host.Position;
|
||||
|
||||
if (targetVel.LengthSquared() < 0.00001f) return Vector2.Zero;
|
||||
|
||||
targetVel = Vector2.Normalize(targetVel) * speed;
|
||||
Vector2 newSteering = targetVel - host.Steering;
|
||||
|
||||
|
||||
@@ -862,7 +862,6 @@ namespace Subsurface
|
||||
{
|
||||
sounds[i].Play(1.0f, 2000.0f,
|
||||
AnimController.Limbs[0].body.FarseerBody);
|
||||
Debug.WriteLine("playing: " + sounds[i]);
|
||||
return;
|
||||
}
|
||||
n++;
|
||||
@@ -944,7 +943,7 @@ namespace Subsurface
|
||||
{
|
||||
joint.LimitEnabled = false;
|
||||
}
|
||||
Kill(true);
|
||||
Kill();
|
||||
}
|
||||
|
||||
private IEnumerable<object> DeathAnim(Camera cam)
|
||||
@@ -955,6 +954,7 @@ namespace Subsurface
|
||||
float timer = 0.0f;
|
||||
|
||||
Color prevAmbientLight = GameMain.LightManager.AmbientLight;
|
||||
Color darkLight = new Color(0.2f,0.2f,0.2f, 1.0f);
|
||||
|
||||
while (timer < dimDuration)
|
||||
{
|
||||
@@ -968,7 +968,7 @@ namespace Subsurface
|
||||
cam.OffsetAmount = 0.0f;
|
||||
}
|
||||
|
||||
GameMain.LightManager.AmbientLight = Color.Lerp(prevAmbientLight, Color.DarkGray, timer / dimDuration);
|
||||
GameMain.LightManager.AmbientLight = Color.Lerp(prevAmbientLight, darkLight, timer / dimDuration);
|
||||
}
|
||||
|
||||
yield return CoroutineStatus.Running;
|
||||
@@ -984,7 +984,7 @@ namespace Subsurface
|
||||
{
|
||||
lerpLightBack = Math.Min(lerpLightBack + 0.05f, 1.0f);
|
||||
|
||||
GameMain.LightManager.AmbientLight = Color.Lerp(Color.DarkGray, prevAmbientLight, lerpLightBack);
|
||||
GameMain.LightManager.AmbientLight = Color.Lerp(darkLight, prevAmbientLight, lerpLightBack);
|
||||
yield return CoroutineStatus.Running;
|
||||
}
|
||||
|
||||
@@ -996,17 +996,7 @@ namespace Subsurface
|
||||
if (isDead) return;
|
||||
|
||||
//if the game is run by a client, characters are only killed when the server says so
|
||||
if (GameMain.Client != null)
|
||||
{
|
||||
if (networkMessage)
|
||||
{
|
||||
new NetworkEvent(NetworkEventType.KillCharacter, ID, true);
|
||||
}
|
||||
else
|
||||
{
|
||||
return;
|
||||
}
|
||||
}
|
||||
if (GameMain.Client != null && GameMain.Server==null && !networkMessage) return;
|
||||
|
||||
CoroutineManager.StartCoroutine(DeathAnim(GameMain.GameScreen.Cam));
|
||||
|
||||
@@ -1052,7 +1042,6 @@ namespace Subsurface
|
||||
if (type == NetworkEventType.PickItem)
|
||||
{
|
||||
message.Write((int)data);
|
||||
Debug.WriteLine("pickitem");
|
||||
return;
|
||||
}
|
||||
else if (type == NetworkEventType.KillCharacter)
|
||||
@@ -1140,7 +1129,6 @@ namespace Subsurface
|
||||
Item item = FindEntityByID(itemId) as Item;
|
||||
if (item != null)
|
||||
{
|
||||
Debug.WriteLine("pickitem "+itemId );
|
||||
item.Pick(this);
|
||||
}
|
||||
|
||||
@@ -1151,7 +1139,7 @@ namespace Subsurface
|
||||
Kill(true);
|
||||
if (GameMain.NetworkMember != null && controlled == this)
|
||||
{
|
||||
GameMain.Client.AddChatMessage("YOU HAVE DIED. Your chat messages will only be visible to other dead players.", ChatMessageType.Dead);
|
||||
GameMain.NetworkMember.AddChatMessage("YOU HAVE DIED. Your chat messages will only be visible to other dead players.", ChatMessageType.Dead);
|
||||
GameMain.LightManager.LosEnabled = false;
|
||||
}
|
||||
return;
|
||||
|
||||
@@ -132,7 +132,7 @@ namespace Subsurface
|
||||
void UpdateSineAnim(float deltaTime)
|
||||
{
|
||||
movement = MathUtils.SmoothStep(movement, TargetMovement*swimSpeed, 1.0f);
|
||||
if (movement == Vector2.Zero) return;
|
||||
if (movement.LengthSquared() < 0.00001f) return;
|
||||
|
||||
if (!inWater) movement.Y = Math.Min(0.0f, movement.Y);
|
||||
|
||||
|
||||
@@ -401,14 +401,14 @@ namespace Subsurface
|
||||
}
|
||||
}
|
||||
|
||||
for (int i = 0; i < 2; i++)
|
||||
{
|
||||
Limb leg = (i == 0) ? rightFoot : leftFoot;
|
||||
//for (int i = 0; i < 2; i++)
|
||||
//{
|
||||
// Limb leg = (i == 0) ? rightLeg : leftLeg;
|
||||
|
||||
if (leg.SimPosition.Y < torso.SimPosition.Y) continue;
|
||||
// if (leg.SimPosition.Y < waist.SimPosition.Y) continue;
|
||||
|
||||
leg.body.ApplyTorque(-Dir * leg.Mass * 20.0f);
|
||||
}
|
||||
// //leg.body.ApplyTorque(Dir * leg.Mass * 50.0f);
|
||||
//}
|
||||
|
||||
}
|
||||
|
||||
@@ -416,27 +416,17 @@ namespace Subsurface
|
||||
{
|
||||
movement = MathUtils.SmoothStep(movement, TargetMovement, movementLerp);
|
||||
|
||||
if (inWater && movement != Vector2.Zero)
|
||||
if (inWater && movement.LengthSquared()>0.00001f)
|
||||
{
|
||||
movement = Vector2.Normalize(movement);
|
||||
}
|
||||
|
||||
if (!MathUtils.IsValid(movement))
|
||||
{
|
||||
int a = 1;
|
||||
}
|
||||
|
||||
|
||||
RefLimb.pullJoint.Enabled = true;
|
||||
RefLimb.pullJoint.WorldAnchorB =
|
||||
RefLimb.SimPosition + movement*0.15f;
|
||||
|
||||
RefLimb.body.SmoothRotate(0.0f);
|
||||
|
||||
if (!MathUtils.IsValid(RefLimb.body.SimPosition))
|
||||
{
|
||||
int a = 1;
|
||||
}
|
||||
|
||||
foreach (Limb l in Limbs)
|
||||
{
|
||||
if (l==RefLimb) continue;
|
||||
|
||||
Reference in New Issue
Block a user