Merge remote-tracking branch 'origin/master' into moRags
This commit is contained in:
@@ -154,6 +154,8 @@ namespace Barotrauma
|
||||
}
|
||||
}
|
||||
|
||||
if (character.SelectedCharacter != null) DragCharacter(character.SelectedCharacter);
|
||||
|
||||
if (!flip) return;
|
||||
|
||||
flipTimer += deltaTime;
|
||||
@@ -169,6 +171,79 @@ namespace Barotrauma
|
||||
}
|
||||
}
|
||||
|
||||
private float eatTimer = 0.0f;
|
||||
|
||||
public override void DragCharacter(Character target)
|
||||
{
|
||||
if (target == null) return;
|
||||
|
||||
Limb mouthLimb = Array.Find(Limbs, l => l != null && l.MouthPos.HasValue);
|
||||
if (mouthLimb == null) mouthLimb = GetLimb(LimbType.Head);
|
||||
|
||||
if (mouthLimb == null)
|
||||
{
|
||||
DebugConsole.ThrowError("Character \"" + character.SpeciesName + "\" failed to eat a target (a head or a limb with a mouthpos required)");
|
||||
return;
|
||||
}
|
||||
|
||||
Character targetCharacter = target;
|
||||
float eatSpeed = character.Mass / targetCharacter.Mass * 0.1f;
|
||||
|
||||
eatTimer += (float)Timing.Step * eatSpeed;
|
||||
|
||||
Vector2 mouthPos = mouthLimb.SimPosition;
|
||||
if (mouthLimb.MouthPos.HasValue)
|
||||
{
|
||||
float cos = (float)Math.Cos(mouthLimb.Rotation);
|
||||
float sin = (float)Math.Sin(mouthLimb.Rotation);
|
||||
|
||||
mouthPos += new Vector2(
|
||||
mouthLimb.MouthPos.Value.X * cos - mouthLimb.MouthPos.Value.Y * sin,
|
||||
mouthLimb.MouthPos.Value.X * sin + mouthLimb.MouthPos.Value.Y * cos);
|
||||
}
|
||||
|
||||
Vector2 attackSimPosition = character.Submarine == null ? ConvertUnits.ToSimUnits(target.WorldPosition) : target.SimPosition;
|
||||
|
||||
Vector2 limbDiff = attackSimPosition - mouthPos;
|
||||
float limbDist = limbDiff.Length();
|
||||
if (limbDist < 1.0f)
|
||||
{
|
||||
//pull the target character to the position of the mouth
|
||||
//(+ make the force fluctuate to waggle the character a bit)
|
||||
targetCharacter.AnimController.MainLimb.MoveToPos(mouthPos, (float)(Math.Sin(eatTimer) + 10.0f));
|
||||
targetCharacter.AnimController.MainLimb.body.SmoothRotate(mouthLimb.Rotation);
|
||||
targetCharacter.AnimController.Collider.MoveToPos(mouthPos, (float)(Math.Sin(eatTimer) + 10.0f));
|
||||
|
||||
//pull the character's mouth to the target character (again with a fluctuating force)
|
||||
float pullStrength = (float)(Math.Sin(eatTimer) * Math.Max(Math.Sin(eatTimer * 0.5f), 0.0f));
|
||||
mouthLimb.body.ApplyForce(limbDiff * mouthLimb.Mass * 50.0f * pullStrength);
|
||||
|
||||
if (eatTimer % 1.0f < 0.5f && (eatTimer - (float)Timing.Step * eatSpeed) % 1.0f > 0.5f)
|
||||
{
|
||||
//apply damage to the target character to get some blood particles flying
|
||||
targetCharacter.AnimController.MainLimb.AddDamage(targetCharacter.SimPosition, DamageType.None, Rand.Range(10.0f, 25.0f), 10.0f, false);
|
||||
|
||||
//keep severing joints until there is only one limb left
|
||||
LimbJoint[] nonSeveredJoints = Array.FindAll(targetCharacter.AnimController.LimbJoints, l => !l.IsSevered && l.CanBeSevered);
|
||||
if (nonSeveredJoints.Length == 0)
|
||||
{
|
||||
//only one limb left, the character is now full eaten
|
||||
Entity.Spawner.AddToRemoveQueue(targetCharacter);
|
||||
character.SelectedCharacter = null;
|
||||
character.Health += 10.0f;
|
||||
}
|
||||
else //sever a random joint
|
||||
{
|
||||
targetCharacter.AnimController.SeverLimbJoint(nonSeveredJoints[Rand.Int(nonSeveredJoints.Length)]);
|
||||
}
|
||||
}
|
||||
}
|
||||
else
|
||||
{
|
||||
character.SelectedCharacter = null;
|
||||
}
|
||||
}
|
||||
|
||||
void UpdateSineAnim(float deltaTime)
|
||||
{
|
||||
movement = TargetMovement*swimSpeed;
|
||||
|
||||
@@ -175,7 +175,7 @@ namespace Barotrauma
|
||||
{
|
||||
get { return !IsUnconscious && Stun <= 0.0f && !isDead; }
|
||||
}
|
||||
|
||||
|
||||
public bool CanInteract
|
||||
{
|
||||
get { return AllowInput && IsHumanoid && !LockHands; }
|
||||
@@ -206,6 +206,7 @@ namespace Barotrauma
|
||||
get { return selectedCharacter; }
|
||||
set
|
||||
{
|
||||
if (value == selectedCharacter) return;
|
||||
if (selectedCharacter != null)
|
||||
selectedCharacter.selectedBy = null;
|
||||
selectedCharacter = value;
|
||||
@@ -303,7 +304,7 @@ namespace Barotrauma
|
||||
private float stunTimer;
|
||||
public float Stun
|
||||
{
|
||||
get { return stunTimer; }
|
||||
get { return IsRagdolled ? 1.0f : stunTimer; }
|
||||
set
|
||||
{
|
||||
if (GameMain.Client != null) return;
|
||||
@@ -686,7 +687,7 @@ namespace Barotrauma
|
||||
case InputType.Use:
|
||||
return !(dequeuedInput.HasFlag(InputNetFlags.Use)) && (prevDequeuedInput.HasFlag(InputNetFlags.Use));
|
||||
case InputType.Ragdoll:
|
||||
return !(dequeuedInput.HasFlag(InputType.Ragdoll)) && (prevDequeuedInput.HasFlag(InputType.Ragdoll));
|
||||
return !(dequeuedInput.HasFlag(InputNetFlags.Ragdoll)) && (prevDequeuedInput.HasFlag(InputNetFlags.Ragdoll));
|
||||
default:
|
||||
return false;
|
||||
}
|
||||
@@ -1030,7 +1031,7 @@ namespace Barotrauma
|
||||
|
||||
public bool CanInteractWith(Character c, float maxDist = 200.0f)
|
||||
{
|
||||
if (c == this || !c.Enabled || c.info == null || !c.IsHumanoid || !c.CanBeSelected) return false;
|
||||
if (c == this || !c.Enabled || !c.IsHumanoid || !c.CanBeSelected) return false;
|
||||
|
||||
maxDist = ConvertUnits.ToSimUnits(maxDist);
|
||||
if (Vector2.DistanceSquared(SimPosition, c.SimPosition) > maxDist * maxDist) return false;
|
||||
@@ -1058,6 +1059,9 @@ namespace Barotrauma
|
||||
Wire wire = item.GetComponent<Wire>();
|
||||
if (wire != null)
|
||||
{
|
||||
//locked wires are never interactable
|
||||
if (wire.Locked) return false;
|
||||
|
||||
//wires are interactable if the character has selected either of the items the wire is connected to
|
||||
if (wire.Connections[0]?.Item != null && selectedConstruction == wire.Connections[0].Item) return true;
|
||||
if (wire.Connections[1]?.Item != null && selectedConstruction == wire.Connections[1].Item) return true;
|
||||
@@ -1242,7 +1246,7 @@ namespace Barotrauma
|
||||
public void SelectCharacter(Character character)
|
||||
{
|
||||
if (character == null) return;
|
||||
|
||||
|
||||
SelectedCharacter = character;
|
||||
}
|
||||
|
||||
@@ -1264,27 +1268,27 @@ namespace Barotrauma
|
||||
public void DoInteractionUpdate(float deltaTime, Vector2 mouseSimPos)
|
||||
{
|
||||
bool isLocalPlayer = (controlled == this);
|
||||
if (!isLocalPlayer && (this is AICharacter || !IsRemotePlayer))
|
||||
if (!isLocalPlayer && (this is AICharacter && !IsRemotePlayer))
|
||||
{
|
||||
return;
|
||||
}
|
||||
|
||||
if (!CanInteract)
|
||||
{
|
||||
if (SelectedCharacter != null)
|
||||
{
|
||||
DeselectCharacter();
|
||||
}
|
||||
selectedConstruction = null;
|
||||
focusedItem = null;
|
||||
focusedCharacter = null;
|
||||
return;
|
||||
if (!AllowInput)
|
||||
{
|
||||
focusedCharacter = null;
|
||||
if (SelectedCharacter != null) DeselectCharacter();
|
||||
return;
|
||||
}
|
||||
}
|
||||
if ((!isLocalPlayer && IsKeyHit(InputType.Select) && GameMain.Server == null) ||
|
||||
(isLocalPlayer && (findFocusedTimer <= 0.0f || Screen.Selected == GameMain.SubEditorScreen)))
|
||||
{
|
||||
focusedCharacter = FindCharacterAtPosition(mouseSimPos);
|
||||
focusedItem = FindItemAtPosition(mouseSimPos, AnimController.InWater ? 0.5f : 0.25f);
|
||||
focusedItem = CanInteract ? FindItemAtPosition(mouseSimPos, AnimController.InWater ? 0.5f : 0.25f) : null;
|
||||
|
||||
if (focusedCharacter != null && focusedItem != null)
|
||||
{
|
||||
@@ -1303,7 +1307,7 @@ namespace Barotrauma
|
||||
{
|
||||
findFocusedTimer -= deltaTime;
|
||||
}
|
||||
|
||||
|
||||
if (SelectedCharacter != null && IsKeyHit(InputType.Select))
|
||||
{
|
||||
DeselectCharacter();
|
||||
@@ -1448,7 +1452,7 @@ namespace Barotrauma
|
||||
|
||||
UpdateControlled(deltaTime, cam);
|
||||
|
||||
if (Stun > 0.0f)
|
||||
if (stunTimer > 0.0f)
|
||||
{
|
||||
stunTimer -= deltaTime;
|
||||
if (stunTimer < 0.0f && GameMain.Server != null)
|
||||
@@ -1471,8 +1475,7 @@ namespace Barotrauma
|
||||
|
||||
if (IsRagdolled)
|
||||
{
|
||||
((HumanoidAnimController)AnimController).Crouching = false;
|
||||
Stun = Math.Max(0.1f, Stun);
|
||||
if (AnimController is HumanoidAnimController) ((HumanoidAnimController)AnimController).Crouching = false;
|
||||
|
||||
AnimController.ResetPullJoints();
|
||||
selectedConstruction = null;
|
||||
|
||||
@@ -128,6 +128,12 @@ namespace Barotrauma
|
||||
if (!AllowInput)
|
||||
{
|
||||
AnimController.Frozen = false;
|
||||
if (memInput.Count > 0)
|
||||
{
|
||||
prevDequeuedInput = dequeuedInput;
|
||||
dequeuedInput = memInput[memInput.Count - 1].states;
|
||||
memInput.RemoveAt(memInput.Count - 1);
|
||||
}
|
||||
}
|
||||
else if (memInput.Count == 0)
|
||||
{
|
||||
@@ -289,20 +295,20 @@ namespace Barotrauma
|
||||
newInteract = msg.ReadUInt16();
|
||||
}
|
||||
|
||||
if (AllowInput)
|
||||
//if (AllowInput)
|
||||
//{
|
||||
if (NetIdUtils.IdMoreRecent((ushort)(networkUpdateID - i), LastNetworkUpdateID) && (i < 60))
|
||||
{
|
||||
if (NetIdUtils.IdMoreRecent((ushort)(networkUpdateID - i), LastNetworkUpdateID) && (i < 60))
|
||||
{
|
||||
NetInputMem newMem = new NetInputMem();
|
||||
newMem.states = newInput;
|
||||
newMem.intAim = newAim;
|
||||
newMem.interact = newInteract;
|
||||
NetInputMem newMem = new NetInputMem();
|
||||
newMem.states = newInput;
|
||||
newMem.intAim = newAim;
|
||||
newMem.interact = newInteract;
|
||||
|
||||
newMem.networkUpdateID = (ushort)(networkUpdateID - i);
|
||||
newMem.networkUpdateID = (ushort)(networkUpdateID - i);
|
||||
|
||||
memInput.Insert(i, newMem);
|
||||
}
|
||||
memInput.Insert(i, newMem);
|
||||
}
|
||||
//}
|
||||
}
|
||||
|
||||
if (NetIdUtils.IdMoreRecent(networkUpdateID, LastNetworkUpdateID))
|
||||
|
||||
@@ -212,6 +212,14 @@ namespace Barotrauma.Items.Components
|
||||
//existing wire not in the list of new wires -> disconnect it
|
||||
if (!wires[i].Contains(existingWire))
|
||||
{
|
||||
if (existingWire.Locked)
|
||||
{
|
||||
//this should not be possible unless the client is running a modified version of the game
|
||||
GameServer.Log(c.Character.Name + " attempted to disconnect a locked wire from " +
|
||||
Connections[i].Item.Name + " (" + Connections[i].Name + ")", ServerLog.MessageType.Error);
|
||||
continue;
|
||||
}
|
||||
|
||||
existingWire.RemoveConnection(item);
|
||||
|
||||
if (existingWire.Connections[0] == null && existingWire.Connections[1] == null)
|
||||
|
||||
@@ -4,12 +4,6 @@ namespace Barotrauma.Items.Components
|
||||
{
|
||||
partial class StatusHUD : ItemComponent
|
||||
{
|
||||
private static readonly string[] BleedingTexts = {"Minor bleeding", "Bleeding", "Bleeding heavily", "Catastrophic Bleeding"};
|
||||
|
||||
private static readonly string[] HealthTexts = { "No visible injuries", "Minor injuries", "Injured", "Major injuries", "Critically injured" };
|
||||
|
||||
private static readonly string[] OxygenTexts = { "Oxygen level normal", "Gasping for air", "Signs of oxygen deprivation", "Not breathing" };
|
||||
|
||||
public StatusHUD(Item item, XElement element)
|
||||
: base(item, element)
|
||||
{
|
||||
|
||||
Reference in New Issue
Block a user