(b522c4551) Don't assign the attackinglimb if we shouldn't be attacking. Fixes Hammerhead not falling back after hitting the sub.
This commit is contained in:
@@ -44,29 +44,25 @@ namespace Barotrauma
|
|||||||
return;
|
return;
|
||||||
}
|
}
|
||||||
|
|
||||||
if (character.MemState[0].SelectedCharacter == null || character.MemState[0].SelectedCharacter.Removed)
|
if (character.MemState[0].Interact == null || character.MemState[0].Interact.Removed)
|
||||||
{
|
{
|
||||||
character.DeselectCharacter();
|
character.DeselectCharacter();
|
||||||
}
|
|
||||||
else if (character.MemState[0].SelectedCharacter != null)
|
|
||||||
{
|
|
||||||
character.SelectCharacter(character.MemState[0].SelectedCharacter);
|
|
||||||
}
|
|
||||||
|
|
||||||
if (character.MemState[0].SelectedItem == null || character.MemState[0].SelectedItem.Removed)
|
|
||||||
{
|
|
||||||
character.SelectedConstruction = null;
|
character.SelectedConstruction = null;
|
||||||
}
|
}
|
||||||
else
|
else if (character.MemState[0].Interact is Character)
|
||||||
{
|
{
|
||||||
if (character.SelectedConstruction != character.MemState[0].SelectedItem)
|
character.SelectCharacter((Character)character.MemState[0].Interact);
|
||||||
|
}
|
||||||
|
else if (character.MemState[0].Interact is Item newSelectedConstruction)
|
||||||
|
{
|
||||||
|
if (newSelectedConstruction != null && character.SelectedConstruction != newSelectedConstruction)
|
||||||
{
|
{
|
||||||
foreach (var ic in character.MemState[0].SelectedItem.Components)
|
foreach (var ic in newSelectedConstruction.Components)
|
||||||
{
|
{
|
||||||
if (ic.CanBeSelected) ic.Select(character);
|
if (ic.CanBeSelected) ic.Select(character);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
character.SelectedConstruction = character.MemState[0].SelectedItem;
|
character.SelectedConstruction = newSelectedConstruction;
|
||||||
}
|
}
|
||||||
|
|
||||||
if (character.MemState[0].Animation == AnimController.Animation.CPR)
|
if (character.MemState[0].Animation == AnimController.Animation.CPR)
|
||||||
@@ -92,13 +88,13 @@ namespace Barotrauma
|
|||||||
Collider.AngularVelocity = newAngularVelocity;
|
Collider.AngularVelocity = newAngularVelocity;
|
||||||
|
|
||||||
float distSqrd = Vector2.DistanceSquared(newPosition, Collider.SimPosition);
|
float distSqrd = Vector2.DistanceSquared(newPosition, Collider.SimPosition);
|
||||||
float errorTolerance = character.AllowInput ? 0.01f : 0.2f;
|
float errorTolerance = character.AllowInput ? 0.01f : 0.1f;
|
||||||
if (distSqrd > errorTolerance)
|
if (distSqrd > errorTolerance)
|
||||||
{
|
{
|
||||||
if (distSqrd > 10.0f || !character.AllowInput)
|
if (distSqrd > 10.0f || !character.AllowInput)
|
||||||
{
|
{
|
||||||
Collider.TargetRotation = newRotation;
|
Collider.TargetRotation = newRotation;
|
||||||
SetPosition(newPosition, lerp: distSqrd < 5.0f);
|
SetPosition(newPosition, lerp: distSqrd < 1.0f);
|
||||||
}
|
}
|
||||||
else
|
else
|
||||||
{
|
{
|
||||||
@@ -112,15 +108,8 @@ namespace Barotrauma
|
|||||||
// -> we need to correct it manually
|
// -> we need to correct it manually
|
||||||
if (!character.AllowInput)
|
if (!character.AllowInput)
|
||||||
{
|
{
|
||||||
float mainLimbDistSqrd = Vector2.DistanceSquared(MainLimb.PullJointWorldAnchorA, Collider.SimPosition);
|
MainLimb.PullJointWorldAnchorB = Collider.SimPosition;
|
||||||
float mainLimbErrorTolerance = 0.1f;
|
MainLimb.PullJointEnabled = true;
|
||||||
//if the main limb is roughly at the correct position and the collider isn't moving (much at least),
|
|
||||||
//don't attempt to correct the position.
|
|
||||||
if (mainLimbDistSqrd > mainLimbErrorTolerance || Collider.LinearVelocity.LengthSquared() > 0.05f)
|
|
||||||
{
|
|
||||||
MainLimb.PullJointWorldAnchorB = Collider.SimPosition;
|
|
||||||
MainLimb.PullJointEnabled = true;
|
|
||||||
}
|
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
character.MemLocalState.Clear();
|
character.MemLocalState.Clear();
|
||||||
@@ -173,30 +162,25 @@ namespace Barotrauma
|
|||||||
CharacterStateInfo localPos = character.MemLocalState[localPosIndex];
|
CharacterStateInfo localPos = character.MemLocalState[localPosIndex];
|
||||||
|
|
||||||
//the entity we're interacting with doesn't match the server's
|
//the entity we're interacting with doesn't match the server's
|
||||||
if (localPos.SelectedCharacter != serverPos.SelectedCharacter)
|
if (localPos.Interact != serverPos.Interact)
|
||||||
{
|
{
|
||||||
if (serverPos.SelectedCharacter == null || serverPos.SelectedCharacter.Removed)
|
if (serverPos.Interact == null || serverPos.Interact.Removed)
|
||||||
{
|
{
|
||||||
character.DeselectCharacter();
|
character.DeselectCharacter();
|
||||||
}
|
|
||||||
else if (serverPos.SelectedCharacter != null)
|
|
||||||
{
|
|
||||||
character.SelectCharacter(serverPos.SelectedCharacter);
|
|
||||||
}
|
|
||||||
}
|
|
||||||
if (localPos.SelectedItem != serverPos.SelectedItem)
|
|
||||||
{
|
|
||||||
if (serverPos.SelectedItem == null || serverPos.SelectedItem.Removed)
|
|
||||||
{
|
|
||||||
character.SelectedConstruction = null;
|
character.SelectedConstruction = null;
|
||||||
}
|
}
|
||||||
else if (serverPos.SelectedItem != null)
|
else if (serverPos.Interact is Character)
|
||||||
{
|
{
|
||||||
if (character.SelectedConstruction != serverPos.SelectedItem)
|
character.SelectCharacter((Character)serverPos.Interact);
|
||||||
|
}
|
||||||
|
else
|
||||||
|
{
|
||||||
|
var newSelectedConstruction = (Item)serverPos.Interact;
|
||||||
|
if (newSelectedConstruction != null && character.SelectedConstruction != newSelectedConstruction)
|
||||||
{
|
{
|
||||||
serverPos.SelectedItem.TryInteract(character, true, true);
|
newSelectedConstruction.TryInteract(character, true, true);
|
||||||
}
|
}
|
||||||
character.SelectedConstruction = serverPos.SelectedItem;
|
character.SelectedConstruction = newSelectedConstruction;
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|||||||
@@ -30,13 +30,12 @@ namespace Barotrauma
|
|||||||
else
|
else
|
||||||
{
|
{
|
||||||
var posInfo = new CharacterStateInfo(
|
var posInfo = new CharacterStateInfo(
|
||||||
SimPosition,
|
SimPosition,
|
||||||
AnimController.Collider.Rotation,
|
AnimController.Collider.Rotation,
|
||||||
LastNetworkUpdateID,
|
LastNetworkUpdateID,
|
||||||
AnimController.TargetDir,
|
AnimController.TargetDir,
|
||||||
SelectedCharacter,
|
SelectedCharacter == null ? (Entity)SelectedConstruction : (Entity)SelectedCharacter,
|
||||||
SelectedConstruction,
|
AnimController.Anim);
|
||||||
AnimController.Anim);
|
|
||||||
|
|
||||||
memLocalState.Add(posInfo);
|
memLocalState.Add(posInfo);
|
||||||
|
|
||||||
@@ -215,7 +214,6 @@ namespace Barotrauma
|
|||||||
Vector2 linearVelocity = new Vector2(
|
Vector2 linearVelocity = new Vector2(
|
||||||
msg.ReadRangedSingle(-MaxVel, MaxVel, 12),
|
msg.ReadRangedSingle(-MaxVel, MaxVel, 12),
|
||||||
msg.ReadRangedSingle(-MaxVel, MaxVel, 12));
|
msg.ReadRangedSingle(-MaxVel, MaxVel, 12));
|
||||||
linearVelocity = NetConfig.Quantize(linearVelocity, -MaxVel, MaxVel, 12);
|
|
||||||
|
|
||||||
bool fixedRotation = msg.ReadBoolean();
|
bool fixedRotation = msg.ReadBoolean();
|
||||||
float? rotation = null;
|
float? rotation = null;
|
||||||
@@ -225,7 +223,6 @@ namespace Barotrauma
|
|||||||
rotation = msg.ReadFloat();
|
rotation = msg.ReadFloat();
|
||||||
float MaxAngularVel = NetConfig.MaxPhysicsBodyAngularVelocity;
|
float MaxAngularVel = NetConfig.MaxPhysicsBodyAngularVelocity;
|
||||||
angularVelocity = msg.ReadRangedSingle(-MaxAngularVel, MaxAngularVel, 8);
|
angularVelocity = msg.ReadRangedSingle(-MaxAngularVel, MaxAngularVel, 8);
|
||||||
angularVelocity = NetConfig.Quantize(angularVelocity.Value, -MaxAngularVel, MaxAngularVel, 8);
|
|
||||||
}
|
}
|
||||||
|
|
||||||
bool readStatus = msg.ReadBoolean();
|
bool readStatus = msg.ReadBoolean();
|
||||||
@@ -239,11 +236,7 @@ namespace Barotrauma
|
|||||||
int index = 0;
|
int index = 0;
|
||||||
if (GameMain.Client.Character == this && AllowInput)
|
if (GameMain.Client.Character == this && AllowInput)
|
||||||
{
|
{
|
||||||
var posInfo = new CharacterStateInfo(
|
var posInfo = new CharacterStateInfo(pos, rotation, networkUpdateID, facingRight ? Direction.Right : Direction.Left, selectedEntity, animation);
|
||||||
pos, rotation,
|
|
||||||
networkUpdateID,
|
|
||||||
facingRight ? Direction.Right : Direction.Left,
|
|
||||||
selectedCharacter, selectedItem, animation);
|
|
||||||
|
|
||||||
while (index < memState.Count && NetIdUtils.IdMoreRecent(posInfo.ID, memState[index].ID))
|
while (index < memState.Count && NetIdUtils.IdMoreRecent(posInfo.ID, memState[index].ID))
|
||||||
index++;
|
index++;
|
||||||
@@ -251,11 +244,7 @@ namespace Barotrauma
|
|||||||
}
|
}
|
||||||
else
|
else
|
||||||
{
|
{
|
||||||
var posInfo = new CharacterStateInfo(
|
var posInfo = new CharacterStateInfo(pos, rotation, linearVelocity, angularVelocity, sendingTime, facingRight ? Direction.Right : Direction.Left, selectedEntity, animation);
|
||||||
pos, rotation,
|
|
||||||
linearVelocity, angularVelocity,
|
|
||||||
sendingTime, facingRight ? Direction.Right : Direction.Left,
|
|
||||||
selectedCharacter, selectedItem, animation);
|
|
||||||
|
|
||||||
while (index < memState.Count && posInfo.Timestamp > memState[index].Timestamp)
|
while (index < memState.Count && posInfo.Timestamp > memState[index].Timestamp)
|
||||||
index++;
|
index++;
|
||||||
|
|||||||
@@ -656,13 +656,6 @@ namespace Barotrauma
|
|||||||
msg.Timer -= deltaTime;
|
msg.Timer -= deltaTime;
|
||||||
msg.Pos += msg.Velocity * deltaTime;
|
msg.Pos += msg.Velocity * deltaTime;
|
||||||
}
|
}
|
||||||
|
|
||||||
foreach (GUIMessage msg in messages)
|
|
||||||
{
|
|
||||||
if (!msg.WorldSpace) continue;
|
|
||||||
msg.Timer -= deltaTime;
|
|
||||||
msg.Pos += msg.Velocity * deltaTime;
|
|
||||||
}
|
|
||||||
}
|
}
|
||||||
|
|
||||||
messages.RemoveAll(m => m.Timer <= 0.0f);
|
messages.RemoveAll(m => m.Timer <= 0.0f);
|
||||||
|
|||||||
@@ -171,12 +171,9 @@ namespace Barotrauma
|
|||||||
newVelocity = new Vector2(
|
newVelocity = new Vector2(
|
||||||
msg.ReadRangedSingle(-MaxVel, MaxVel, 12),
|
msg.ReadRangedSingle(-MaxVel, MaxVel, 12),
|
||||||
msg.ReadRangedSingle(-MaxVel, MaxVel, 12));
|
msg.ReadRangedSingle(-MaxVel, MaxVel, 12));
|
||||||
newVelocity = NetConfig.Quantize(newVelocity, -MaxVel, MaxVel, 12);
|
|
||||||
|
|
||||||
if (!fixedRotation)
|
if (!fixedRotation)
|
||||||
{
|
{
|
||||||
newAngularVelocity = msg.ReadRangedSingle(-MaxAngularVel, MaxAngularVel, 8);
|
newAngularVelocity = msg.ReadRangedSingle(-MaxAngularVel, MaxAngularVel, 8);
|
||||||
newAngularVelocity = NetConfig.Quantize(newAngularVelocity.Value, -MaxAngularVel, MaxAngularVel, 8);
|
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
msg.ReadPadBits();
|
msg.ReadPadBits();
|
||||||
|
|||||||
@@ -362,8 +362,7 @@ namespace Barotrauma
|
|||||||
if (SelectedCharacter != null || SelectedConstruction != null)
|
if (SelectedCharacter != null || SelectedConstruction != null)
|
||||||
{
|
{
|
||||||
tempBuffer.Write(true);
|
tempBuffer.Write(true);
|
||||||
tempBuffer.Write(SelectedCharacter != null ? SelectedCharacter.ID : NullEntityID);
|
tempBuffer.Write(SelectedCharacter != null ? SelectedCharacter.ID : SelectedConstruction.ID);
|
||||||
tempBuffer.Write(SelectedConstruction != null ? SelectedConstruction.ID : NullEntityID);
|
|
||||||
if (SelectedCharacter != null)
|
if (SelectedCharacter != null)
|
||||||
{
|
{
|
||||||
tempBuffer.Write(AnimController.Anim == AnimController.Animation.CPR);
|
tempBuffer.Write(AnimController.Anim == AnimController.Animation.CPR);
|
||||||
@@ -377,9 +376,8 @@ namespace Barotrauma
|
|||||||
tempBuffer.Write(SimPosition.X);
|
tempBuffer.Write(SimPosition.X);
|
||||||
tempBuffer.Write(SimPosition.Y);
|
tempBuffer.Write(SimPosition.Y);
|
||||||
float MaxVel = NetConfig.MaxPhysicsBodyVelocity;
|
float MaxVel = NetConfig.MaxPhysicsBodyVelocity;
|
||||||
AnimController.Collider.LinearVelocity = NetConfig.Quantize(AnimController.Collider.LinearVelocity, -MaxVel, MaxVel, 12);
|
tempBuffer.WriteRangedSingle(MathHelper.Clamp(AnimController.Collider.LinearVelocity.X, -MaxVel, MaxVel), -MaxVel, MaxVel, 12);
|
||||||
tempBuffer.WriteRangedSingle(AnimController.Collider.LinearVelocity.X, -MaxVel, MaxVel, 12);
|
tempBuffer.WriteRangedSingle(MathHelper.Clamp(AnimController.Collider.LinearVelocity.Y, -MaxVel, MaxVel), -MaxVel, MaxVel, 12);
|
||||||
tempBuffer.WriteRangedSingle(AnimController.Collider.LinearVelocity.Y, -MaxVel, MaxVel, 12);
|
|
||||||
|
|
||||||
bool fixedRotation = AnimController.Collider.FarseerBody.FixedRotation;
|
bool fixedRotation = AnimController.Collider.FarseerBody.FixedRotation;
|
||||||
tempBuffer.Write(fixedRotation);
|
tempBuffer.Write(fixedRotation);
|
||||||
@@ -387,7 +385,6 @@ namespace Barotrauma
|
|||||||
{
|
{
|
||||||
tempBuffer.Write(AnimController.Collider.Rotation);
|
tempBuffer.Write(AnimController.Collider.Rotation);
|
||||||
float MaxAngularVel = NetConfig.MaxPhysicsBodyAngularVelocity;
|
float MaxAngularVel = NetConfig.MaxPhysicsBodyAngularVelocity;
|
||||||
AnimController.Collider.AngularVelocity = NetConfig.Quantize(AnimController.Collider.AngularVelocity, -MaxAngularVel, MaxAngularVel, 8);
|
|
||||||
tempBuffer.WriteRangedSingle(MathHelper.Clamp(AnimController.Collider.AngularVelocity, -MaxAngularVel, MaxAngularVel), -MaxAngularVel, MaxAngularVel, 8);
|
tempBuffer.WriteRangedSingle(MathHelper.Clamp(AnimController.Collider.AngularVelocity, -MaxAngularVel, MaxAngularVel), -MaxAngularVel, MaxAngularVel, 8);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|||||||
@@ -1,7 +1,11 @@
|
|||||||
using Barotrauma.Networking;
|
using System;
|
||||||
|
using System.Collections.Generic;
|
||||||
|
using System.Linq;
|
||||||
|
using System.Text;
|
||||||
|
using System.Threading.Tasks;
|
||||||
|
using Barotrauma.Networking;
|
||||||
using Lidgren.Network;
|
using Lidgren.Network;
|
||||||
using Microsoft.Xna.Framework;
|
using Microsoft.Xna.Framework;
|
||||||
using System;
|
|
||||||
|
|
||||||
namespace Barotrauma
|
namespace Barotrauma
|
||||||
{
|
{
|
||||||
@@ -33,12 +37,10 @@ namespace Barotrauma
|
|||||||
if (FarseerBody.Awake)
|
if (FarseerBody.Awake)
|
||||||
{
|
{
|
||||||
body.Enabled = true;
|
body.Enabled = true;
|
||||||
body.LinearVelocity = NetConfig.Quantize(body.LinearVelocity, -MaxVel, MaxVel, 12);
|
msg.WriteRangedSingle(MathHelper.Clamp(body.LinearVelocity.X, -MaxVel, MaxVel), -MaxVel, MaxVel, 12);
|
||||||
msg.WriteRangedSingle(body.LinearVelocity.X, -MaxVel, MaxVel, 12);
|
msg.WriteRangedSingle(MathHelper.Clamp(body.LinearVelocity.Y, -MaxVel, MaxVel), -MaxVel, MaxVel, 12);
|
||||||
msg.WriteRangedSingle(body.LinearVelocity.Y, -MaxVel, MaxVel, 12);
|
|
||||||
if (!FarseerBody.FixedRotation)
|
if (!FarseerBody.FixedRotation)
|
||||||
{
|
{
|
||||||
body.AngularVelocity = NetConfig.Quantize(body.AngularVelocity, -MaxAngularVel, MaxAngularVel, 8);
|
|
||||||
msg.WriteRangedSingle(MathHelper.Clamp(body.AngularVelocity, -MaxAngularVel, MaxAngularVel), -MaxAngularVel, MaxAngularVel, 8);
|
msg.WriteRangedSingle(MathHelper.Clamp(body.AngularVelocity, -MaxAngularVel, MaxAngularVel), -MaxAngularVel, MaxAngularVel, 8);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|||||||
@@ -705,16 +705,15 @@ namespace Barotrauma
|
|||||||
default:
|
default:
|
||||||
UpdateFallBack(attackWorldPos, deltaTime);
|
UpdateFallBack(attackWorldPos, deltaTime);
|
||||||
return;
|
return;
|
||||||
|
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
if (AttackingLimb == null || _previousAiTarget != SelectedAiTarget)
|
|
||||||
{
|
|
||||||
AttackingLimb = GetAttackLimb(attackWorldPos);
|
|
||||||
}
|
|
||||||
if (canAttack)
|
if (canAttack)
|
||||||
{
|
{
|
||||||
|
if (AttackingLimb == null || _previousAiTarget != SelectedAiTarget)
|
||||||
|
{
|
||||||
|
AttackingLimb = GetAttackLimb(attackWorldPos);
|
||||||
|
}
|
||||||
canAttack = AttackingLimb != null && AttackingLimb.attack.CoolDownTimer <= 0;
|
canAttack = AttackingLimb != null && AttackingLimb.attack.CoolDownTimer <= 0;
|
||||||
}
|
}
|
||||||
float distance = 0;
|
float distance = 0;
|
||||||
@@ -1233,11 +1232,52 @@ namespace Barotrauma
|
|||||||
valueModifier = isOutdoor ? 1 : 0;
|
valueModifier = isOutdoor ? 1 : 0;
|
||||||
valueModifier *= isOpen ? 5 : 1;
|
valueModifier *= isOpen ? 5 : 1;
|
||||||
}
|
}
|
||||||
|
}
|
||||||
|
else
|
||||||
|
{
|
||||||
|
// Ignore disabled walls
|
||||||
|
bool isDisabled = true;
|
||||||
for (int i = 0; i < s.Sections.Length; i++)
|
for (int i = 0; i < s.Sections.Length; i++)
|
||||||
{
|
{
|
||||||
valueModifier = isOutdoor ? 0 : 1;
|
valueModifier = isOutdoor ? 0 : 1;
|
||||||
valueModifier *= isOpen ? 0 : 1;
|
valueModifier *= isOpen ? 0 : 1;
|
||||||
}
|
}
|
||||||
|
if (isDisabled)
|
||||||
|
{
|
||||||
|
valueModifier = 0;
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
||||||
|
else
|
||||||
|
{
|
||||||
|
targetingTag = "room";
|
||||||
|
}
|
||||||
|
if (door != null)
|
||||||
|
{
|
||||||
|
// If there's not a more specific tag for the door
|
||||||
|
if (string.IsNullOrEmpty(targetingTag) || targetingTag == "room")
|
||||||
|
{
|
||||||
|
targetingTag = "door";
|
||||||
|
}
|
||||||
|
bool isOutdoor = door.LinkedGap?.FlowTargetHull != null && !door.LinkedGap.IsRoomToRoom;
|
||||||
|
bool isOpen = door.IsOpen || door.Item.Condition <= 0.0f;
|
||||||
|
//increase priority if the character is outside and an aggressive boarder, and the door is from outside to inside
|
||||||
|
if (aggressiveBoarding)
|
||||||
|
{
|
||||||
|
if (character.CurrentHull == null)
|
||||||
|
{
|
||||||
|
valueModifier = isOutdoor ? 1 : 0;
|
||||||
|
valueModifier *= isOpen ? 5 : 1;
|
||||||
|
}
|
||||||
|
for (int i = 0; i < s.Sections.Length; i++)
|
||||||
|
{
|
||||||
|
valueModifier = isOutdoor ? 0 : 1;
|
||||||
|
valueModifier *= isOpen ? 0 : 1;
|
||||||
|
}
|
||||||
|
}
|
||||||
|
else if (isOpen) //ignore broken and open doors
|
||||||
|
{
|
||||||
|
continue;
|
||||||
}
|
}
|
||||||
else if (isOpen) //ignore broken and open doors
|
else if (isOpen) //ignore broken and open doors
|
||||||
{
|
{
|
||||||
|
|||||||
@@ -14,17 +14,17 @@ namespace Barotrauma
|
|||||||
|
|
||||||
public readonly AnimController.Animation Animation;
|
public readonly AnimController.Animation Animation;
|
||||||
|
|
||||||
public CharacterStateInfo(Vector2 pos, float? rotation, Vector2 velocity, float? angularVelocity, float time, Direction dir, Character selectedCharacter, Item selectedItem, AnimController.Animation animation = AnimController.Animation.None)
|
public CharacterStateInfo(Vector2 pos, float? rotation, Vector2 velocity, float? angularVelocity, float time, Direction dir, Entity interact, AnimController.Animation animation = AnimController.Animation.None)
|
||||||
: this(pos, rotation, velocity, angularVelocity, 0, time, dir, selectedCharacter, selectedItem, animation)
|
: this(pos, rotation, velocity, angularVelocity, 0, time, dir, interact, animation)
|
||||||
{
|
{
|
||||||
}
|
}
|
||||||
|
|
||||||
public CharacterStateInfo(Vector2 pos, float? rotation, UInt16 ID, Direction dir, Character selectedCharacter, Item selectedItem, AnimController.Animation animation = AnimController.Animation.None)
|
public CharacterStateInfo(Vector2 pos, float? rotation, UInt16 ID, Direction dir, Entity interact, AnimController.Animation animation = AnimController.Animation.None)
|
||||||
: this(pos, rotation, Vector2.Zero, 0.0f, ID, 0.0f, dir, selectedCharacter, selectedItem, animation)
|
: this(pos, rotation, Vector2.Zero, 0.0f, ID, 0.0f, dir, interact, animation)
|
||||||
{
|
{
|
||||||
}
|
}
|
||||||
|
|
||||||
protected CharacterStateInfo(Vector2 pos, float? rotation, Vector2 velocity, float? angularVelocity, UInt16 ID, float time, Direction dir, Character selectedCharacter, Item selectedItem, AnimController.Animation animation = AnimController.Animation.None)
|
protected CharacterStateInfo(Vector2 pos, float? rotation, Vector2 velocity, float? angularVelocity, UInt16 ID, float time, Direction dir, Entity interact, AnimController.Animation animation = AnimController.Animation.None)
|
||||||
: base(pos, rotation, velocity, angularVelocity, ID, time)
|
: base(pos, rotation, velocity, angularVelocity, ID, time)
|
||||||
{
|
{
|
||||||
Direction = dir;
|
Direction = dir;
|
||||||
|
|||||||
@@ -1016,6 +1016,39 @@ namespace Barotrauma
|
|||||||
|
|
||||||
AllowedLinks = element.GetAttributeStringArray("allowedlinks", new string[0], convertToLowerInvariant: true).ToList();
|
AllowedLinks = element.GetAttributeStringArray("allowedlinks", new string[0], convertToLowerInvariant: true).ToList();
|
||||||
|
|
||||||
|
if (sprite == null)
|
||||||
|
{
|
||||||
|
DebugConsole.ThrowError("Item \"" + Name + "\" has no sprite!");
|
||||||
|
#if SERVER
|
||||||
|
sprite = new Sprite("", Vector2.Zero);
|
||||||
|
sprite.SourceRect = new Rectangle(0, 0, 32, 32);
|
||||||
|
#else
|
||||||
|
sprite = new Sprite(TextureLoader.PlaceHolderTexture, null, null)
|
||||||
|
{
|
||||||
|
Origin = TextureLoader.PlaceHolderTexture.Bounds.Size.ToVector2() / 2
|
||||||
|
};
|
||||||
|
#endif
|
||||||
|
size = sprite.size;
|
||||||
|
sprite.EntityID = identifier;
|
||||||
|
}
|
||||||
|
|
||||||
|
if (!category.HasFlag(MapEntityCategory.Legacy) && string.IsNullOrEmpty(identifier))
|
||||||
|
{
|
||||||
|
DebugConsole.ThrowError(
|
||||||
|
"Item prefab \"" + name + "\" has no identifier. All item prefabs have a unique identifier string that's used to differentiate between items during saving and loading.");
|
||||||
|
}
|
||||||
|
if (!string.IsNullOrEmpty(identifier))
|
||||||
|
{
|
||||||
|
MapEntityPrefab existingPrefab = List.Find(e => e.Identifier == identifier);
|
||||||
|
if (existingPrefab != null)
|
||||||
|
{
|
||||||
|
DebugConsole.ThrowError(
|
||||||
|
"Map entity prefabs \"" + name + "\" and \"" + existingPrefab.Name + "\" have the same identifier!");
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
AllowedLinks = element.GetAttributeStringArray("allowedlinks", new string[0], convertToLowerInvariant: true).ToList();
|
||||||
|
|
||||||
List.Add(this);
|
List.Add(this);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|||||||
@@ -74,23 +74,5 @@ namespace Barotrauma.Networking
|
|||||||
if (lengthSqr > 1000.0f) { return Vector2.Zero; }
|
if (lengthSqr > 1000.0f) { return Vector2.Zero; }
|
||||||
return cursorPositionError *= 0.7f;
|
return cursorPositionError *= 0.7f;
|
||||||
}
|
}
|
||||||
|
|
||||||
public static Vector2 Quantize(Vector2 value, float min, float max, int numberOfBits)
|
|
||||||
{
|
|
||||||
return new Vector2(
|
|
||||||
Quantize(value.X, min, max, numberOfBits),
|
|
||||||
Quantize(value.Y, min, max, numberOfBits));
|
|
||||||
}
|
|
||||||
|
|
||||||
public static float Quantize(float value, float min, float max, int numberOfBits)
|
|
||||||
{
|
|
||||||
float step = (max - min) / (1 << (numberOfBits + 1));
|
|
||||||
if (Math.Abs(value) < step + 0.00001f)
|
|
||||||
{
|
|
||||||
return 0.0f;
|
|
||||||
}
|
|
||||||
|
|
||||||
return MathUtils.RoundTowardsClosest(MathHelper.Clamp(value, min, max), step);
|
|
||||||
}
|
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|||||||
Reference in New Issue
Block a user