(0bd92547e) Show ping direction when adjusting the direction slider even if directional ping is not enabled. Closes #1298
This commit is contained in:
@@ -656,13 +656,6 @@ namespace Barotrauma
|
||||
msg.Timer -= 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);
|
||||
|
||||
@@ -44,7 +44,9 @@ namespace Barotrauma.Items.Components
|
||||
private float displayScale;
|
||||
|
||||
private float zoomSqrt;
|
||||
|
||||
|
||||
private float showDirectionalIndicatorTimer;
|
||||
|
||||
//Vector2 = vector from the ping source to the position of the disruption
|
||||
//float = strength of the disruption, between 0-1
|
||||
List<Pair<Vector2, float>> disruptedDirections = new List<Pair<Vector2, float>>();
|
||||
@@ -145,6 +147,7 @@ namespace Barotrauma.Items.Components
|
||||
{
|
||||
OnMoved = (scrollbar, scroll) =>
|
||||
{
|
||||
showDirectionalIndicatorTimer = 1.0f;
|
||||
float pingAngle = MathHelper.Lerp(0.0f, MathHelper.TwoPi, scroll);
|
||||
pingDirection = new Vector2((float)Math.Cos(pingAngle), (float)Math.Sin(pingAngle));
|
||||
if (GameMain.Client != null)
|
||||
@@ -175,6 +178,7 @@ namespace Barotrauma.Items.Components
|
||||
|
||||
public override void UpdateHUD(Character character, float deltaTime, Camera cam)
|
||||
{
|
||||
showDirectionalIndicatorTimer -= deltaTime;
|
||||
if (GameMain.Client != null)
|
||||
{
|
||||
if (unsentChanges)
|
||||
@@ -378,12 +382,13 @@ namespace Barotrauma.Items.Components
|
||||
spriteBatch.Begin(SpriteSortMode.Deferred, BlendState.AlphaBlend);
|
||||
}
|
||||
|
||||
if (useDirectionalPing && IsActive)
|
||||
float directionalPingVisibility = useDirectionalPing && IsActive ? 1.0f : showDirectionalIndicatorTimer;
|
||||
if (directionalPingVisibility > 0.0f)
|
||||
{
|
||||
Vector2 sector1 = MathUtils.RotatePointAroundTarget(pingDirection * DisplayRadius, Vector2.Zero, DirectionalPingSector * 0.5f);
|
||||
Vector2 sector2 = MathUtils.RotatePointAroundTarget(pingDirection * DisplayRadius, Vector2.Zero, -DirectionalPingSector * 0.5f);
|
||||
GUI.DrawLine(spriteBatch, center, center + sector1, Color.LightCyan * 0.2f, width: 3);
|
||||
GUI.DrawLine(spriteBatch, center, center + sector2, Color.LightCyan * 0.2f, width: 3);
|
||||
GUI.DrawLine(spriteBatch, center, center + sector1, Color.LightCyan * 0.2f * directionalPingVisibility, width: 3);
|
||||
GUI.DrawLine(spriteBatch, center, center + sector2, Color.LightCyan * 0.2f * directionalPingVisibility, width: 3);
|
||||
}
|
||||
|
||||
if (GameMain.DebugDraw)
|
||||
|
||||
@@ -332,7 +332,8 @@ namespace Barotrauma.Networking
|
||||
}
|
||||
}
|
||||
|
||||
foreach (NetEntityEvent entityEvent in sentEvents)
|
||||
//too many events for one packet
|
||||
if (eventsToSync.Count > 200)
|
||||
{
|
||||
msg.Write((byte)ServerNetObject.ENTITY_EVENT_INITIAL);
|
||||
msg.Write(client.UnreceivedEntityEventCount);
|
||||
|
||||
@@ -726,8 +726,7 @@ namespace Barotrauma
|
||||
if (!canAttack && !IsCoolDownRunning)
|
||||
{
|
||||
// If not, reset the attacking limb, if the cooldown is not running
|
||||
// Don't use the property, because we don't want cancel reversing, if we are reversing.
|
||||
_attackingLimb = null;
|
||||
AttackingLimb = null;
|
||||
}
|
||||
}
|
||||
|
||||
@@ -1148,6 +1147,65 @@ namespace Barotrauma
|
||||
//skip the target if it's a room and the character is already inside a sub
|
||||
if (character.CurrentHull != null && target.Entity is Hull) continue;
|
||||
|
||||
Door door = null;
|
||||
if (target.Entity is Item item)
|
||||
{
|
||||
targetingTag = "dead";
|
||||
if (targetCharacter.Submarine != Character.Submarine)
|
||||
{
|
||||
// In a different sub or the target is outside when we are inside or vice versa -> Ignore the target
|
||||
continue;
|
||||
}
|
||||
else if (targetCharacter.CurrentHull != Character.CurrentHull)
|
||||
{
|
||||
// In the same sub, halve the priority, if not in the same hull.
|
||||
valueModifier = 0.5f;
|
||||
}
|
||||
}
|
||||
else if (targetCharacter.AIController is EnemyAIController enemy)
|
||||
{
|
||||
if (enemy.combatStrength > combatStrength)
|
||||
{
|
||||
targetingTag = "stronger";
|
||||
}
|
||||
else if (enemy.combatStrength < combatStrength)
|
||||
{
|
||||
targetingTag = "weaker";
|
||||
}
|
||||
if (State == AIState.Escape && targetingTag == "stronger")
|
||||
{
|
||||
// Frightened
|
||||
valueModifier = 2;
|
||||
}
|
||||
else
|
||||
{
|
||||
if (targetCharacter.Submarine != Character.Submarine)
|
||||
{
|
||||
// In a different sub or the target is outside when we are inside or vice versa -> Ignore the target
|
||||
continue;
|
||||
}
|
||||
else if (targetCharacter.CurrentHull != Character.CurrentHull)
|
||||
{
|
||||
// In the same sub, halve the priority, if not in the same hull.
|
||||
valueModifier = 0.5f;
|
||||
}
|
||||
}
|
||||
}
|
||||
else if (targetCharacter.Submarine != null && Character.Submarine == null)
|
||||
{
|
||||
//target inside, AI outside -> we'll be attacking a wall between the characters so use the priority for attacking rooms
|
||||
targetingTag = "room";
|
||||
}
|
||||
else if (targetingPriorities.ContainsKey(targetCharacter.SpeciesName.ToLowerInvariant()))
|
||||
{
|
||||
targetingTag = targetCharacter.SpeciesName.ToLowerInvariant();
|
||||
}
|
||||
}
|
||||
else if (target.Entity != null)
|
||||
{
|
||||
//skip the target if it's a room and the character is already inside a sub
|
||||
if (character.CurrentHull != null && target.Entity is Hull) continue;
|
||||
|
||||
Door door = null;
|
||||
if (target.Entity is Item item)
|
||||
{
|
||||
@@ -1217,49 +1275,11 @@ namespace Barotrauma
|
||||
valueModifier = isOutdoor ? 1 : 0;
|
||||
valueModifier *= isOpen ? 5 : 1;
|
||||
}
|
||||
}
|
||||
}
|
||||
else if (targetCharacter.Submarine != null && Character.Submarine == null)
|
||||
{
|
||||
targetingTag = "dead";
|
||||
if (targetCharacter.Submarine != Character.Submarine)
|
||||
{
|
||||
// In a different sub or the target is outside when we are inside or vice versa -> Ignore the target
|
||||
continue;
|
||||
}
|
||||
else if (targetCharacter.CurrentHull != Character.CurrentHull)
|
||||
{
|
||||
// In the same sub, halve the priority, if not in the same hull.
|
||||
valueModifier = 0.5f;
|
||||
}
|
||||
}
|
||||
else if (targetCharacter.AIController is EnemyAIController enemy)
|
||||
{
|
||||
if (enemy.combatStrength > combatStrength)
|
||||
{
|
||||
targetingTag = "stronger";
|
||||
}
|
||||
else if (enemy.combatStrength < combatStrength)
|
||||
{
|
||||
targetingTag = "weaker";
|
||||
}
|
||||
if (State == AIState.Escape && targetingTag == "stronger")
|
||||
{
|
||||
// Frightened
|
||||
valueModifier = 2;
|
||||
}
|
||||
else
|
||||
{
|
||||
if (targetCharacter.Submarine != Character.Submarine)
|
||||
else if (targetCharacter.CurrentHull != Character.CurrentHull)
|
||||
{
|
||||
valueModifier = isOutdoor ? 0 : 1;
|
||||
valueModifier *= isOpen ? 0 : 1;
|
||||
}
|
||||
else if (targetCharacter.CurrentHull != Character.CurrentHull)
|
||||
{
|
||||
// In the same sub, halve the priority, if not in the same hull.
|
||||
valueModifier = 0.5f;
|
||||
}
|
||||
}
|
||||
else if (isOpen) //ignore broken and open doors
|
||||
{
|
||||
@@ -1277,11 +1297,6 @@ namespace Barotrauma
|
||||
|
||||
valueModifier *= targetingPriorities[targetingTag].Priority;
|
||||
|
||||
if (targetingTag == null) continue;
|
||||
if (!targetingPriorities.ContainsKey(targetingTag)) continue;
|
||||
|
||||
valueModifier *= targetingPriorities[targetingTag].Priority;
|
||||
|
||||
if (valueModifier == 0.0f) continue;
|
||||
|
||||
Vector2 toTarget = target.WorldPosition - character.WorldPosition;
|
||||
|
||||
@@ -538,7 +538,6 @@ namespace Barotrauma.Items.Components
|
||||
GameAnalyticsManager.AddErrorEventOnce("ItemComponent.DegreeOfSuccess:CharacterNull", GameAnalyticsSDK.Net.EGAErrorSeverity.Error, errorMsg);
|
||||
return 0.0f;
|
||||
}
|
||||
float average = skillSuccessSum / requiredSkills.Count;
|
||||
|
||||
float skillSuccessSum = 0.0f;
|
||||
for (int i = 0; i < requiredSkills.Count; i++)
|
||||
@@ -735,15 +734,13 @@ namespace Barotrauma.Items.Components
|
||||
private void OverrideRequiredItems(XElement element)
|
||||
{
|
||||
var prevRequiredItems = new Dictionary<RelatedItem.RelationType, List<RelatedItem>>(requiredItems);
|
||||
bool overrideRequiredItems = false;
|
||||
requiredItems.Clear();
|
||||
|
||||
foreach (XElement subElement in element.Elements())
|
||||
{
|
||||
switch (subElement.Name.ToString().ToLowerInvariant())
|
||||
{
|
||||
case "requireditem":
|
||||
if (!overrideRequiredItems) requiredItems.Clear();
|
||||
overrideRequiredItems = true;
|
||||
|
||||
RelatedItem newRequiredItem = RelatedItem.Load(subElement, item.Name);
|
||||
if (newRequiredItem == null) continue;
|
||||
|
||||
|
||||
@@ -752,6 +752,39 @@ namespace Barotrauma
|
||||
|
||||
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);
|
||||
}
|
||||
|
||||
|
||||
Reference in New Issue
Block a user