Unstable 0.1500.6.0 (1984 edition)

This commit is contained in:
Markus Isberg
2021-10-09 00:22:02 +09:00
parent 08bdfc6cea
commit c8943ef9c4
96 changed files with 1817 additions and 559 deletions
@@ -1829,7 +1829,7 @@ namespace Barotrauma
private void GenerateRuin(Point ruinPos, bool mirror)
{
var ruinGenerationParams = RuinGenerationParams.GetRandom();
var ruinGenerationParams = RuinGenerationParams.GetRandom(Rand.RandSync.Server);
LocationType locationType = StartLocation?.Type;
if (locationType == null)
@@ -1839,7 +1839,7 @@ namespace Barotrauma
{
locationType = LocationType.List.Where(lt =>
ruinGenerationParams.AllowedLocationTypes.Any(allowedType =>
allowedType.Equals("any", StringComparison.OrdinalIgnoreCase) || lt.Identifier.Equals(allowedType, StringComparison.OrdinalIgnoreCase))).GetRandom();
allowedType.Equals("any", StringComparison.OrdinalIgnoreCase) || lt.Identifier.Equals(allowedType, StringComparison.OrdinalIgnoreCase))).GetRandom(Rand.RandSync.Server);
}
}
@@ -3594,7 +3594,7 @@ namespace Barotrauma
{
locationType = LocationType.List.Where(lt =>
outpostGenerationParams.AllowedLocationTypes.Any(allowedType =>
allowedType.Equals("any", StringComparison.OrdinalIgnoreCase) || lt.Identifier.Equals(allowedType, StringComparison.OrdinalIgnoreCase))).GetRandom();
allowedType.Equals("any", StringComparison.OrdinalIgnoreCase) || lt.Identifier.Equals(allowedType, StringComparison.OrdinalIgnoreCase))).GetRandom(Rand.RandSync.Server);
}
}
@@ -3953,7 +3953,7 @@ namespace Barotrauma
bool TryGetExtraSpawnPoint(out Vector2 point)
{
point = Vector2.Zero;
var hull = Hull.hullList.FindAll(h => h.Submarine == wreck).GetRandom();
var hull = Hull.hullList.FindAll(h => h.Submarine == wreck).GetRandom(Rand.RandSync.Unsynced);
if (hull != null)
{
point = hull.WorldPosition;
@@ -44,7 +44,7 @@ namespace Barotrauma.RuinGeneration
this.filePath = filePath;
}
public static RuinGenerationParams GetRandom()
public static RuinGenerationParams GetRandom(Rand.RandSync randSync = Rand.RandSync.Server)
{
if (paramsList == null) { LoadAll(); }
@@ -54,7 +54,7 @@ namespace Barotrauma.RuinGeneration
return new RuinGenerationParams(null, null);
}
return paramsList[Rand.Int(paramsList.Count, Rand.RandSync.Server)];
return paramsList[Rand.Int(paramsList.Count, randSync)];
}
private static void LoadAll()
@@ -90,7 +90,7 @@ namespace Barotrauma
private const float StoreMaxReputationModifier = 0.1f;
private const float StoreSellPriceModifier = 0.8f;
private const float DailySpecialPriceModifier = 0.9f;
private const float DailySpecialPriceModifier = 0.5f;
private const float RequestGoodPriceModifier = 1.5f;
public const int StoreInitialBalance = 5000;
/// <summary>
@@ -472,17 +472,18 @@ namespace Barotrauma
foreach (LocationConnection connection in Connections)
{
connection.Difficulty = MathHelper.Clamp((connection.CenterPos.X / Width * 100) + Rand.Range(-10.0f, 0.0f, Rand.RandSync.Server), 1.2f, 100.0f);
float difficulty = GetLevelDifficulty(connection.CenterPos.X / Width);
connection.Difficulty = MathHelper.Clamp(difficulty + Rand.Range(-10.0f, 0.0f, Rand.RandSync.Server), 1.2f, 100.0f);
}
AssignBiomes();
CreateEndLocation();
foreach (Location location in Locations)
{
location.LevelData = new LevelData(location)
{
Difficulty = MathHelper.Clamp(location.MapPosition.X / Width * 100, 0.0f, 100.0f)
Difficulty = MathHelper.Clamp(GetLevelDifficulty(location.MapPosition.X / Width), 0.0f, 100.0f)
};
location.UnlockInitialMissions();
}
@@ -490,6 +491,14 @@ namespace Barotrauma
{
connection.LevelData = new LevelData(connection);
}
float GetLevelDifficulty(float areaDifficulty)
{
const float CurveModifier = 1.5f;
const float DifficultyMultiplier = 1.1f;
const float BaseDifficulty = -3f;
return (float)(1 - Math.Pow(1 - areaDifficulty, CurveModifier)) * DifficultyMultiplier * 100f + BaseDifficulty;
}
}
partial void GenerateLocationConnectionVisuals();
@@ -85,7 +85,15 @@ namespace Barotrauma
var subInfo = new SubmarineInfo(outpostModuleFile.Path);
if (subInfo.OutpostModuleInfo != null)
{
if (subInfo.OutpostModuleInfo.ModuleFlags.Contains("ruin") != generationParams is RuinGeneration.RuinGenerationParams) { continue; }
if (generationParams is RuinGeneration.RuinGenerationParams)
{
//if the module doesn't have the ruin flag or any other flag used in the generation params, don't use it in ruins
if (!subInfo.OutpostModuleInfo.ModuleFlags.Contains("ruin") &&
!generationParams.ModuleCounts.Any(m => subInfo.OutpostModuleInfo.ModuleFlags.Contains(m.Key)))
{
continue;
}
}
outpostModules.Add(subInfo);
}
}
@@ -11,6 +11,7 @@ using System.Xml.Linq;
using Barotrauma.Abilities;
#if CLIENT
using Microsoft.Xna.Framework.Graphics;
using Barotrauma.Lights;
#endif
namespace Barotrauma
@@ -97,7 +98,7 @@ namespace Barotrauma
{
get { return Prefab.Body; }
}
public List<Body> Bodies { get; private set; }
public bool CastShadow
@@ -113,7 +114,7 @@ namespace Barotrauma
}
private float? maxHealth;
[Serialize(100.0f, true)]
public float MaxHealth
{
@@ -168,7 +169,7 @@ namespace Barotrauma
{
get { return prefab.Tags; }
}
protected Color spriteColor;
[Editable, Serialize("1.0,1.0,1.0,1.0", true)]
public Color SpriteColor
@@ -176,7 +177,7 @@ namespace Barotrauma
get { return spriteColor; }
set { spriteColor = value; }
}
[Editable, Serialize(false, true)]
public bool UseDropShadow
{
@@ -216,6 +217,13 @@ namespace Barotrauma
UpdateSections();
}
}
#if CLIENT
foreach (LightSource light in Lights)
{
light.SpriteScale = scale * textureScale;
}
#endif
}
}
@@ -231,6 +239,13 @@ namespace Barotrauma
textureScale = new Vector2(
MathHelper.Clamp(value.X, 0.01f, 10),
MathHelper.Clamp(value.Y, 0.01f, 10));
#if CLIENT
foreach (LightSource light in Lights)
{
light.LightTextureScale = textureScale * scale;
}
#endif
}
}
@@ -239,7 +254,13 @@ namespace Barotrauma
public Vector2 TextureOffset
{
get { return textureOffset; }
set { textureOffset = value; }
set
{
textureOffset = value;
#if CLIENT
SetLightTextureOffset();
#endif
}
}
@@ -282,10 +303,10 @@ namespace Barotrauma
secRect.X += value.X; secRect.Y += value.Y;
sec.rect = secRect;
}
}
}
}
}
public float BodyWidth
{
get { return Prefab.BodyWidth > 0.0f ? Prefab.BodyWidth * scale : rect.Width; }
@@ -364,6 +385,12 @@ namespace Barotrauma
#if CLIENT
convexHulls?.ForEach(x => x.Move(amount));
foreach (LightSource light in Lights)
{
light.LightTextureTargetSize = rect.Size.ToVector2();
light.Position = rect.Location.ToVector2();
}
#endif
}
@@ -375,7 +402,7 @@ namespace Barotrauma
defaultRect = rectangle;
maxHealth = sp.Health;
rect = rectangle;
TextureScale = sp.TextureScale;
@@ -427,13 +454,48 @@ namespace Barotrauma
if (StairDirection != Direction.None)
{
CreateStairBodies();
}
}
}
}
SerializableProperties = element != null ? SerializableProperty.DeserializeProperties(this, element) : SerializableProperty.GetProperties(this);
// Only add ai targets automatically to submarine/outpost walls
#if CLIENT
foreach (XElement subElement in sp.ConfigElement.Elements())
{
if (subElement.Name.ToString().Equals("light", StringComparison.OrdinalIgnoreCase))
{
Vector2 pos = rect.Location.ToVector2();
pos.Y += rect.Height;
LightSource light = new LightSource(subElement)
{
ParentSub = Submarine,
Position = rect.Location.ToVector2(),
CastShadows = false,
IsBackground = false,
Color = subElement.GetAttributeColor("lightcolor", Color.White),
SpriteScale = Vector2.One,
Range = 0,
LightTextureTargetSize = rect.Size.ToVector2(),
LightTextureScale = textureScale * scale,
LightSourceParams =
{
Flicker = subElement.GetAttributeFloat("flicker", 0f),
FlickerSpeed = subElement.GetAttributeFloat("flickerspeed", 0f),
PulseAmount = subElement.GetAttributeFloat("pulseamount", 0f),
PulseFrequency = subElement.GetAttributeFloat("pulsefrequency", 0f),
BlinkFrequency = subElement.GetAttributeFloat("blinkfrequency", 0f)
}
};
Lights.Add(light);
SetLightTextureOffset();
}
}
#endif
// Only add ai targets automatically to submarine/outpost walls
if (aiTarget == null && HasBody && Tags.Contains("wall") && submarine != null && !submarine.Info.IsWreck && !NoAITarget)
{
aiTarget = new AITarget(this)
@@ -445,7 +507,7 @@ namespace Barotrauma
}
InsertToList();
DebugConsole.Log("Created " + Name + " (" + ID + ")");
}
@@ -477,7 +539,7 @@ namespace Barotrauma
{
Bodies = new List<Body>();
bodyDebugDimensions.Clear();
float stairAngle = MathHelper.ToRadians(Math.Min(Prefab.StairAngle, 75.0f));
float bodyWidth = ConvertUnits.ToSimUnits(rect.Width / Math.Cos(stairAngle));
@@ -505,9 +567,9 @@ namespace Barotrauma
{
int xsections = 1, ysections = 1;
int width = rect.Width, height = rect.Height;
if (!HasBody)
{
{
if (FlippedX && IsHorizontal)
{
xsections = (int)Math.Ceiling((float)rect.Width / prefab.sprite.SourceRect.Width);
@@ -549,8 +611,8 @@ namespace Barotrauma
if (FlippedX || FlippedY)
{
Rectangle sectionRect = new Rectangle(
FlippedX ? rect.Right - (x + 1) * width : rect.X + x * width,
FlippedY ? rect.Y - rect.Height + (y + 1) * height : rect.Y - y * height,
FlippedX ? rect.Right - (x + 1) * width : rect.X + x * width,
FlippedY ? rect.Y - rect.Height + (y + 1) * height : rect.Y - y * height,
width, height);
if (FlippedX)
@@ -646,8 +708,8 @@ namespace Barotrauma
Vector2 transformedMousePos = MathUtils.RotatePointAroundTarget(position, bodyPos, BodyRotation);
return
Math.Abs(transformedMousePos.X - bodyPos.X) < rectSize.X / 2.0f &&
return
Math.Abs(transformedMousePos.X - bodyPos.X) < rectSize.X / 2.0f &&
Math.Abs(transformedMousePos.Y - bodyPos.Y) < rectSize.Y / 2.0f;
}
else
@@ -693,6 +755,10 @@ namespace Barotrauma
#if CLIENT
if (convexHulls != null) convexHulls.ForEach(x => x.Remove());
foreach (LightSource light in Lights)
{
light.Remove();
}
#endif
}
@@ -725,6 +791,10 @@ namespace Barotrauma
#if CLIENT
if (convexHulls != null) convexHulls.ForEach(x => x.Remove());
foreach (LightSource light in Lights)
{
light.Remove();
}
#endif
}
@@ -782,7 +852,7 @@ namespace Barotrauma
return (IsHorizontal ? Sections[sectionIndex].rect.Width : Sections[sectionIndex].rect.Height);
}
public override bool AddUpgrade(Upgrade upgrade, bool createNetworkEvent = false)
{
if (!upgrade.Prefab.IsWallUpgrade) { return false; }
@@ -800,7 +870,7 @@ namespace Barotrauma
Upgrades.Add(upgrade);
upgrade.ApplyUpgrade();
}
UpdateSections();
return true;
@@ -915,7 +985,7 @@ namespace Barotrauma
{
diffFromCenter = -diffFromCenter;
}
Vector2 sectionPos = Position + new Vector2(
(float)Math.Cos(IsHorizontal ? -BodyRotation : MathHelper.PiOver2 - BodyRotation),
(float)Math.Sin(IsHorizontal ? -BodyRotation : MathHelper.PiOver2 - BodyRotation)) * diffFromCenter;
@@ -926,7 +996,7 @@ namespace Barotrauma
}
return sectionPos;
}
}
}
public AttackResult AddDamage(Character attacker, Vector2 worldPosition, Attack attack, float deltaTime, bool playSound = false)
{
@@ -949,7 +1019,7 @@ namespace Barotrauma
GameMain.ParticleManager.CreateParticle("dustcloud", SectionPosition(i), 0.0f, 0.0f);
#endif
}
}
}
#if CLIENT
if (playSound && damageAmount > 0)
{
@@ -976,7 +1046,7 @@ namespace Barotrauma
if (!MathUtils.IsValid(damage)) { return; }
damage = MathHelper.Clamp(damage, 0.0f, MaxHealth - Prefab.MinHealth);
#if SERVER
if (GameMain.Server != null && createNetworkEvent && damage != Sections[sectionIndex].damage)
{
@@ -1022,10 +1092,10 @@ namespace Barotrauma
{
diffFromCenter = (gapRect.Center.X - this.rect.Center.X) / (float)this.rect.Width * BodyWidth;
if (BodyWidth > 0.0f) { gapRect.Width = (int)(BodyWidth * (gapRect.Width / (float)this.rect.Width)); }
if (BodyHeight > 0.0f)
{
if (BodyHeight > 0.0f)
{
gapRect.Y = (gapRect.Y - gapRect.Height / 2) + (int)(BodyHeight / 2 + BodyOffset.Y * scale);
gapRect.Height = (int)BodyHeight;
gapRect.Height = (int)BodyHeight;
}
}
else
@@ -1034,7 +1104,7 @@ namespace Barotrauma
if (BodyWidth > 0.0f)
{
gapRect.X = gapRect.Center.X + (int)(-BodyWidth / 2 + BodyOffset.X * scale);
gapRect.Width = (int)BodyWidth;
gapRect.Width = (int)BodyWidth;
}
if (BodyHeight > 0.0f) { gapRect.Height = (int)(BodyHeight * (gapRect.Height / (float)this.rect.Height)); }
}
@@ -1053,7 +1123,7 @@ namespace Barotrauma
gapRect.Y += 10;
gapRect.Width += 20;
gapRect.Height += 20;
bool horizontalGap = !IsHorizontal;
if (Prefab.BodyRotation != 0.0f)
{
@@ -1090,7 +1160,7 @@ namespace Barotrauma
}
float gapOpen = MaxHealth <= 0.0f ? 0.0f : (damage / MaxHealth - LeakThreshold) * (1.0f / (1.0f - LeakThreshold));
Sections[sectionIndex].gap.Open = gapOpen;
Sections[sectionIndex].gap.Open = gapOpen;
}
float damageDiff = damage - Sections[sectionIndex].damage;
@@ -1106,9 +1176,9 @@ namespace Barotrauma
{
if (damageDiff < 0.0f)
{
attacker.Info?.IncreaseSkillLevel("mechanical",
attacker.Info?.IncreaseSkillLevel("mechanical",
-damageDiff * SkillSettings.Current.SkillIncreasePerRepairedStructureDamage / Math.Max(attacker.GetSkillLevel("mechanical"), 1.0f),
SectionPosition(sectionIndex));
SectionPosition(sectionIndex));
}
}
}
@@ -1116,7 +1186,7 @@ namespace Barotrauma
bool hasHole = SectionBodyDisabled(sectionIndex);
if (hadHole == hasHole) { return; }
UpdateSections();
}
@@ -1198,7 +1268,7 @@ namespace Barotrauma
if (BodyHeight > 0.0f) rect.Height = Math.Max((int)Math.Round(BodyHeight * (rect.Height / (float)this.rect.Height)), 1);
}
if (FlippedX) { diffFromCenter = -diffFromCenter; }
Vector2 bodyOffset = ConvertUnits.ToSimUnits(Prefab.BodyOffset) * scale;
if (FlippedX) { bodyOffset.X = -bodyOffset.X; }
if (FlippedY) { bodyOffset.Y = -bodyOffset.Y; }
@@ -1240,7 +1310,7 @@ namespace Barotrauma
}
partial void CreateConvexHull(Vector2 position, Vector2 size, float rotation);
public override void FlipX(bool relativeToSub)
{
base.FlipX(relativeToSub);
@@ -1261,7 +1331,7 @@ namespace Barotrauma
CreateStairBodies();
}
if (HasBody)
{
CreateSections();
@@ -1388,7 +1458,7 @@ namespace Barotrauma
StructurePrefab prefab = null;
if (string.IsNullOrEmpty(identifier))
{
//legacy support:
//legacy support:
//1. attempt to find a prefab with an empty identifier and a matching name
prefab = MapEntityPrefab.Find(name, "") as StructurePrefab;
//2. not found, attempt to find a prefab with a matching name
@@ -1433,7 +1503,7 @@ namespace Barotrauma
}
SerializableProperty.SerializeProperties(this, element);
foreach (var upgrade in Upgrades)
{
upgrade.Save(element);
@@ -291,7 +291,8 @@ namespace Barotrauma
{
case "sprite":
sp.sprite = new Sprite(subElement, lazyLoad: true);
if (subElement.Attribute("sourcerect") == null)
if (subElement.Attribute("sourcerect") == null &&
subElement.Attribute("sheetindex") == null)
{
DebugConsole.ThrowError("Warning - sprite sourcerect not configured for structure \"" + sp.name + "\"!");
}
@@ -914,9 +914,11 @@ namespace Barotrauma
mapEntity.Move(-HiddenSubPosition);
}
var prevBodyType = subBody.Body.BodyType;
Vector2 pos = new Vector2(subBody.Position.X, subBody.Position.Y);
subBody.Body.Remove();
subBody = new SubmarineBody(this);
subBody.Body.BodyType = prevBodyType;
SetPosition(pos, new List<Submarine>(parents.Where(p => p != this)));
if (entityGrid != null)
@@ -1429,6 +1431,11 @@ namespace Barotrauma
}
}
}
else if (info.IsRuin)
{
ShowSonarMarker = false;
PhysicsBody.FarseerBody.BodyType = BodyType.Static;
}
}
if (entityGrid != null)
@@ -868,11 +868,12 @@ namespace Barotrauma
}
}
public static WayPoint GetRandom(SpawnType spawnType = SpawnType.Human, JobPrefab assignedJob = null, Submarine sub = null, bool useSyncedRand = false)
public static WayPoint GetRandom(SpawnType spawnType = SpawnType.Human, JobPrefab assignedJob = null, Submarine sub = null, bool useSyncedRand = false, string spawnPointTag = null)
{
return WayPointList.GetRandom(wp =>
wp.Submarine == sub &&
wp.spawnType == spawnType &&
(string.IsNullOrEmpty(spawnPointTag) || wp.Tags.Any(t => t.Equals(spawnPointTag, StringComparison.OrdinalIgnoreCase))) &&
(assignedJob == null || (assignedJob != null && wp.AssignedJob == assignedJob)),
useSyncedRand ? Rand.RandSync.Server : Rand.RandSync.Unsynced);
}