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:
Alex Noir
2017-12-06 18:58:18 +03:00
parent b26b6a7418
commit 4a8e411a70
6 changed files with 64 additions and 35 deletions

View File

@@ -127,7 +127,7 @@ namespace Barotrauma
if (selectedEntity is Character)
{
bool doingCpr = msg.ReadBoolean();
if (doingCpr && selectedCharacter != null)
if (doingCpr && SelectedCharacter != null)
{
animation = AnimController.Animation.CPR;
}

View File

@@ -259,14 +259,14 @@ namespace Barotrauma
{
if (character == null) return false;
GUIComponent existingFrame = crewList.Parent.FindChild("selectedcharacter");
GUIComponent existingFrame = crewList.Parent.FindChild("SelectedCharacter");
if (existingFrame != null) crewList.Parent.RemoveChild(existingFrame);
var previewPlayer = new GUIFrame(
new Rectangle(0, 0, 230, 300),
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.UserData = "selectedcharacter";
previewPlayer.UserData = "SelectedCharacter";
character.Info.CreateInfoFrame(previewPlayer);

View File

@@ -237,7 +237,7 @@ namespace Barotrauma
float getUpSpeed = 0.3f;
float walkCycleSpeed = movement.X * walkAnimSpeed;
if (stairs != null)
if (Stairs != null)
{
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));
bool onSlope = floorPos > GetColliderBottom().Y + 0.05f;
if (stairs != null || onSlope)
if (Stairs != null || onSlope)
{
torso.pullJoint.WorldAnchorB = new Vector2(
MathHelper.SmoothStep(torso.SimPosition.X, footMid + movement.X * 0.25f, getUpSpeed * 0.8f),
@@ -382,7 +382,7 @@ namespace Barotrauma
Vector2 footPos = stepSize * -i;
if (stepSize.Y < 0.0f) stepSize.Y = -0.15f;
if (onSlope && stairs == null)
if (onSlope && Stairs == null)
{
footPos.Y *= 2.0f;
}
@@ -462,7 +462,7 @@ namespace Barotrauma
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);
}
@@ -987,7 +987,7 @@ namespace Barotrauma
}
//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)

View File

@@ -67,7 +67,7 @@ namespace Barotrauma
protected float colliderHeightFromFloor;
protected Structure stairs;
public Structure Stairs;
protected Direction dir;
@@ -452,7 +452,7 @@ namespace Barotrauma
}
else if (structure.StairDirection != Direction.None)
{
stairs = null;
Stairs = null;
//don't collider with stairs if
@@ -475,8 +475,15 @@ namespace Barotrauma
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);
@@ -895,8 +902,8 @@ namespace Barotrauma
limb.Update(deltaTime);
}
bool onStairs = stairs != null;
stairs = null;
bool onStairs = Stairs != null;
Stairs = null;
var contacts = Collider.FarseerBody.ContactList;
while (Collider.FarseerBody.Enabled && contacts != null && contacts.Contact != null)
@@ -914,7 +921,7 @@ namespace Barotrauma
Structure structure = contacts.Contact.FixtureA.Body.UserData as Structure;
if (structure != null && onStairs)
{
stairs = structure;
Stairs = structure;
}
break;
}
@@ -963,7 +970,7 @@ namespace Barotrauma
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)
if (!inWater && !character.IsDead && character.Stun <= 0f && levitatingCollider && Collider.LinearVelocity.Y>-ImpactTolerance)
{
float closestFraction = 1.0f;
Fixture closestFixture = null;
@@ -975,6 +982,7 @@ namespace Barotrauma
Structure structure = fixture.Body.UserData as Structure;
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 (character.SelectedBy != null) return -1;
break;
case Physics.CollisionPlatform:
Structure platform = fixture.Body.UserData as Structure;
@@ -1004,7 +1012,7 @@ namespace Barotrauma
switch (closestFixture.CollisionCategories)
{
case Physics.CollisionStairs:
stairs = closestFixture.Body.UserData as Structure;
Stairs = closestFixture.Body.UserData as Structure;
onStairs = true;
forceImmediate = true;
break;

View File

@@ -94,7 +94,7 @@ namespace Barotrauma
protected float minHealth, maxHealth;
protected Item focusedItem;
private Character focusedCharacter, selectedCharacter;
private Character focusedCharacter, selectedCharacter, selectedBy;
private bool isDead;
private CauseOfDeath lastAttackCauseOfDeath;
@@ -204,6 +204,27 @@ namespace Barotrauma
public Character 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;
@@ -772,7 +793,7 @@ namespace Barotrauma
// - dragging someone
// - crouching
// - moving backwards
if (selectedCharacter == null &&
if (SelectedCharacter == null &&
(!(AnimController is HumanoidAnimController) || !((HumanoidAnimController)AnimController).Crouching) &&
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 (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();
}
@@ -993,7 +1014,7 @@ namespace Barotrauma
var owner = (Character)inventory.Owner;
//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)
@@ -1222,22 +1243,22 @@ namespace Barotrauma
{
if (character == null) return;
selectedCharacter = character;
SelectedCharacter = character;
}
public void DeselectCharacter()
{
if (selectedCharacter == null) return;
if (SelectedCharacter == null) return;
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;
}
}
selectedCharacter = null;
SelectedCharacter = null;
}
public void DoInteractionUpdate(float deltaTime, Vector2 mouseSimPos)
@@ -1250,7 +1271,7 @@ namespace Barotrauma
if (!CanInteract)
{
if (selectedCharacter != null)
if (SelectedCharacter != null)
{
DeselectCharacter();
}
@@ -1283,7 +1304,7 @@ namespace Barotrauma
findFocusedTimer -= deltaTime;
}
if (selectedCharacter != null && IsKeyHit(InputType.Select))
if (SelectedCharacter != null && IsKeyHit(InputType.Select))
{
DeselectCharacter();
}
@@ -1470,9 +1491,9 @@ namespace Barotrauma
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();
@@ -1861,7 +1882,7 @@ namespace Barotrauma
foreach (Character c in CharacterList)
{
if (c.focusedCharacter == this) c.focusedCharacter = null;
if (c.selectedCharacter == this) c.selectedCharacter = null;
if (c.SelectedCharacter == this) c.SelectedCharacter = null;
}
}
partial void DisposeProjSpecific();

View File

@@ -193,7 +193,7 @@ namespace Barotrauma
SimPosition,
LastNetworkUpdateID,
AnimController.TargetDir,
selectedCharacter == null ? (Entity)selectedConstruction : (Entity)selectedCharacter,
SelectedCharacter == null ? (Entity)selectedConstruction : (Entity)SelectedCharacter,
AnimController.Anim);
memLocalState.Add(posInfo);
@@ -445,11 +445,11 @@ namespace Barotrauma
tempBuffer.Write(AnimController.TargetDir == Direction.Right);
}
if (selectedCharacter != null || selectedConstruction != null)
if (SelectedCharacter != null || selectedConstruction != null)
{
tempBuffer.Write(true);
tempBuffer.Write(selectedCharacter != null ? selectedCharacter.ID : selectedConstruction.ID);
if (selectedCharacter != null)
tempBuffer.Write(SelectedCharacter != null ? SelectedCharacter.ID : selectedConstruction.ID);
if (SelectedCharacter != null)
{
tempBuffer.Write(AnimController.Anim == AnimController.Animation.CPR);
}