Unstable 0.1500.7.0 (No edition)

This commit is contained in:
Markus Isberg
2021-10-14 00:42:06 +09:00
parent c8943ef9c4
commit de917c5d74
105 changed files with 871 additions and 443 deletions
@@ -342,7 +342,7 @@ namespace Barotrauma
partial void SetupDrawOrder()
{
//make sure every character gets drawn at a distinct "layer"
//make sure every character gets drawn at a distinct "layer"
//(instead of having some of the limbs appear behind and some in front of other characters)
float startDepth = 0.1f;
float increment = 0.001f;
@@ -355,8 +355,16 @@ namespace Barotrauma
List<Limb> depthSortedLimbs = Limbs.OrderBy(l => l.DefaultSpriteDepth).ToList();
foreach (Limb limb in Limbs)
{
if (limb.ActiveSprite == null) { continue; }
limb.ActiveSprite.Depth = startDepth + depthSortedLimbs.IndexOf(limb) * 0.00001f;
var sprite = limb.GetActiveSprite();
if (sprite == null) { continue; }
sprite.Depth = startDepth + depthSortedLimbs.IndexOf(limb) * 0.00001f;
foreach (var conditionalSprite in limb.ConditionalSprites)
{
if (conditionalSprite.Exclusive)
{
conditionalSprite.ActiveSprite.Depth = sprite.Depth;
}
}
}
foreach (Limb limb in Limbs)
{
@@ -128,6 +128,50 @@ namespace Barotrauma
get { return gibEmitters; }
}
private class GUIMessage
{
public string RawText;
public string Identifier;
public string Text;
private int _value;
public int Value
{
get { return _value; }
set
{
_value = value;
Text = RawText.Replace("[value]", _value.ToString());
Size = GUI.Font.MeasureString(Text);
}
}
public Color Color;
public float Lifetime;
public float Timer;
public Vector2 Size;
public bool PlaySound;
public GUIMessage(string rawText, Color color, float delay, string identifier = null, int? value = null)
{
RawText = Text = rawText;
if (value.HasValue)
{
Text = rawText.Replace("[value]", value.Value.ToString());
Value = value.Value;
}
Timer = -delay;
Size = GUI.Font.MeasureString(Text);
Color = color;
Identifier = identifier;
Lifetime = 3.0f;
}
}
private List<GUIMessage> guiMessages = new List<GUIMessage>();
public static bool IsMouseOnUI => GUI.MouseOn != null ||
(CharacterInventory.IsMouseOnInventory && !CharacterInventory.DraggingItemToWorld);
@@ -618,6 +662,17 @@ namespace Barotrauma
}
}
foreach (GUIMessage message in guiMessages)
{
bool wasPending = message.Timer < 0.0f;
message.Timer += deltaTime;
if (wasPending && message.Timer >= 0.0f && message.PlaySound)
{
SoundPlayer.PlayUISound(GUISoundType.UIMessage);
}
}
guiMessages.RemoveAll(m => m.Timer >= m.Lifetime);
if (!enabled) { return; }
if (!IsIncapacitated)
@@ -736,6 +791,27 @@ namespace Barotrauma
CharacterHUD.Draw(spriteBatch, this, cam);
if (drawHealth && !CharacterHUD.IsCampaignInterfaceOpen) { CharacterHealth.DrawHUD(spriteBatch); }
}
public void DrawGUIMessages(SpriteBatch spriteBatch, Camera cam)
{
if (info == null || !Enabled || InvisibleTimer > 0.0f)
{
return;
}
Vector2 messagePos = DrawPosition;
messagePos.Y += hudInfoHeight;
messagePos = cam.WorldToScreen(messagePos) - Vector2.UnitY * GUI.IntScale(60);
foreach (GUIMessage message in guiMessages)
{
if (message.Timer < 0) { continue; }
Vector2 drawPos = messagePos + Vector2.UnitX * (GUI.IntScale(60) - message.Size.X);
drawPos = new Vector2((int)drawPos.X, (int)drawPos.Y);
float alpha = MathHelper.SmoothStep(1.0f, 0.0f, message.Timer / message.Lifetime);
GUI.DrawString(spriteBatch, drawPos, message.Text, message.Color * alpha);
messagePos -= Vector2.UnitY * message.Size.Y * 1.2f;
}
}
public virtual void DrawFront(SpriteBatch spriteBatch, Camera cam)
{
@@ -942,6 +1018,55 @@ namespace Barotrauma
return nameColor;
}
public void AddMessage(string rawText, Color color, bool playSound, string identifier = null, int? value = null)
{
GUIMessage existingMessage = null;
float delay = 0.0f;
if (guiMessages.Any())
{
delay = guiMessages.Min(m => m.Timer) - 0.5f;
if (delay < 0)
{
delay = -delay;
if (guiMessages.Count > 5)
{
//reduce delays if there's lots of messages
guiMessages.Where(m => m.Timer < 0.0f).ForEach(m => m.Timer *= 0.9f);
}
}
else
{
delay = 0;
}
}
if (identifier != null)
{
existingMessage = guiMessages.Find(m => m.Identifier == identifier && m.Timer < m.Lifetime * 0.5f);
}
if (existingMessage == null || !value.HasValue)
{
var newMessage = new GUIMessage(rawText, color, delay, identifier, value);
guiMessages.Insert(0, newMessage);
if (playSound)
{
if (delay > 0.0f)
{
newMessage.PlaySound = true;
}
else
{
SoundPlayer.PlayUISound(GUISoundType.UIMessage);
}
}
}
else
{
existingMessage.Value += value.Value;
}
}
/// <summary>
/// Creates a progress bar that's "linked" to the specified object (or updates an existing one if there's one already linked to the object)
/// The progress bar will automatically fade out after 1 sec if the method hasn't been called during that time
@@ -1046,24 +1171,14 @@ namespace Barotrauma
if (newAmount > prevAmount)
{
int increase = newAmount - prevAmount;
GUI.AddMessage(
"+" + TextManager.GetWithVariable("currencyformat", "[credits]", increase.ToString()),
GUI.Style.Yellow,
Position + Vector2.UnitY * 150.0f,
Vector2.UnitY * 10.0f,
playSound: true,
subId: Submarine?.ID ?? -1);
AddMessage("+" + TextManager.GetWithVariable("currencyformat", "[credits]", "[value]"),
GUI.Style.Yellow, playSound: this == Controlled, "money", increase);
}
}
partial void OnTalentGiven(string talentIdentifier)
{
GUI.AddMessage(TextManager.Get("talentname." + talentIdentifier.ToString()),
GUI.Style.Yellow,
Position + Vector2.UnitY * 150.0f,
Vector2.UnitY * 10.0f,
playSound: true,
subId: Submarine?.ID ?? -1);
AddMessage(TextManager.Get("talentname." + talentIdentifier.ToString()), GUI.Style.Yellow, playSound: this == Controlled);
}
}
}
@@ -187,7 +187,7 @@ namespace Barotrauma
return frame;
}
partial void OnSkillChanged(string skillIdentifier, float prevLevel, float newLevel, Vector2 textPopupPos)
partial void OnSkillChanged(string skillIdentifier, float prevLevel, float newLevel)
{
if (TeamID == CharacterTeamType.FriendlyNPC) { return; }
if (Character.Controlled != null && Character.Controlled.TeamID != TeamID) { return; }
@@ -198,17 +198,14 @@ namespace Barotrauma
if ((int)newLevel > (int)prevLevel)
{
int increase = Math.Max((int)newLevel - (int)prevLevel, 1);
GUI.AddMessage(
string.Format("+{0} {1}", increase, TextManager.Get("SkillName." + skillIdentifier)),
specialIncrease ? GUI.Style.Orange : GUI.Style.Green,
textPopupPos,
Vector2.UnitY * 10.0f,
playSound: specialIncrease,
subId: Character?.Submarine?.ID ?? -1);
Character?.AddMessage(
"+[value] "+ TextManager.Get("SkillName." + skillIdentifier),
specialIncrease ? GUI.Style.Orange : GUI.Style.Green,
playSound: Character == Character.Controlled, skillIdentifier, increase);
}
}
partial void OnExperienceChanged(int prevAmount, int newAmount, Vector2 textPopupPos)
partial void OnExperienceChanged(int prevAmount, int newAmount)
{
if (Character.Controlled != null && Character.Controlled.TeamID != TeamID) { return; }
@@ -217,13 +214,9 @@ namespace Barotrauma
if (newAmount > prevAmount)
{
int increase = newAmount - prevAmount;
GUI.AddMessage(
string.Format("+{0} {1}", increase, TextManager.Get("experienceshort")),
GUI.Style.Blue,
textPopupPos,
Vector2.UnitY * 10.0f,
playSound: true,
subId: Character?.Submarine?.ID ?? -1);
Character?.AddMessage(
"+[value] " + TextManager.Get("experienceshort"),
GUI.Style.Blue, playSound: Character == Character.Controlled, "exp", increase);
}
}
@@ -358,7 +358,7 @@ namespace Barotrauma
{
string skillIdentifier = msg.ReadString();
float skillLevel = msg.ReadSingle();
info?.SetSkillLevel(skillIdentifier, skillLevel, Position + Vector2.UnitY * 150.0f);
info?.SetSkillLevel(skillIdentifier, skillLevel);
}
break;
case 4: // NetEntityEvent.Type.SetAttackTarget
@@ -390,7 +390,7 @@ namespace Barotrauma
}
targetLimb = targetCharacter.AnimController.Limbs[targetLimbIndex];
}
if (attackLimb?.attack != null)
if (attackLimb?.attack != null && Controlled != this)
{
if (eventType == 4)
{
@@ -467,8 +467,9 @@ namespace Barotrauma
ushort talentCount = msg.ReadUInt16();
for (int i = 0; i < talentCount; i++)
{
bool addedThisRound = msg.ReadBoolean();
UInt32 talentIdentifier = msg.ReadUInt32();
GiveTalent(talentIdentifier);
GiveTalent(talentIdentifier, addedThisRound);
}
break;
case 12: //NetEntityEvent.Type.UpdateMoney:
@@ -1969,8 +1969,8 @@ namespace Barotrauma
if (limbHealths[limb.HealthIndex].Afflictions.Count == 0) continue;
foreach (Affliction a in limbHealths[limb.HealthIndex].Afflictions)
{
limb.BurnOverlayStrength += a.Strength / a.Prefab.MaxStrength * a.Prefab.BurnOverlayAlpha;
limb.DamageOverlayStrength += a.Strength / a.Prefab.MaxStrength * a.Prefab.DamageOverlayAlpha;
limb.BurnOverlayStrength += a.Strength / Math.Min(a.Prefab.MaxStrength, 100) * a.Prefab.BurnOverlayAlpha;
limb.DamageOverlayStrength += a.Strength / Math.Min(a.Prefab.MaxStrength, 100) * a.Prefab.DamageOverlayAlpha;
}
limb.BurnOverlayStrength /= limbHealths[limb.HealthIndex].Afflictions.Count;
limb.DamageOverlayStrength /= limbHealths[limb.HealthIndex].Afflictions.Count;
@@ -167,6 +167,10 @@ namespace Barotrauma
}
}
public Sprite GetActiveSprite(bool excludeConditionalSprites = true)
=> excludeConditionalSprites ? (_deformSprite != null ? _deformSprite.Sprite : Sprite)
: ActiveSprite;
public float DefaultSpriteDepth { get; private set; }
public WearableSprite HuskSprite { get; private set; }
@@ -397,7 +401,7 @@ namespace Barotrauma
return deformations;
}
}
DefaultSpriteDepth = ActiveSprite.Depth;
DefaultSpriteDepth = GetActiveSprite()?.Depth ?? 0.0f;
LightSource?.CheckConditionals();
}
@@ -901,7 +905,7 @@ namespace Barotrauma
}
foreach (WearableSprite wearable in WearingItems)
{
if (onlyDrawable != null && onlyDrawable != wearable) continue;
if (onlyDrawable != null && onlyDrawable != wearable && wearable.CanBeHiddenByOtherWearables) { continue; }
DrawWearable(wearable, depthStep, spriteBatch, blankColor, alpha: color.A / 255f, spriteEffect);
//if there are multiple sprites on this limb, make the successive ones be drawn in front
depthStep += step;