(d9829ac) v0.9.4.0

This commit is contained in:
Regalis
2019-10-24 18:05:42 +02:00
parent 9aa12bcac2
commit b39922a074
319 changed files with 12516 additions and 6815 deletions
@@ -22,6 +22,7 @@ namespace Barotrauma
{
LoadConfig(configPath);
}
public BackgroundCreatureManager(IEnumerable<string> files)
{
foreach(var file in files)
@@ -29,14 +30,26 @@ namespace Barotrauma
LoadConfig(file);
}
}
private void LoadConfig(string configPath)
{
try
{
XDocument doc = XMLExtensions.TryLoadXml(configPath);
if (doc == null || doc.Root == null) return;
if (doc == null) { return; }
var mainElement = doc.Root;
if (mainElement.IsOverride())
{
mainElement = doc.Root.FirstElement();
prefabs.Clear();
DebugConsole.NewMessage($"Overriding all background creatures with '{configPath}'", Color.Yellow);
}
else if (prefabs.Any())
{
DebugConsole.NewMessage($"Loading additional background creatures from file '{configPath}'");
}
foreach (XElement element in doc.Root.Elements())
foreach (XElement element in mainElement.Elements())
{
prefabs.Add(new BackgroundCreaturePrefab(element));
};
@@ -46,6 +59,7 @@ namespace Barotrauma
DebugConsole.ThrowError(String.Format("Failed to load BackgroundCreatures from {0}", configPath), e);
}
}
public void SpawnSprites(int count, Vector2? position = null)
{
activeSprites.Clear();
@@ -41,7 +41,7 @@ namespace Barotrauma
{
if (subElement.Name.ToString().ToLowerInvariant() != "sprite") continue;
Sprite = new Sprite(subElement);
Sprite = new Sprite(subElement, lazyLoad: true);
break;
}
}
@@ -132,7 +132,7 @@ namespace Barotrauma
var newDeformation = SpriteDeformation.Load(animationElement, Prefab.Name);
if (newDeformation != null)
{
newDeformation.DeformationParams = Prefab.SpriteDeformations[j].DeformationParams;
newDeformation.Params = Prefab.SpriteDeformations[j].Params;
spriteDeformations.Add(newDeformation);
j++;
}
@@ -72,6 +72,11 @@ namespace Barotrauma.Lights
private float ambientLightUpdateTimer;
public IEnumerable<LightSource> Lights
{
get { return lights; }
}
public LightManager(GraphicsDevice graphics, ContentManager content)
{
lights = new List<LightSource>();
@@ -10,15 +10,11 @@ namespace Barotrauma.Lights
{
class LightSourceParams : ISerializableEntity
{
public string Name => "LightSource";
public string Name => "Light Source";
public bool Persistent;
public Dictionary<string, SerializableProperty> SerializableProperties
{
get;
private set;
} = new Dictionary<string, SerializableProperty>();
public Dictionary<string, SerializableProperty> SerializableProperties { get; private set; } = new Dictionary<string, SerializableProperty>();
[Serialize("1.0,1.0,1.0,1.0", true), Editable]
public Color Color
@@ -28,6 +24,7 @@ namespace Barotrauma.Lights
}
private float range;
[Serialize(100.0f, true), Editable(MinValueFloat = 0.0f, MaxValueFloat = 2048.0f)]
public float Range
{
@@ -64,7 +61,7 @@ namespace Barotrauma.Lights
public LightSourceParams(XElement element)
{
SerializableProperties = SerializableProperty.DeserializeProperties(this, element);
Deserialize(element);
foreach (XElement subElement in element.Elements())
{
@@ -103,6 +100,17 @@ namespace Barotrauma.Lights
Range = range;
Color = color;
}
public bool Deserialize(XElement element)
{
SerializableProperties = SerializableProperty.DeserializeProperties(this, element);
return SerializableProperties != null;
}
public void Serialize(XElement element)
{
SerializableProperty.SerializeProperties(this, element, true);
}
}
class LightSource
@@ -893,13 +901,21 @@ namespace Barotrauma.Lights
if (GameMain.DebugDraw)
{
Vector2 drawPos = position;
if (ParentSub != null) { drawPos += ParentSub.DrawPosition; }
drawPos.Y = -drawPos.Y;
if (CastShadows && Screen.Selected == GameMain.SubEditorScreen)
{
GUI.DrawRectangle(spriteBatch, drawPos - Vector2.One * 20, Vector2.One * 40, Color.Orange, isFilled: false);
GUI.DrawLine(spriteBatch, drawPos - Vector2.One * 20, drawPos + Vector2.One * 20, Color.Orange);
GUI.DrawLine(spriteBatch, drawPos - new Vector2(1.0f, -1.0f) * 20, drawPos + new Vector2(1.0f, -1.0f) * 20, Color.Orange);
}
//visualize light recalculations
float timeSinceRecalculation = (float)Timing.TotalTime - lastRecalculationTime;
if (timeSinceRecalculation < 0.1f)
{
Vector2 drawPos = position;
if (ParentSub != null) drawPos += ParentSub.DrawPosition;
drawPos.Y = -drawPos.Y;
GUI.DrawRectangle(spriteBatch, drawPos - Vector2.One * 10, Vector2.One * 20, Color.Red * (1.0f - timeSinceRecalculation * 10.0f), isFilled: true);
GUI.DrawLine(spriteBatch, drawPos - Vector2.One * Range, drawPos + Vector2.One * Range, Color);
GUI.DrawLine(spriteBatch, drawPos - new Vector2(1.0f, -1.0f) * Range, drawPos + new Vector2(1.0f, -1.0f) * Range, Color);
@@ -92,7 +92,7 @@ namespace Barotrauma
public virtual void Draw(SpriteBatch spriteBatch, bool editing, bool back = true) { }
public virtual void DrawDamage(SpriteBatch spriteBatch, Effect damageEffect) { }
public virtual void DrawDamage(SpriteBatch spriteBatch, Effect damageEffect, bool editing) { }
/// <summary>
/// Update the selection logic in submarine editor
@@ -170,9 +170,9 @@ namespace Barotrauma
Draw(spriteBatch, editing, back, null);
}
public override void DrawDamage(SpriteBatch spriteBatch, Effect damageEffect)
public override void DrawDamage(SpriteBatch spriteBatch, Effect damageEffect, bool editing)
{
Draw(spriteBatch, false, false, damageEffect);
Draw(spriteBatch, editing, false, damageEffect);
}
private void Draw(SpriteBatch spriteBatch, bool editing, bool back = true, Effect damageEffect = null)
@@ -265,7 +265,7 @@ namespace Barotrauma
}
}
if (back == depth > 0.5f || editing)
if (back == depth > 0.5f)
{
SpriteEffects oldEffects = prefab.sprite.effects;
prefab.sprite.effects ^= SpriteEffects;
@@ -235,7 +235,7 @@ namespace Barotrauma
foreach (MapEntity e in entitiesToRender)
{
if (e.DrawDamageEffect)
e.DrawDamage(spriteBatch, damageEffect);
e.DrawDamage(spriteBatch, damageEffect, editing);
}
if (damageEffect != null)
{
@@ -301,7 +301,7 @@ namespace Barotrauma
}
};
jobDropDown.AddItem(TextManager.Get("Any"), null);
foreach (JobPrefab jobPrefab in JobPrefab.List)
foreach (JobPrefab jobPrefab in JobPrefab.List.Values)
{
jobDropDown.AddItem(jobPrefab.Name, jobPrefab);
}