(45f083a5a) Merge branch 'dev' of https://github.com/Regalis11/Barotrauma-development into dev
This commit is contained in:
@@ -44,25 +44,29 @@ namespace Barotrauma
|
||||
return;
|
||||
}
|
||||
|
||||
if (character.MemState[0].Interact == null || character.MemState[0].Interact.Removed)
|
||||
if (character.MemState[0].SelectedCharacter == null || character.MemState[0].SelectedCharacter.Removed)
|
||||
{
|
||||
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;
|
||||
}
|
||||
else if (character.MemState[0].Interact is Character)
|
||||
else
|
||||
{
|
||||
character.SelectCharacter((Character)character.MemState[0].Interact);
|
||||
}
|
||||
else if (character.MemState[0].Interact is Item newSelectedConstruction)
|
||||
{
|
||||
if (newSelectedConstruction != null && character.SelectedConstruction != newSelectedConstruction)
|
||||
if (character.SelectedConstruction != character.MemState[0].SelectedItem)
|
||||
{
|
||||
foreach (var ic in newSelectedConstruction.Components)
|
||||
foreach (var ic in character.MemState[0].SelectedItem.Components)
|
||||
{
|
||||
if (ic.CanBeSelected) ic.Select(character);
|
||||
}
|
||||
}
|
||||
character.SelectedConstruction = newSelectedConstruction;
|
||||
character.SelectedConstruction = character.MemState[0].SelectedItem;
|
||||
}
|
||||
|
||||
if (character.MemState[0].Animation == AnimController.Animation.CPR)
|
||||
@@ -88,13 +92,13 @@ namespace Barotrauma
|
||||
Collider.AngularVelocity = newAngularVelocity;
|
||||
|
||||
float distSqrd = Vector2.DistanceSquared(newPosition, Collider.SimPosition);
|
||||
float errorTolerance = character.AllowInput ? 0.01f : 0.1f;
|
||||
float errorTolerance = character.AllowInput ? 0.01f : 0.2f;
|
||||
if (distSqrd > errorTolerance)
|
||||
{
|
||||
if (distSqrd > 10.0f || !character.AllowInput)
|
||||
{
|
||||
Collider.TargetRotation = newRotation;
|
||||
SetPosition(newPosition, lerp: distSqrd < 1.0f);
|
||||
SetPosition(newPosition, lerp: distSqrd < 5.0f);
|
||||
}
|
||||
else
|
||||
{
|
||||
@@ -108,8 +112,15 @@ namespace Barotrauma
|
||||
// -> we need to correct it manually
|
||||
if (!character.AllowInput)
|
||||
{
|
||||
MainLimb.PullJointWorldAnchorB = Collider.SimPosition;
|
||||
MainLimb.PullJointEnabled = true;
|
||||
float mainLimbDistSqrd = Vector2.DistanceSquared(MainLimb.PullJointWorldAnchorA, Collider.SimPosition);
|
||||
float mainLimbErrorTolerance = 0.1f;
|
||||
//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();
|
||||
@@ -162,25 +173,30 @@ namespace Barotrauma
|
||||
CharacterStateInfo localPos = character.MemLocalState[localPosIndex];
|
||||
|
||||
//the entity we're interacting with doesn't match the server's
|
||||
if (localPos.Interact != serverPos.Interact)
|
||||
if (localPos.SelectedCharacter != serverPos.SelectedCharacter)
|
||||
{
|
||||
if (serverPos.Interact == null || serverPos.Interact.Removed)
|
||||
if (serverPos.SelectedCharacter == null || serverPos.SelectedCharacter.Removed)
|
||||
{
|
||||
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;
|
||||
}
|
||||
else if (serverPos.Interact is Character)
|
||||
else if (serverPos.SelectedItem != null)
|
||||
{
|
||||
character.SelectCharacter((Character)serverPos.Interact);
|
||||
}
|
||||
else
|
||||
{
|
||||
var newSelectedConstruction = (Item)serverPos.Interact;
|
||||
if (newSelectedConstruction != null && character.SelectedConstruction != newSelectedConstruction)
|
||||
if (character.SelectedConstruction != serverPos.SelectedItem)
|
||||
{
|
||||
newSelectedConstruction.TryInteract(character, true, true);
|
||||
serverPos.SelectedItem.TryInteract(character, true, true);
|
||||
}
|
||||
character.SelectedConstruction = newSelectedConstruction;
|
||||
character.SelectedConstruction = serverPos.SelectedItem;
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
@@ -200,9 +200,13 @@ namespace Barotrauma
|
||||
{
|
||||
cam.OffsetAmount = 0.0f;
|
||||
}
|
||||
else if (SelectedConstruction != null && SelectedConstruction.Components.Any(ic => (ic.GuiFrame != null && GUI.IsMouseOn(ic.GuiFrame))))
|
||||
else if (SelectedConstruction != null && ViewTarget == null &&
|
||||
SelectedConstruction.Components.Any(ic => ic?.GuiFrame != null && ic.ShouldDrawHUD(this)))
|
||||
{
|
||||
cam.OffsetAmount = 0.0f;
|
||||
cursorPosition =
|
||||
SelectedConstruction.Position +
|
||||
new Vector2(cursorPosition.X % 10.0f, cursorPosition.Y % 10.0f); //apply a little bit of movement to the cursor pos to prevent AFK kicking
|
||||
}
|
||||
else if (Lights.LightManager.ViewTarget == this && Vector2.DistanceSquared(AnimController.Limbs[0].SimPosition, mouseSimPos) > 1.0f)
|
||||
{
|
||||
@@ -210,7 +214,7 @@ namespace Barotrauma
|
||||
{
|
||||
if (deltaTime > 0.0f) cam.OffsetAmount = 0.0f;
|
||||
}
|
||||
else if (Lights.LightManager.ViewTarget == this && Vector2.DistanceSquared(AnimController.Limbs[0].SimPosition, mouseSimPos) > 1.0f)
|
||||
else
|
||||
{
|
||||
Body body = Submarine.CheckVisibility(AnimController.Limbs[0].SimPosition, mouseSimPos);
|
||||
Structure structure = body == null ? null : body.UserData as Structure;
|
||||
|
||||
@@ -241,10 +241,12 @@ namespace Barotrauma
|
||||
if (!string.IsNullOrEmpty(jobIdentifier))
|
||||
{
|
||||
jobPrefab = JobPrefab.List.Find(jp => jp.Identifier == jobIdentifier);
|
||||
for (int i = 0; i < jobPrefab.Skills.Count; i++)
|
||||
byte skillCount = inc.ReadByte();
|
||||
for (int i = 0; i < skillCount; i++)
|
||||
{
|
||||
string skillIdentifier = inc.ReadString();
|
||||
float skillLevel = inc.ReadSingle();
|
||||
skillLevels.Add(jobPrefab.Skills[i].Identifier, skillLevel);
|
||||
skillLevels.Add(skillIdentifier, skillLevel);
|
||||
}
|
||||
}
|
||||
|
||||
@@ -254,7 +256,6 @@ namespace Barotrauma
|
||||
ID = infoID,
|
||||
};
|
||||
ch.RecreateHead(headSpriteID,(Race)race, (Gender)gender, hairIndex, beardIndex, moustacheIndex, faceAttachmentIndex);
|
||||
System.Diagnostics.Debug.Assert(skillLevels.Count == ch.Job.Skills.Count);
|
||||
if (ch.Job != null)
|
||||
{
|
||||
foreach (KeyValuePair<string, float> skill in skillLevels)
|
||||
@@ -262,11 +263,12 @@ namespace Barotrauma
|
||||
Skill matchingSkill = ch.Job.Skills.Find(s => s.Identifier == skill.Key);
|
||||
if (matchingSkill == null)
|
||||
{
|
||||
DebugConsole.ThrowError("Skill \"" + skill.Key + "\" not found in character \"" + newName + "\"");
|
||||
ch.Job.Skills.Add(new Skill(skill.Key, skill.Value));
|
||||
continue;
|
||||
}
|
||||
matchingSkill.Level = skill.Value;
|
||||
}
|
||||
ch.Job.Skills.RemoveAll(s => !skillLevels.ContainsKey(s.Identifier));
|
||||
}
|
||||
return ch;
|
||||
}
|
||||
|
||||
@@ -30,12 +30,13 @@ namespace Barotrauma
|
||||
else
|
||||
{
|
||||
var posInfo = new CharacterStateInfo(
|
||||
SimPosition,
|
||||
AnimController.Collider.Rotation,
|
||||
LastNetworkUpdateID,
|
||||
AnimController.TargetDir,
|
||||
SelectedCharacter == null ? (Entity)SelectedConstruction : (Entity)SelectedCharacter,
|
||||
AnimController.Anim);
|
||||
SimPosition,
|
||||
AnimController.Collider.Rotation,
|
||||
LastNetworkUpdateID,
|
||||
AnimController.TargetDir,
|
||||
SelectedCharacter,
|
||||
SelectedConstruction,
|
||||
AnimController.Anim);
|
||||
|
||||
memLocalState.Add(posInfo);
|
||||
|
||||
@@ -214,6 +215,7 @@ namespace Barotrauma
|
||||
Vector2 linearVelocity = new Vector2(
|
||||
msg.ReadRangedSingle(-MaxVel, MaxVel, 12),
|
||||
msg.ReadRangedSingle(-MaxVel, MaxVel, 12));
|
||||
linearVelocity = NetConfig.Quantize(linearVelocity, -MaxVel, MaxVel, 12);
|
||||
|
||||
bool fixedRotation = msg.ReadBoolean();
|
||||
float? rotation = null;
|
||||
@@ -223,6 +225,7 @@ namespace Barotrauma
|
||||
rotation = msg.ReadFloat();
|
||||
float MaxAngularVel = NetConfig.MaxPhysicsBodyAngularVelocity;
|
||||
angularVelocity = msg.ReadRangedSingle(-MaxAngularVel, MaxAngularVel, 8);
|
||||
angularVelocity = NetConfig.Quantize(angularVelocity.Value, -MaxAngularVel, MaxAngularVel, 8);
|
||||
}
|
||||
|
||||
bool readStatus = msg.ReadBoolean();
|
||||
@@ -236,7 +239,11 @@ namespace Barotrauma
|
||||
int index = 0;
|
||||
if (GameMain.Client.Character == this && AllowInput)
|
||||
{
|
||||
var posInfo = new CharacterStateInfo(pos, rotation, networkUpdateID, facingRight ? Direction.Right : Direction.Left, selectedEntity, animation);
|
||||
var posInfo = new CharacterStateInfo(
|
||||
pos, rotation,
|
||||
networkUpdateID,
|
||||
facingRight ? Direction.Right : Direction.Left,
|
||||
selectedCharacter, selectedItem, animation);
|
||||
|
||||
while (index < memState.Count && NetIdUtils.IdMoreRecent(posInfo.ID, memState[index].ID))
|
||||
index++;
|
||||
@@ -244,7 +251,11 @@ namespace Barotrauma
|
||||
}
|
||||
else
|
||||
{
|
||||
var posInfo = new CharacterStateInfo(pos, rotation, linearVelocity, angularVelocity, sendingTime, facingRight ? Direction.Right : Direction.Left, selectedEntity, animation);
|
||||
var posInfo = new CharacterStateInfo(
|
||||
pos, rotation,
|
||||
linearVelocity, angularVelocity,
|
||||
sendingTime, facingRight ? Direction.Right : Direction.Left,
|
||||
selectedCharacter, selectedItem, animation);
|
||||
|
||||
while (index < memState.Count && posInfo.Timestamp > memState[index].Timestamp)
|
||||
index++;
|
||||
|
||||
Reference in New Issue
Block a user