Unstable 0.17.0.0

This commit is contained in:
Markus Isberg
2022-02-26 02:43:01 +09:00
parent a83f375681
commit 3974067915
913 changed files with 32472 additions and 32364 deletions
@@ -15,25 +15,30 @@ namespace Barotrauma.Items.Components
{
internal class ProducedItem
{
[Serialize(0f, true)]
[Serialize(0f, IsPropertySaveable.Yes)]
public float Probability { get; set; }
public readonly List<StatusEffect> StatusEffects = new List<StatusEffect>();
public readonly Item Producer;
public readonly ItemPrefab? Prefab;
public ProducedItem(ItemPrefab prefab, float probability)
public ProducedItem(Item producer, ItemPrefab prefab, float probability)
{
Producer = producer;
Prefab = prefab;
Probability = probability;
}
public ProducedItem(XElement element)
public ProducedItem(Item producer, ContentXElement element)
{
SerializableProperty.DeserializeProperties(this, element);
string itemIdentifier = element.GetAttributeString("identifier", string.Empty);
if (!string.IsNullOrWhiteSpace(itemIdentifier))
Producer = producer;
Identifier itemIdentifier = element.GetAttributeIdentifier("identifier", Identifier.Empty);
if (!itemIdentifier.IsEmpty)
{
Prefab = ItemPrefab.Find(null, itemIdentifier);
}
@@ -41,17 +46,17 @@ namespace Barotrauma.Items.Components
LoadSubElements(element);
}
private void LoadSubElements(XElement element)
private void LoadSubElements(ContentXElement element)
{
if (!element.HasElements) { return; }
foreach (XElement subElement in element.Elements())
foreach (var subElement in element.Elements())
{
switch (subElement.Name.ToString().ToLowerInvariant())
{
case "statuseffect":
{
StatusEffect effect = StatusEffect.Load(subElement, Prefab?.Name);
StatusEffect effect = StatusEffect.Load(subElement, Prefab?.Name.Value);
if (effect.type != ActionType.OnProduceSpawned)
{
DebugConsole.ThrowError("Only OnProduceSpawned type can be used in <ProducedItem>.");
@@ -325,9 +330,14 @@ namespace Barotrauma.Items.Components
}
public static TileSide GetOppositeSide(this TileSide side)
{
return (TileSide) (1 << ((int) Math.Log2((int) side) + 2) % 4);
}
=> side switch
{
TileSide.Left => TileSide.Right,
TileSide.Right => TileSide.Left,
TileSide.Bottom => TileSide.Top,
TileSide.Top => TileSide.Bottom,
_ => throw new ArgumentException($"Expected Left, Right, Bottom or Top, got {side}")
};
}
internal partial class Growable : ItemComponent, IServerSerializable
@@ -335,61 +345,61 @@ namespace Barotrauma.Items.Components
// used for debugging where a vine failed to grow
public readonly HashSet<Rectangle> FailedRectangles = new HashSet<Rectangle>();
[Serialize(1f, true, "How fast the plant grows.")]
[Serialize(1f, IsPropertySaveable.Yes, "How fast the plant grows.")]
public float GrowthSpeed { get; set; }
[Serialize(100f, true, "How long the plant can go without watering.")]
[Serialize(100f, IsPropertySaveable.Yes, "How long the plant can go without watering.")]
public float MaxHealth { get; set; }
[Serialize(1f, true, "How much damage the plant takes while in water.")]
[Serialize(1f, IsPropertySaveable.Yes, "How much damage the plant takes while in water.")]
public float FloodTolerance { get; set; }
[Serialize(1f, true, "How much damage the plant takes while growing.")]
[Serialize(1f, IsPropertySaveable.Yes, "How much damage the plant takes while growing.")]
public float Hardiness { get; set; }
[Serialize(0.01f, true, "How often a seed is produced.")]
[Serialize(0.01f, IsPropertySaveable.Yes, "How often a seed is produced.")]
public float SeedRate { get; set; }
[Serialize(0.01f, true, "How often a product item is produced.")]
[Serialize(0.01f, IsPropertySaveable.Yes, "How often a product item is produced.")]
public float ProductRate { get; set; }
[Serialize(0.5f, true, "Probability of an attribute being randomly modified in a newly produced seed.")]
[Serialize(0.5f, IsPropertySaveable.Yes, "Probability of an attribute being randomly modified in a newly produced seed.")]
public float MutationProbability { get; set; }
[Serialize("1.0,1.0,1.0,1.0", true, "Color of the flowers.")]
[Serialize("1.0,1.0,1.0,1.0", IsPropertySaveable.Yes, "Color of the flowers.")]
public Color FlowerTint { get; set; }
[Serialize(3, true, "Number of flowers drawn when fully grown")]
[Serialize(3, IsPropertySaveable.Yes, "Number of flowers drawn when fully grown")]
public int FlowerQuantity { get; set; }
[Serialize(0.25f, true, "Size of the flower sprites.")]
[Serialize(0.25f, IsPropertySaveable.Yes, "Size of the flower sprites.")]
public float BaseFlowerScale { get; set; }
[Serialize(0.5f, true, "Size of the leaf sprites.")]
[Serialize(0.5f, IsPropertySaveable.Yes, "Size of the leaf sprites.")]
public float BaseLeafScale { get; set; }
[Serialize("1.0,1.0,1.0,1.0", true, "Color of the leaves.")]
[Serialize("1.0,1.0,1.0,1.0", IsPropertySaveable.Yes, "Color of the leaves.")]
public Color LeafTint { get; set; }
[Serialize(0.33f, true, "Chance of a leaf appearing behind a branch.")]
[Serialize(0.33f, IsPropertySaveable.Yes, "Chance of a leaf appearing behind a branch.")]
public float LeafProbability { get; set; }
[Serialize("1.0,1.0,1.0,1.0", true, "Color of the vines.")]
[Serialize("1.0,1.0,1.0,1.0", IsPropertySaveable.Yes, "Color of the vines.")]
public Color VineTint { get; set; }
[Serialize(32, true, "Maximum number of vine tiles the plant can grow.")]
[Serialize(32, IsPropertySaveable.Yes, "Maximum number of vine tiles the plant can grow.")]
public int MaximumVines { get; set; }
[Serialize(0.25f, true, "Size of the vine sprites.")]
[Serialize(0.25f, IsPropertySaveable.Yes, "Size of the vine sprites.")]
public float VineScale { get; set; }
[Serialize("0.26,0.27,0.29,1.0", true, "Tint of a dead plant.")]
[Serialize("0.26,0.27,0.29,1.0", IsPropertySaveable.Yes, "Tint of a dead plant.")]
public Color DeadTint { get; set; }
[Serialize("1,1,1,1", true, "Probability for the plant to grow in a direction.")]
[Serialize("1,1,1,1", IsPropertySaveable.Yes, "Probability for the plant to grow in a direction.")]
public Vector4 GrowthWeights { get; set; }
[Serialize(0.0f, true, "How much damage is taken from fires.")]
[Serialize(0.0f, IsPropertySaveable.Yes, "How much damage is taken from fires.")]
public float FireVulnerability { get; set; }
private const float increasedDeathSpeed = 10f;
@@ -422,7 +432,7 @@ namespace Barotrauma.Items.Components
private static float MinFlowerScale = 0.5f, MaxFlowerScale = 1.0f, MinLeafScale = 0.5f, MaxLeafScale = 1.0f;
private const int VineChunkSize = 32;
public Growable(Item item, XElement element) : base(item, element)
public Growable(Item item, ContentXElement element) : base(item, element)
{
SerializableProperty.DeserializeProperties(this, element);
@@ -430,12 +440,12 @@ namespace Barotrauma.Items.Components
if (element.HasElements)
{
foreach (XElement subElement in element.Elements())
foreach (var subElement in element.Elements())
{
switch (subElement.Name.ToString().ToLowerInvariant())
{
case "produceditem":
ProducedItems.Add(new ProducedItem(subElement));
ProducedItems.Add(new ProducedItem(this.item, subElement));
break;
case "vinesprites":
LoadVines(subElement);
@@ -444,7 +454,7 @@ namespace Barotrauma.Items.Components
}
}
ProducedSeed = new ProducedItem(this.item.Prefab, 1.0f);
ProducedSeed = new ProducedItem(this.item, this.item.Prefab, 1.0f);
flowerTiles = new int[FlowerQuantity];
}
@@ -471,7 +481,7 @@ namespace Barotrauma.Items.Components
}
}
partial void LoadVines(XElement element);
partial void LoadVines(ContentXElement element);
public void OnGrowthTick(Planter planter, PlantSlot slot)
{
@@ -541,7 +551,7 @@ namespace Barotrauma.Items.Components
if (spawnProduct || spawnSeed)
{
VineTile vine = Vines.GetRandom();
VineTile vine = Vines.GetRandomUnsynced();
spawnPos = vine.GetWorldPosition(planter, slot.Offset);
}
else
@@ -564,9 +574,9 @@ namespace Barotrauma.Items.Components
{
if (producedItem.Prefab == null) { return; }
GameAnalyticsManager.AddDesignEvent("MicroInteraction:" + (GameMain.GameSession?.GameMode?.Preset.Identifier ?? "null") + ":GardeningProduce:" + thisItem.prefab.Identifier + ":" + producedItem.Prefab.Identifier);
GameAnalyticsManager.AddDesignEvent("MicroInteraction:" + (GameMain.GameSession?.GameMode?.Preset.Identifier.Value ?? "null") + ":GardeningProduce:" + thisItem.Prefab.Identifier + ":" + producedItem.Prefab.Identifier);
Entity.Spawner?.AddToSpawnQueue(producedItem.Prefab, pos, onSpawned: it =>
Entity.Spawner?.AddItemToSpawnQueue(producedItem.Prefab, pos, onSpawned: it =>
{
foreach (StatusEffect effect in producedItem.StatusEffects)
{
@@ -590,7 +600,7 @@ namespace Barotrauma.Items.Components
{
if (!Decayed)
{
GameAnalyticsManager.AddDesignEvent("MicroInteraction:" + (GameMain.GameSession?.GameMode?.Preset.Identifier ?? "null") + ":GardeningDied:" + item.prefab.Identifier);
GameAnalyticsManager.AddDesignEvent("MicroInteraction:" + (GameMain.GameSession?.GameMode?.Preset.Identifier.Value ?? "null") + ":GardeningDied:" + item.Prefab.Identifier);
}
Decayed = true;
@@ -881,14 +891,14 @@ namespace Barotrauma.Items.Components
return element;
}
public override void Load(XElement componentElement, bool usePrefabValues, IdRemap idRemap)
public override void Load(ContentXElement componentElement, bool usePrefabValues, IdRemap idRemap)
{
base.Load(componentElement, usePrefabValues, idRemap);
flowerTiles = componentElement.GetAttributeIntArray("flowertiles", new int[0]);
flowerTiles = componentElement.GetAttributeIntArray("flowertiles", Array.Empty<int>())!;
Decayed = componentElement.GetAttributeBool("decayed", false);
Vines.Clear();
foreach (XElement element in componentElement.Elements())
foreach (var element in componentElement.Elements())
{
if (element.Name.ToString().Equals("vine", StringComparison.OrdinalIgnoreCase))
{