Fixed carrying stunned people being a severe case of a major ass pain by carrying over the "stairs" from the carrier.
Added "CarriedBy" property, publicized CarriedCharacter and CarriedBy, synced CarriedCharacter and CarriedBy for cool points Publicized Stairs property
This commit is contained in:
@@ -127,7 +127,7 @@ namespace Barotrauma
|
|||||||
if (selectedEntity is Character)
|
if (selectedEntity is Character)
|
||||||
{
|
{
|
||||||
bool doingCpr = msg.ReadBoolean();
|
bool doingCpr = msg.ReadBoolean();
|
||||||
if (doingCpr && selectedCharacter != null)
|
if (doingCpr && SelectedCharacter != null)
|
||||||
{
|
{
|
||||||
animation = AnimController.Animation.CPR;
|
animation = AnimController.Animation.CPR;
|
||||||
}
|
}
|
||||||
|
|||||||
@@ -259,14 +259,14 @@ namespace Barotrauma
|
|||||||
{
|
{
|
||||||
if (character == null) return false;
|
if (character == null) return false;
|
||||||
|
|
||||||
GUIComponent existingFrame = crewList.Parent.FindChild("selectedcharacter");
|
GUIComponent existingFrame = crewList.Parent.FindChild("SelectedCharacter");
|
||||||
if (existingFrame != null) crewList.Parent.RemoveChild(existingFrame);
|
if (existingFrame != null) crewList.Parent.RemoveChild(existingFrame);
|
||||||
|
|
||||||
var previewPlayer = new GUIFrame(
|
var previewPlayer = new GUIFrame(
|
||||||
new Rectangle(0, 0, 230, 300),
|
new Rectangle(0, 0, 230, 300),
|
||||||
new Color(0.0f, 0.0f, 0.0f, 0.8f), Alignment.TopRight, "", crewList.Parent);
|
new Color(0.0f, 0.0f, 0.0f, 0.8f), Alignment.TopRight, "", crewList.Parent);
|
||||||
previewPlayer.Padding = new Vector4(5.0f, 5.0f, 5.0f, 5.0f);
|
previewPlayer.Padding = new Vector4(5.0f, 5.0f, 5.0f, 5.0f);
|
||||||
previewPlayer.UserData = "selectedcharacter";
|
previewPlayer.UserData = "SelectedCharacter";
|
||||||
|
|
||||||
character.Info.CreateInfoFrame(previewPlayer);
|
character.Info.CreateInfoFrame(previewPlayer);
|
||||||
|
|
||||||
|
|||||||
@@ -237,7 +237,7 @@ namespace Barotrauma
|
|||||||
|
|
||||||
float getUpSpeed = 0.3f;
|
float getUpSpeed = 0.3f;
|
||||||
float walkCycleSpeed = movement.X * walkAnimSpeed;
|
float walkCycleSpeed = movement.X * walkAnimSpeed;
|
||||||
if (stairs != null)
|
if (Stairs != null)
|
||||||
{
|
{
|
||||||
TargetMovement = new Vector2(MathHelper.Clamp(TargetMovement.X, -1.5f, 1.5f), TargetMovement.Y);
|
TargetMovement = new Vector2(MathHelper.Clamp(TargetMovement.X, -1.5f, 1.5f), TargetMovement.Y);
|
||||||
|
|
||||||
@@ -328,7 +328,7 @@ namespace Barotrauma
|
|||||||
float floorPos = GetFloorY(colliderPos + new Vector2(Math.Sign(movement.X) * 0.5f, 1.0f));
|
float floorPos = GetFloorY(colliderPos + new Vector2(Math.Sign(movement.X) * 0.5f, 1.0f));
|
||||||
bool onSlope = floorPos > GetColliderBottom().Y + 0.05f;
|
bool onSlope = floorPos > GetColliderBottom().Y + 0.05f;
|
||||||
|
|
||||||
if (stairs != null || onSlope)
|
if (Stairs != null || onSlope)
|
||||||
{
|
{
|
||||||
torso.pullJoint.WorldAnchorB = new Vector2(
|
torso.pullJoint.WorldAnchorB = new Vector2(
|
||||||
MathHelper.SmoothStep(torso.SimPosition.X, footMid + movement.X * 0.25f, getUpSpeed * 0.8f),
|
MathHelper.SmoothStep(torso.SimPosition.X, footMid + movement.X * 0.25f, getUpSpeed * 0.8f),
|
||||||
@@ -382,7 +382,7 @@ namespace Barotrauma
|
|||||||
Vector2 footPos = stepSize * -i;
|
Vector2 footPos = stepSize * -i;
|
||||||
if (stepSize.Y < 0.0f) stepSize.Y = -0.15f;
|
if (stepSize.Y < 0.0f) stepSize.Y = -0.15f;
|
||||||
|
|
||||||
if (onSlope && stairs == null)
|
if (onSlope && Stairs == null)
|
||||||
{
|
{
|
||||||
footPos.Y *= 2.0f;
|
footPos.Y *= 2.0f;
|
||||||
}
|
}
|
||||||
@@ -462,7 +462,7 @@ namespace Barotrauma
|
|||||||
footPos = new Vector2(GetCenterOfMass().X + stepSize.X * i * 0.2f, colliderPos.Y - 0.1f);
|
footPos = new Vector2(GetCenterOfMass().X + stepSize.X * i * 0.2f, colliderPos.Y - 0.1f);
|
||||||
}
|
}
|
||||||
|
|
||||||
if (stairs == null)
|
if (Stairs == null)
|
||||||
{
|
{
|
||||||
footPos.Y = Math.Max(Math.Min(floorPos, footPos.Y + 0.5f), footPos.Y);
|
footPos.Y = Math.Max(Math.Min(floorPos, footPos.Y + 0.5f), footPos.Y);
|
||||||
}
|
}
|
||||||
@@ -987,7 +987,7 @@ namespace Barotrauma
|
|||||||
}
|
}
|
||||||
|
|
||||||
//if on stairs, make the dragged character "climb up" (= collide with stairs)
|
//if on stairs, make the dragged character "climb up" (= collide with stairs)
|
||||||
//if (stairs != null) target.AnimController.TargetMovement = new Vector2 (target.AnimController.TargetMovement.X, 1.0f);
|
//if (Stairs != null) target.AnimController.TargetMovement = new Vector2 (target.AnimController.TargetMovement.X, 1.0f);
|
||||||
}
|
}
|
||||||
|
|
||||||
public void Grab(Vector2 rightHandPos, Vector2 leftHandPos)
|
public void Grab(Vector2 rightHandPos, Vector2 leftHandPos)
|
||||||
|
|||||||
@@ -67,7 +67,7 @@ namespace Barotrauma
|
|||||||
|
|
||||||
protected float colliderHeightFromFloor;
|
protected float colliderHeightFromFloor;
|
||||||
|
|
||||||
protected Structure stairs;
|
public Structure Stairs;
|
||||||
|
|
||||||
protected Direction dir;
|
protected Direction dir;
|
||||||
|
|
||||||
@@ -452,7 +452,7 @@ namespace Barotrauma
|
|||||||
}
|
}
|
||||||
else if (structure.StairDirection != Direction.None)
|
else if (structure.StairDirection != Direction.None)
|
||||||
{
|
{
|
||||||
stairs = null;
|
Stairs = null;
|
||||||
|
|
||||||
//don't collider with stairs if
|
//don't collider with stairs if
|
||||||
|
|
||||||
@@ -475,8 +475,15 @@ namespace Barotrauma
|
|||||||
if (inWater && targetMovement.Y < 0.5f) return false;
|
if (inWater && targetMovement.Y < 0.5f) return false;
|
||||||
|
|
||||||
//---------------
|
//---------------
|
||||||
|
|
||||||
stairs = structure;
|
//set stairs to that of the one dragging us
|
||||||
|
if (character.SelectedBy != null)
|
||||||
|
Stairs = character.SelectedBy.AnimController.Stairs;
|
||||||
|
else
|
||||||
|
Stairs = structure;
|
||||||
|
|
||||||
|
if (Stairs == null)
|
||||||
|
return false;
|
||||||
}
|
}
|
||||||
|
|
||||||
CalculateImpact(f1, f2, contact);
|
CalculateImpact(f1, f2, contact);
|
||||||
@@ -895,8 +902,8 @@ namespace Barotrauma
|
|||||||
limb.Update(deltaTime);
|
limb.Update(deltaTime);
|
||||||
}
|
}
|
||||||
|
|
||||||
bool onStairs = stairs != null;
|
bool onStairs = Stairs != null;
|
||||||
stairs = null;
|
Stairs = null;
|
||||||
|
|
||||||
var contacts = Collider.FarseerBody.ContactList;
|
var contacts = Collider.FarseerBody.ContactList;
|
||||||
while (Collider.FarseerBody.Enabled && contacts != null && contacts.Contact != null)
|
while (Collider.FarseerBody.Enabled && contacts != null && contacts.Contact != null)
|
||||||
@@ -914,7 +921,7 @@ namespace Barotrauma
|
|||||||
Structure structure = contacts.Contact.FixtureA.Body.UserData as Structure;
|
Structure structure = contacts.Contact.FixtureA.Body.UserData as Structure;
|
||||||
if (structure != null && onStairs)
|
if (structure != null && onStairs)
|
||||||
{
|
{
|
||||||
stairs = structure;
|
Stairs = structure;
|
||||||
}
|
}
|
||||||
break;
|
break;
|
||||||
}
|
}
|
||||||
@@ -963,7 +970,7 @@ namespace Barotrauma
|
|||||||
rayEnd.Y -= Collider.height * 0.5f + Collider.radius + colliderHeightFromFloor*1.2f;
|
rayEnd.Y -= Collider.height * 0.5f + Collider.radius + colliderHeightFromFloor*1.2f;
|
||||||
|
|
||||||
Vector2 colliderBottomDisplay = ConvertUnits.ToDisplayUnits(GetColliderBottom());
|
Vector2 colliderBottomDisplay = ConvertUnits.ToDisplayUnits(GetColliderBottom());
|
||||||
if (!inWater && !character.IsDead && !character.IsUnconscious && levitatingCollider && Collider.LinearVelocity.Y>-ImpactTolerance)
|
if (!inWater && !character.IsDead && character.Stun <= 0f && levitatingCollider && Collider.LinearVelocity.Y>-ImpactTolerance)
|
||||||
{
|
{
|
||||||
float closestFraction = 1.0f;
|
float closestFraction = 1.0f;
|
||||||
Fixture closestFixture = null;
|
Fixture closestFixture = null;
|
||||||
@@ -975,6 +982,7 @@ namespace Barotrauma
|
|||||||
Structure structure = fixture.Body.UserData as Structure;
|
Structure structure = fixture.Body.UserData as Structure;
|
||||||
if (inWater && targetMovement.Y < 0.5f) return -1;
|
if (inWater && targetMovement.Y < 0.5f) return -1;
|
||||||
if (colliderBottomDisplay.Y < structure.Rect.Y - structure.Rect.Height + 30 && TargetMovement.Y < 0.5f) return -1;
|
if (colliderBottomDisplay.Y < structure.Rect.Y - structure.Rect.Height + 30 && TargetMovement.Y < 0.5f) return -1;
|
||||||
|
if (character.SelectedBy != null) return -1;
|
||||||
break;
|
break;
|
||||||
case Physics.CollisionPlatform:
|
case Physics.CollisionPlatform:
|
||||||
Structure platform = fixture.Body.UserData as Structure;
|
Structure platform = fixture.Body.UserData as Structure;
|
||||||
@@ -1004,7 +1012,7 @@ namespace Barotrauma
|
|||||||
switch (closestFixture.CollisionCategories)
|
switch (closestFixture.CollisionCategories)
|
||||||
{
|
{
|
||||||
case Physics.CollisionStairs:
|
case Physics.CollisionStairs:
|
||||||
stairs = closestFixture.Body.UserData as Structure;
|
Stairs = closestFixture.Body.UserData as Structure;
|
||||||
onStairs = true;
|
onStairs = true;
|
||||||
forceImmediate = true;
|
forceImmediate = true;
|
||||||
break;
|
break;
|
||||||
|
|||||||
@@ -94,7 +94,7 @@ namespace Barotrauma
|
|||||||
protected float minHealth, maxHealth;
|
protected float minHealth, maxHealth;
|
||||||
|
|
||||||
protected Item focusedItem;
|
protected Item focusedItem;
|
||||||
private Character focusedCharacter, selectedCharacter;
|
private Character focusedCharacter, selectedCharacter, selectedBy;
|
||||||
|
|
||||||
private bool isDead;
|
private bool isDead;
|
||||||
private CauseOfDeath lastAttackCauseOfDeath;
|
private CauseOfDeath lastAttackCauseOfDeath;
|
||||||
@@ -204,6 +204,27 @@ namespace Barotrauma
|
|||||||
public Character SelectedCharacter
|
public Character SelectedCharacter
|
||||||
{
|
{
|
||||||
get { return selectedCharacter; }
|
get { return selectedCharacter; }
|
||||||
|
set
|
||||||
|
{
|
||||||
|
if (selectedCharacter != null)
|
||||||
|
selectedCharacter.selectedBy = null;
|
||||||
|
selectedCharacter = value;
|
||||||
|
if (selectedCharacter != null)
|
||||||
|
selectedCharacter.selectedBy = this;
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
public Character SelectedBy
|
||||||
|
{
|
||||||
|
get { return selectedBy; }
|
||||||
|
set
|
||||||
|
{
|
||||||
|
if (selectedBy != null)
|
||||||
|
selectedBy.selectedCharacter = null;
|
||||||
|
selectedBy = value;
|
||||||
|
if (selectedBy != null)
|
||||||
|
selectedBy.selectedCharacter = this;
|
||||||
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
private float lowPassMultiplier;
|
private float lowPassMultiplier;
|
||||||
@@ -772,7 +793,7 @@ namespace Barotrauma
|
|||||||
// - dragging someone
|
// - dragging someone
|
||||||
// - crouching
|
// - crouching
|
||||||
// - moving backwards
|
// - moving backwards
|
||||||
if (selectedCharacter == null &&
|
if (SelectedCharacter == null &&
|
||||||
(!(AnimController is HumanoidAnimController) || !((HumanoidAnimController)AnimController).Crouching) &&
|
(!(AnimController is HumanoidAnimController) || !((HumanoidAnimController)AnimController).Crouching) &&
|
||||||
Math.Sign(targetMovement.X) != -Math.Sign(AnimController.Dir))
|
Math.Sign(targetMovement.X) != -Math.Sign(AnimController.Dir))
|
||||||
{
|
{
|
||||||
@@ -919,9 +940,9 @@ namespace Barotrauma
|
|||||||
if (selectedConstruction != null && IsKeyDown(InputType.Aim)) selectedConstruction.SecondaryUse(deltaTime, this);
|
if (selectedConstruction != null && IsKeyDown(InputType.Aim)) selectedConstruction.SecondaryUse(deltaTime, this);
|
||||||
}
|
}
|
||||||
|
|
||||||
if (selectedCharacter != null)
|
if (SelectedCharacter != null)
|
||||||
{
|
{
|
||||||
if (Vector2.DistanceSquared(selectedCharacter.WorldPosition, WorldPosition) > 90000.0f || !selectedCharacter.CanBeSelected)
|
if (Vector2.DistanceSquared(SelectedCharacter.WorldPosition, WorldPosition) > 90000.0f || !SelectedCharacter.CanBeSelected)
|
||||||
{
|
{
|
||||||
DeselectCharacter();
|
DeselectCharacter();
|
||||||
}
|
}
|
||||||
@@ -993,7 +1014,7 @@ namespace Barotrauma
|
|||||||
var owner = (Character)inventory.Owner;
|
var owner = (Character)inventory.Owner;
|
||||||
|
|
||||||
//can only be accessed if the character is incapacitated and has been selected
|
//can only be accessed if the character is incapacitated and has been selected
|
||||||
return selectedCharacter == owner && (!owner.CanInteract);
|
return SelectedCharacter == owner && (!owner.CanInteract);
|
||||||
}
|
}
|
||||||
|
|
||||||
if (inventory.Owner is Item)
|
if (inventory.Owner is Item)
|
||||||
@@ -1222,22 +1243,22 @@ namespace Barotrauma
|
|||||||
{
|
{
|
||||||
if (character == null) return;
|
if (character == null) return;
|
||||||
|
|
||||||
selectedCharacter = character;
|
SelectedCharacter = character;
|
||||||
}
|
}
|
||||||
|
|
||||||
public void DeselectCharacter()
|
public void DeselectCharacter()
|
||||||
{
|
{
|
||||||
if (selectedCharacter == null) return;
|
if (SelectedCharacter == null) return;
|
||||||
|
|
||||||
if (SelectedCharacter.AnimController != null)
|
if (SelectedCharacter.AnimController != null)
|
||||||
{
|
{
|
||||||
foreach (Limb limb in selectedCharacter.AnimController.Limbs)
|
foreach (Limb limb in SelectedCharacter.AnimController.Limbs)
|
||||||
{
|
{
|
||||||
if (limb.pullJoint != null) limb.pullJoint.Enabled = false;
|
if (limb.pullJoint != null) limb.pullJoint.Enabled = false;
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
selectedCharacter = null;
|
SelectedCharacter = null;
|
||||||
}
|
}
|
||||||
|
|
||||||
public void DoInteractionUpdate(float deltaTime, Vector2 mouseSimPos)
|
public void DoInteractionUpdate(float deltaTime, Vector2 mouseSimPos)
|
||||||
@@ -1250,7 +1271,7 @@ namespace Barotrauma
|
|||||||
|
|
||||||
if (!CanInteract)
|
if (!CanInteract)
|
||||||
{
|
{
|
||||||
if (selectedCharacter != null)
|
if (SelectedCharacter != null)
|
||||||
{
|
{
|
||||||
DeselectCharacter();
|
DeselectCharacter();
|
||||||
}
|
}
|
||||||
@@ -1283,7 +1304,7 @@ namespace Barotrauma
|
|||||||
findFocusedTimer -= deltaTime;
|
findFocusedTimer -= deltaTime;
|
||||||
}
|
}
|
||||||
|
|
||||||
if (selectedCharacter != null && IsKeyHit(InputType.Select))
|
if (SelectedCharacter != null && IsKeyHit(InputType.Select))
|
||||||
{
|
{
|
||||||
DeselectCharacter();
|
DeselectCharacter();
|
||||||
}
|
}
|
||||||
@@ -1470,9 +1491,9 @@ namespace Barotrauma
|
|||||||
selectedConstruction = null;
|
selectedConstruction = null;
|
||||||
}
|
}
|
||||||
|
|
||||||
if (selectedCharacter != null && AnimController.Anim == AnimController.Animation.CPR)
|
if (SelectedCharacter != null && AnimController.Anim == AnimController.Animation.CPR)
|
||||||
{
|
{
|
||||||
if (GameMain.Client == null) selectedCharacter.Oxygen += (GetSkillLevel("Medical") / 10.0f) * deltaTime;
|
if (GameMain.Client == null) SelectedCharacter.Oxygen += (GetSkillLevel("Medical") / 10.0f) * deltaTime;
|
||||||
}
|
}
|
||||||
|
|
||||||
UpdateSightRange();
|
UpdateSightRange();
|
||||||
@@ -1861,7 +1882,7 @@ namespace Barotrauma
|
|||||||
foreach (Character c in CharacterList)
|
foreach (Character c in CharacterList)
|
||||||
{
|
{
|
||||||
if (c.focusedCharacter == this) c.focusedCharacter = null;
|
if (c.focusedCharacter == this) c.focusedCharacter = null;
|
||||||
if (c.selectedCharacter == this) c.selectedCharacter = null;
|
if (c.SelectedCharacter == this) c.SelectedCharacter = null;
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
partial void DisposeProjSpecific();
|
partial void DisposeProjSpecific();
|
||||||
|
|||||||
@@ -193,7 +193,7 @@ namespace Barotrauma
|
|||||||
SimPosition,
|
SimPosition,
|
||||||
LastNetworkUpdateID,
|
LastNetworkUpdateID,
|
||||||
AnimController.TargetDir,
|
AnimController.TargetDir,
|
||||||
selectedCharacter == null ? (Entity)selectedConstruction : (Entity)selectedCharacter,
|
SelectedCharacter == null ? (Entity)selectedConstruction : (Entity)SelectedCharacter,
|
||||||
AnimController.Anim);
|
AnimController.Anim);
|
||||||
|
|
||||||
memLocalState.Add(posInfo);
|
memLocalState.Add(posInfo);
|
||||||
@@ -445,11 +445,11 @@ namespace Barotrauma
|
|||||||
tempBuffer.Write(AnimController.TargetDir == Direction.Right);
|
tempBuffer.Write(AnimController.TargetDir == Direction.Right);
|
||||||
}
|
}
|
||||||
|
|
||||||
if (selectedCharacter != null || selectedConstruction != null)
|
if (SelectedCharacter != null || selectedConstruction != null)
|
||||||
{
|
{
|
||||||
tempBuffer.Write(true);
|
tempBuffer.Write(true);
|
||||||
tempBuffer.Write(selectedCharacter != null ? selectedCharacter.ID : selectedConstruction.ID);
|
tempBuffer.Write(SelectedCharacter != null ? SelectedCharacter.ID : selectedConstruction.ID);
|
||||||
if (selectedCharacter != null)
|
if (SelectedCharacter != null)
|
||||||
{
|
{
|
||||||
tempBuffer.Write(AnimController.Anim == AnimController.Animation.CPR);
|
tempBuffer.Write(AnimController.Anim == AnimController.Animation.CPR);
|
||||||
}
|
}
|
||||||
|
|||||||
Reference in New Issue
Block a user