Merge branch 'master' into new-netcode
Conflicts: Subsurface/Properties/AssemblyInfo.cs Subsurface/Source/Characters/Animation/HumanoidAnimController.cs Subsurface/Source/Characters/Character.cs Subsurface/Source/Items/Components/Door.cs Subsurface/Source/Items/Components/Power/PowerContainer.cs Subsurface/Source/Items/Components/Signal/Wire.cs Subsurface/Source/Items/Item.cs Subsurface/Source/Networking/ChatMessage.cs Subsurface/Source/Networking/GameClient.cs Subsurface/Source/Networking/GameServer.cs Subsurface/Source/Networking/GameServerLogin.cs Subsurface/Source/Networking/GameServerSettings.cs Subsurface/Source/Networking/NetworkMember.cs
This commit is contained in:
@@ -35,7 +35,7 @@ namespace Barotrauma
|
||||
{
|
||||
l.body.PhysEnabled = !frozen;
|
||||
}
|
||||
collider.PhysEnabled = !frozen;
|
||||
Collider.PhysEnabled = !frozen;
|
||||
}
|
||||
}
|
||||
|
||||
@@ -70,6 +70,8 @@ namespace Barotrauma
|
||||
protected bool inWater, headInWater;
|
||||
public bool onGround;
|
||||
private bool ignorePlatforms;
|
||||
|
||||
protected float colliderHeightFromFloor;
|
||||
|
||||
protected Structure stairs;
|
||||
|
||||
@@ -77,13 +79,46 @@ namespace Barotrauma
|
||||
|
||||
public Direction TargetDir;
|
||||
|
||||
protected PhysicsBody collider;
|
||||
|
||||
protected List<PhysicsBody> collider;
|
||||
protected int colliderIndex = 0;
|
||||
|
||||
public PhysicsBody Collider
|
||||
{
|
||||
get
|
||||
{
|
||||
return collider;
|
||||
return collider[colliderIndex];
|
||||
}
|
||||
}
|
||||
|
||||
public int ColliderIndex
|
||||
{
|
||||
get
|
||||
{
|
||||
return colliderIndex;
|
||||
}
|
||||
set
|
||||
{
|
||||
if (value == colliderIndex) return;
|
||||
if (value >= collider.Count) return;
|
||||
if (collider[colliderIndex].height<collider[value].height)
|
||||
{
|
||||
Vector2 pos1 = collider[colliderIndex].SimPosition;
|
||||
pos1.Y -= collider[colliderIndex].height * colliderHeightFromFloor;
|
||||
Vector2 pos2 = pos1;
|
||||
pos2.Y += collider[value].height * 1.1f;
|
||||
if (GameMain.World.RayCast(pos1, pos2).Any(f => f.CollisionCategories.HasFlag(Physics.CollisionWall))) return;
|
||||
}
|
||||
collider[value].LinearVelocity = collider[colliderIndex].LinearVelocity;
|
||||
collider[value].AngularVelocity = collider[colliderIndex].AngularVelocity;
|
||||
Vector2 pos = collider[colliderIndex].SimPosition;
|
||||
pos.Y -= collider[colliderIndex].height * 0.5f;
|
||||
pos.Y += collider[value].height * 0.5f;
|
||||
collider[value].SetTransform(pos, collider[colliderIndex].Rotation);
|
||||
collider[value].PhysEnabled = !frozen;
|
||||
collider[value].Enabled = !simplePhysicsEnabled;
|
||||
collider[value].Submarine = collider[colliderIndex].Submarine;
|
||||
collider[colliderIndex].PhysEnabled = false;
|
||||
colliderIndex = value;
|
||||
}
|
||||
}
|
||||
|
||||
@@ -109,8 +144,8 @@ namespace Barotrauma
|
||||
get
|
||||
{
|
||||
return character.Submarine == null ?
|
||||
ConvertUnits.ToDisplayUnits(collider.SimPosition) :
|
||||
ConvertUnits.ToDisplayUnits(collider.SimPosition) + character.Submarine.Position;
|
||||
ConvertUnits.ToDisplayUnits(Collider.SimPosition) :
|
||||
ConvertUnits.ToDisplayUnits(Collider.SimPosition) + character.Submarine.Position;
|
||||
}
|
||||
}
|
||||
|
||||
@@ -137,7 +172,7 @@ namespace Barotrauma
|
||||
{
|
||||
foreach (Limb limb in Limbs)
|
||||
{
|
||||
limb.body.SetTransform(collider.SimPosition, collider.Rotation);
|
||||
limb.body.SetTransform(Collider.SimPosition, Collider.Rotation);
|
||||
}
|
||||
}
|
||||
}
|
||||
@@ -207,7 +242,7 @@ namespace Barotrauma
|
||||
{
|
||||
limb.body.Submarine = currSubmarine;
|
||||
}
|
||||
collider.Submarine = currSubmarine;
|
||||
Collider.Submarine = currSubmarine;
|
||||
}
|
||||
}
|
||||
|
||||
@@ -266,7 +301,12 @@ namespace Barotrauma
|
||||
ImpactTolerance = ToolBox.GetAttributeFloat(element, "impacttolerance", 50.0f);
|
||||
|
||||
CanEnterSubmarine = ToolBox.GetAttributeBool(element, "canentersubmarine", true);
|
||||
|
||||
|
||||
colliderHeightFromFloor = ToolBox.GetAttributeFloat(element, "colliderheightfromfloor", 45.0f);
|
||||
colliderHeightFromFloor = ConvertUnits.ToSimUnits(colliderHeightFromFloor);
|
||||
|
||||
collider = new List<PhysicsBody>();
|
||||
|
||||
foreach (XElement subElement in element.Elements())
|
||||
{
|
||||
switch (subElement.Name.ToString())
|
||||
@@ -287,24 +327,31 @@ namespace Barotrauma
|
||||
|
||||
break;
|
||||
case "collider":
|
||||
collider = new PhysicsBody(subElement, scale);
|
||||
collider.FarseerBody.FixedRotation = true;
|
||||
collider.Add(new PhysicsBody(subElement, scale));
|
||||
|
||||
collider[collider.Count - 1].FarseerBody.Friction = 0.05f;
|
||||
collider[collider.Count - 1].FarseerBody.Restitution = 0.05f;
|
||||
collider[collider.Count - 1].FarseerBody.FixedRotation = true;
|
||||
collider[collider.Count - 1].CollisionCategories = Physics.CollisionCharacter;
|
||||
collider[collider.Count - 1].FarseerBody.AngularDamping = 5.0f;
|
||||
collider[collider.Count - 1].FarseerBody.FixedRotation = true;
|
||||
collider[collider.Count - 1].FarseerBody.OnCollision += OnLimbCollision;
|
||||
if (collider.Count > 1) collider[collider.Count - 1].PhysEnabled = false;
|
||||
break;
|
||||
}
|
||||
}
|
||||
|
||||
if (collider == null)
|
||||
if (collider[0] == null)
|
||||
{
|
||||
DebugConsole.ThrowError("No collider configured for ''"+character.Name+"''!");
|
||||
collider = new PhysicsBody(0.0f, 0.0f, 0.5f, 5.0f);
|
||||
collider.BodyType = BodyType.Dynamic;
|
||||
DebugConsole.ThrowError("No collider configured for \""+character.Name+"\"!");
|
||||
collider[0] = new PhysicsBody(0.0f, 0.0f, 0.5f, 5.0f);
|
||||
collider[0].BodyType = BodyType.Dynamic;
|
||||
collider[0].CollisionCategories = Physics.CollisionCharacter;
|
||||
collider[0].FarseerBody.AngularDamping = 5.0f;
|
||||
collider[0].FarseerBody.FixedRotation = true;
|
||||
collider[0].FarseerBody.OnCollision += OnLimbCollision;
|
||||
}
|
||||
|
||||
collider.CollisionCategories = Physics.CollisionCharacter;
|
||||
collider.FarseerBody.AngularDamping = 5.0f;
|
||||
collider.FarseerBody.FixedRotation = true;
|
||||
collider.FarseerBody.OnCollision += OnLimbCollision;
|
||||
|
||||
UpdateCollisionCategories();
|
||||
|
||||
foreach (var joint in limbJoints)
|
||||
@@ -431,7 +478,7 @@ namespace Barotrauma
|
||||
//4. contact points is above the bottom half of the collider
|
||||
Vector2 normal; FarseerPhysics.Common.FixedArray2<Vector2> points;
|
||||
contact.GetWorldManifold(out normal, out points);
|
||||
if (points[0].Y > collider.SimPosition.Y) return false;
|
||||
if (points[0].Y > Collider.SimPosition.Y) return false;
|
||||
|
||||
//5. in water
|
||||
if (inWater && targetMovement.Y < 0.5f) return false;
|
||||
@@ -475,14 +522,14 @@ namespace Barotrauma
|
||||
limb.HitSound.Play(volume, impact * 100.0f, limb.WorldPosition);
|
||||
}
|
||||
}
|
||||
else if (f1.Body == collider.FarseerBody)
|
||||
else if (f1.Body == Collider.FarseerBody)
|
||||
{
|
||||
if (!character.IsRemotePlayer || GameMain.Server != null)
|
||||
{
|
||||
if (impact > ImpactTolerance)
|
||||
{
|
||||
character.AddDamage(CauseOfDeath.Damage, impact - ImpactTolerance, null);
|
||||
SoundPlayer.PlayDamageSound(DamageSoundType.LimbBlunt, strongestImpact, collider);
|
||||
SoundPlayer.PlayDamageSound(DamageSoundType.LimbBlunt, strongestImpact, Collider);
|
||||
strongestImpact = Math.Max(strongestImpact, impact - ImpactTolerance);
|
||||
}
|
||||
}
|
||||
@@ -495,7 +542,7 @@ namespace Barotrauma
|
||||
{
|
||||
if (simplePhysicsEnabled) return;
|
||||
|
||||
collider.UpdateDrawPosition();
|
||||
Collider.UpdateDrawPosition();
|
||||
|
||||
foreach (Limb limb in Limbs)
|
||||
{
|
||||
@@ -522,7 +569,7 @@ namespace Barotrauma
|
||||
limb.body.DebugDraw(spriteBatch, inWater ? Color.Cyan : Color.White);
|
||||
}
|
||||
|
||||
collider.DebugDraw(spriteBatch, inWater ? Color.SkyBlue : Color.Gray);
|
||||
Collider.DebugDraw(spriteBatch, inWater ? Color.SkyBlue : Color.Gray);
|
||||
|
||||
foreach (RevoluteJoint joint in limbJoints)
|
||||
{
|
||||
@@ -568,8 +615,8 @@ namespace Barotrauma
|
||||
if (ignorePlatforms)
|
||||
{
|
||||
GUI.DrawLine(spriteBatch,
|
||||
new Vector2(collider.DrawPosition.X, -collider.DrawPosition.Y),
|
||||
new Vector2(collider.DrawPosition.X, -collider.DrawPosition.Y + 50),
|
||||
new Vector2(Collider.DrawPosition.X, -Collider.DrawPosition.Y),
|
||||
new Vector2(Collider.DrawPosition.X, -Collider.DrawPosition.Y + 50),
|
||||
Color.Orange, 0, 5);
|
||||
}
|
||||
}
|
||||
@@ -577,7 +624,7 @@ namespace Barotrauma
|
||||
public virtual void Flip()
|
||||
{
|
||||
dir = (dir == Direction.Left) ? Direction.Right : Direction.Left;
|
||||
|
||||
|
||||
for (int i = 0; i < limbJoints.Length; i++)
|
||||
{
|
||||
float lowerLimit = -limbJoints[i].UpperLimit;
|
||||
@@ -601,6 +648,11 @@ namespace Barotrauma
|
||||
|
||||
Limbs[i].Dir = Dir;
|
||||
|
||||
if (Limbs[i].LightSource != null)
|
||||
{
|
||||
Limbs[i].LightSource.SpriteEffect = (dir == Direction.Left) ? SpriteEffects.FlipHorizontally : SpriteEffects.None;
|
||||
}
|
||||
|
||||
if (Limbs[i].pullJoint == null) continue;
|
||||
|
||||
Limbs[i].pullJoint.LocalAnchorA =
|
||||
@@ -718,7 +770,7 @@ namespace Barotrauma
|
||||
//character.Stun = 0.1f;
|
||||
character.DisableImpactDamageTimer = 0.25f;
|
||||
|
||||
SetPosition(collider.SimPosition + moveAmount);
|
||||
SetPosition(Collider.SimPosition + moveAmount);
|
||||
character.CursorPosition += moveAmount;
|
||||
}
|
||||
|
||||
@@ -732,7 +784,7 @@ namespace Barotrauma
|
||||
wall | Physics.CollisionProjectile | Physics.CollisionStairs
|
||||
: wall | Physics.CollisionProjectile | Physics.CollisionPlatform | Physics.CollisionStairs;
|
||||
|
||||
collider.CollidesWith = collisionCategory;
|
||||
Collider.CollidesWith = collisionCategory;
|
||||
|
||||
foreach (Limb limb in Limbs)
|
||||
{
|
||||
@@ -749,19 +801,21 @@ namespace Barotrauma
|
||||
}
|
||||
}
|
||||
|
||||
protected bool levitatingCollider = true;
|
||||
|
||||
public void Update(Camera cam, float deltaTime)
|
||||
{
|
||||
if (!character.Enabled || Frozen) return;
|
||||
|
||||
UpdateNetPlayerPosition(deltaTime);
|
||||
CheckDistFromCollider();
|
||||
|
||||
|
||||
Vector2 flowForce = Vector2.Zero;
|
||||
|
||||
FindHull();
|
||||
|
||||
splashSoundTimer -= deltaTime;
|
||||
|
||||
|
||||
//ragdoll isn't in any room -> it's in the water
|
||||
if (currentHull == null)
|
||||
{
|
||||
@@ -779,41 +833,41 @@ namespace Barotrauma
|
||||
|
||||
float floorY = GetFloorY();
|
||||
|
||||
if (currentHull.Volume > currentHull.FullVolume * 0.95f ||
|
||||
(waterSurface - floorY > HeadPosition * 0.95f && collider.SimPosition.Y < waterSurface))
|
||||
inWater = true;
|
||||
if (currentHull.Volume > currentHull.FullVolume * 0.95f ||
|
||||
(waterSurface - floorY > HeadPosition * 0.95f && Collider.SimPosition.Y < waterSurface))
|
||||
inWater = true;
|
||||
}
|
||||
|
||||
if (flowForce.LengthSquared() > 0.001f)
|
||||
{
|
||||
collider.ApplyForce(flowForce);
|
||||
Collider.ApplyForce(flowForce);
|
||||
}
|
||||
|
||||
if (currentHull==null ||
|
||||
currentHull.Volume > currentHull.FullVolume * 0.95f ||
|
||||
ConvertUnits.ToSimUnits(currentHull.Surface) > collider.SimPosition.Y)
|
||||
if (currentHull == null ||
|
||||
currentHull.Volume > currentHull.FullVolume * 0.95f ||
|
||||
ConvertUnits.ToSimUnits(currentHull.Surface) > Collider.SimPosition.Y)
|
||||
{
|
||||
collider.ApplyWaterForces();
|
||||
Collider.ApplyWaterForces();
|
||||
}
|
||||
|
||||
|
||||
|
||||
|
||||
foreach (Limb limb in Limbs)
|
||||
{
|
||||
//find the room which the limb is in
|
||||
//the room where the ragdoll is in is used as the "guess", meaning that it's checked first
|
||||
Hull limbHull = currentHull == null ? null : Hull.FindHull(limb.WorldPosition, currentHull);
|
||||
|
||||
|
||||
bool prevInWater = limb.inWater;
|
||||
limb.inWater = false;
|
||||
|
||||
if (limbHull == null)
|
||||
{
|
||||
{
|
||||
//limb isn't in any room -> it's in the water
|
||||
limb.inWater = true;
|
||||
}
|
||||
else if (limbHull.Volume > 0.0f && Submarine.RectContains(limbHull.Rect, limb.Position))
|
||||
{
|
||||
if (limb.Position.Y < limbHull.Surface)
|
||||
if (limb.Position.Y < limbHull.Surface)
|
||||
{
|
||||
limb.inWater = true;
|
||||
|
||||
@@ -829,7 +883,7 @@ namespace Barotrauma
|
||||
headInWater = true;
|
||||
}
|
||||
}
|
||||
//the limb has gone through the surface of the water
|
||||
//the limb has gone through the surface of the water
|
||||
if (Math.Abs(limb.LinearVelocity.Y) > 5.0f && limb.inWater != prevInWater)
|
||||
{
|
||||
|
||||
@@ -838,14 +892,14 @@ namespace Barotrauma
|
||||
new Vector2(limb.Position.X, limbHull.Surface) + limbHull.Submarine.Position,
|
||||
new Vector2(0.0f, Math.Abs(-limb.LinearVelocity.Y * 20.0f)),
|
||||
0.0f, limbHull);
|
||||
|
||||
|
||||
GameMain.ParticleManager.CreateParticle("bubbles",
|
||||
new Vector2(limb.Position.X, limbHull.Surface) + limbHull.Submarine.Position,
|
||||
limb.LinearVelocity*0.001f,
|
||||
new Vector2(limb.Position.X, limbHull.Surface) + limbHull.Submarine.Position,
|
||||
limb.LinearVelocity * 0.001f,
|
||||
0.0f, limbHull);
|
||||
|
||||
//if the Character dropped into water, create a wave
|
||||
if (limb.LinearVelocity.Y<0.0f)
|
||||
if (limb.LinearVelocity.Y < 0.0f)
|
||||
{
|
||||
if (splashSoundTimer <= 0.0f)
|
||||
{
|
||||
@@ -864,15 +918,18 @@ namespace Barotrauma
|
||||
}
|
||||
}
|
||||
|
||||
if (limb.LightSource != null)
|
||||
{
|
||||
limb.LightSource.Rotation = limb.Rotation;
|
||||
}
|
||||
limb.Update(deltaTime);
|
||||
}
|
||||
|
||||
|
||||
|
||||
bool onStairs = stairs != null;
|
||||
stairs = null;
|
||||
|
||||
var contacts = collider.FarseerBody.ContactList;
|
||||
while (collider.FarseerBody.Enabled && contacts != null && contacts.Contact != null)
|
||||
var contacts = Collider.FarseerBody.ContactList;
|
||||
while (Collider.FarseerBody.Enabled && contacts != null && contacts.Contact != null)
|
||||
{
|
||||
if (contacts.Contact.Enabled && contacts.Contact.IsTouching)
|
||||
{
|
||||
@@ -907,7 +964,7 @@ namespace Barotrauma
|
||||
//}
|
||||
|
||||
|
||||
if (points[0].Y < collider.SimPosition.Y)
|
||||
if (points[0].Y < Collider.SimPosition.Y)
|
||||
{
|
||||
floorY = Math.Max(floorY, points[0].Y);
|
||||
|
||||
@@ -931,12 +988,82 @@ namespace Barotrauma
|
||||
onFloorTimer -= deltaTime;
|
||||
}
|
||||
|
||||
Vector2 rayStart = Collider.SimPosition;
|
||||
Vector2 rayEnd = rayStart;
|
||||
rayEnd.Y -= Collider.height * 0.5f + Collider.radius + colliderHeightFromFloor*1.2f;
|
||||
|
||||
Vector2 colliderBottomDisplay = ConvertUnits.ToDisplayUnits(GetColliderBottom());
|
||||
if (!inWater && !character.IsDead && !character.IsUnconscious && levitatingCollider && Collider.LinearVelocity.Y>-ImpactTolerance)
|
||||
{
|
||||
float closestFraction = 1.0f;
|
||||
Fixture closestFixture = null;
|
||||
GameMain.World.RayCast((fixture, point, normal, fraction) =>
|
||||
{
|
||||
switch (fixture.CollisionCategories)
|
||||
{
|
||||
case Physics.CollisionStairs:
|
||||
Structure structure = fixture.Body.UserData as Structure;
|
||||
if (colliderBottomDisplay.Y < structure.Rect.Y - structure.Rect.Height + 30 && TargetMovement.Y < 0.5f) return -1;
|
||||
break;
|
||||
case Physics.CollisionPlatform:
|
||||
Structure platform = fixture.Body.UserData as Structure;
|
||||
if (IgnorePlatforms || colliderBottomDisplay.Y < platform.Rect.Y - 16) return -1;
|
||||
break;
|
||||
case Physics.CollisionWall:
|
||||
break;
|
||||
default:
|
||||
return -1;
|
||||
}
|
||||
|
||||
if (fraction < closestFraction)
|
||||
{
|
||||
closestFraction = fraction;
|
||||
closestFixture = fixture;
|
||||
}
|
||||
|
||||
return closestFraction;
|
||||
}
|
||||
, rayStart, rayEnd);
|
||||
|
||||
if (closestFraction < 1.0f && closestFixture!=null)
|
||||
{
|
||||
bool forceImmediate = false;
|
||||
onGround = true;
|
||||
|
||||
switch (closestFixture.CollisionCategories)
|
||||
{
|
||||
case Physics.CollisionStairs:
|
||||
stairs = closestFixture.Body.UserData as Structure;
|
||||
onStairs = true;
|
||||
forceImmediate = true;
|
||||
break;
|
||||
}
|
||||
|
||||
float tfloorY = rayStart.Y + (rayEnd.Y - rayStart.Y) * closestFraction;
|
||||
float targetY = tfloorY + Collider.height * 0.5f + Collider.radius + colliderHeightFromFloor;
|
||||
|
||||
if (Math.Abs(Collider.SimPosition.Y - targetY) > 0.01f && Collider.SimPosition.Y<targetY && !forceImmediate)
|
||||
{
|
||||
Vector2 newSpeed = Collider.LinearVelocity;
|
||||
newSpeed.Y = (targetY - Collider.SimPosition.Y)*5.0f;
|
||||
Collider.LinearVelocity = newSpeed;
|
||||
}
|
||||
else
|
||||
{
|
||||
Vector2 newSpeed = Collider.LinearVelocity;
|
||||
newSpeed.Y = 0.0f;
|
||||
Collider.LinearVelocity = newSpeed;
|
||||
Vector2 newPos = Collider.SimPosition;
|
||||
newPos.Y = targetY;
|
||||
Collider.SetTransform(newPos, Collider.Rotation);
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
protected float GetFloorY(Limb refLimb = null)
|
||||
{
|
||||
PhysicsBody refBody = refLimb == null ? collider : refLimb.body;
|
||||
PhysicsBody refBody = refLimb == null ? Collider : refLimb.body;
|
||||
|
||||
Vector2 rayStart = refBody.SimPosition;
|
||||
Vector2 rayEnd = rayStart - new Vector2(0.0f, TorsoPosition);
|
||||
@@ -984,9 +1111,9 @@ namespace Barotrauma
|
||||
|
||||
public void SetPosition(Vector2 simPosition, bool lerp = false)
|
||||
{
|
||||
Vector2 moveAmount = simPosition - collider.SimPosition;
|
||||
Vector2 moveAmount = simPosition - Collider.SimPosition;
|
||||
|
||||
collider.SetTransform(simPosition, collider.Rotation);
|
||||
Collider.SetTransform(simPosition, Collider.Rotation);
|
||||
|
||||
foreach (Limb limb in Limbs)
|
||||
{
|
||||
@@ -1019,7 +1146,7 @@ namespace Barotrauma
|
||||
if (lerp)
|
||||
{
|
||||
limb.body.TargetPosition = movePos;
|
||||
limb.body.MoveToTargetPosition(Vector2.Distance(limb.SimPosition, movePos) < 10.0f);
|
||||
limb.body.MoveToTargetPosition(Vector2.DistanceSquared(limb.SimPosition, movePos) < 100.0f);
|
||||
}
|
||||
else
|
||||
{
|
||||
@@ -1037,11 +1164,11 @@ namespace Barotrauma
|
||||
|
||||
protected void CheckDistFromCollider()
|
||||
{
|
||||
float allowedDist = Math.Max(Math.Max(collider.radius, collider.width), collider.height) * 2.0f;
|
||||
float allowedDist = Math.Max(Math.Max(Collider.radius, Collider.width), Collider.height) * 2.0f;
|
||||
|
||||
//if the ragdoll is too far from the collider, disable collisions until it's close enough
|
||||
//(in case the ragdoll has gotten stuck somewhere)
|
||||
if (Vector2.Distance(collider.SimPosition, MainLimb.SimPosition) > allowedDist)
|
||||
if (Vector2.DistanceSquared(Collider.SimPosition, MainLimb.SimPosition) > allowedDist*allowedDist)
|
||||
{
|
||||
foreach (Limb limb in Limbs)
|
||||
{
|
||||
@@ -1053,7 +1180,7 @@ namespace Barotrauma
|
||||
else if (collisionsDisabled)
|
||||
{
|
||||
//set the position of the ragdoll to make sure limbs don't get stuck inside walls when re-enabling collisions
|
||||
SetPosition(collider.SimPosition, true);
|
||||
SetPosition(Collider.SimPosition, true);
|
||||
|
||||
UpdateCollisionCategories();
|
||||
collisionsDisabled = false;
|
||||
@@ -1082,11 +1209,11 @@ namespace Barotrauma
|
||||
if (errorMagnitude > 2.0f)
|
||||
{
|
||||
//predicted position was way off, reset completely
|
||||
collider.SetTransform(serverPos.Position, collider.Rotation);
|
||||
Collider.SetTransform(serverPos.Position, Collider.Rotation);
|
||||
//local positions are incorrect now -> just clear the list
|
||||
character.MemLocalPos.Clear();
|
||||
}
|
||||
else if (errorMagnitude > collider.LinearVelocity.Length()/10.0f + 0.02f)
|
||||
else if (errorMagnitude > Collider.LinearVelocity.Length()/10.0f + 0.02f)
|
||||
{
|
||||
//our prediction differs from the server position
|
||||
//-> we need to move the saved local position and all the positions saved after it
|
||||
@@ -1101,7 +1228,7 @@ namespace Barotrauma
|
||||
character.MemLocalPos[i].Direction,
|
||||
character.MemLocalPos[i].ID);
|
||||
}
|
||||
collider.SetTransform(character.MemLocalPos.Last().Position, collider.Rotation);
|
||||
Collider.SetTransform(character.MemLocalPos.Last().Position, Collider.Rotation);
|
||||
}
|
||||
}
|
||||
|
||||
@@ -1112,8 +1239,8 @@ namespace Barotrauma
|
||||
{
|
||||
if (character.MemPos.Count > 0)
|
||||
{
|
||||
collider.LinearVelocity = Vector2.Zero;
|
||||
collider.CorrectPosition(character.MemPos, deltaTime, out overrideTargetMovement);
|
||||
Collider.LinearVelocity = Vector2.Zero;
|
||||
Collider.CorrectPosition(character.MemPos, deltaTime, out overrideTargetMovement);
|
||||
}
|
||||
}
|
||||
}
|
||||
@@ -1149,10 +1276,12 @@ namespace Barotrauma
|
||||
|
||||
public Vector2 GetColliderBottom()
|
||||
{
|
||||
float halfHeight = collider.height / 2 + collider.radius;
|
||||
float halfHeight = Collider.height * 0.5f + Collider.radius;
|
||||
|
||||
return collider.SimPosition +
|
||||
new Vector2((float)Math.Sin(collider.Rotation), -(float)Math.Cos(collider.Rotation)) * halfHeight;
|
||||
Vector2 offset = Vector2.Zero;
|
||||
offset.Y = -colliderHeightFromFloor;
|
||||
return Collider.SimPosition + offset +
|
||||
new Vector2((float)Math.Sin(Collider.Rotation), -(float)Math.Cos(Collider.Rotation)) * halfHeight;
|
||||
}
|
||||
|
||||
public Limb FindLowestLimb()
|
||||
@@ -1171,11 +1300,24 @@ namespace Barotrauma
|
||||
|
||||
public void Remove()
|
||||
{
|
||||
foreach (Limb l in Limbs) l.Remove();
|
||||
foreach (Limb l in Limbs)
|
||||
{
|
||||
l.Remove();
|
||||
}
|
||||
Limbs = null;
|
||||
|
||||
foreach (PhysicsBody b in collider)
|
||||
{
|
||||
b.Remove();
|
||||
}
|
||||
|
||||
foreach (RevoluteJoint joint in limbJoints)
|
||||
{
|
||||
GameMain.World.RemoveJoint(joint);
|
||||
}
|
||||
limbJoints = null;
|
||||
|
||||
list.Remove(this);
|
||||
}
|
||||
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user