(3a5d98b) v0.9.6.0

This commit is contained in:
Regalis
2019-12-17 14:38:24 +01:00
parent 5c95c53118
commit a3569b8bf0
95 changed files with 1579 additions and 728 deletions
@@ -34,7 +34,7 @@ namespace Barotrauma.Items.Components
{
range = MathHelper.Clamp(value, 0.0f, 4096.0f);
#if CLIENT
if (light != null) light.Range = range;
if (light != null) { light.Range = range; }
#endif
}
}
@@ -75,7 +75,7 @@ namespace Barotrauma.Items.Components
get { return IsActive; }
set
{
if (IsActive == value) return;
if (IsActive == value) { return; }
IsActive = value;
#if SERVER
@@ -135,11 +135,8 @@ namespace Barotrauma.Items.Components
{
if (base.IsActive == value) { return; }
base.IsActive = value;
#if CLIENT
if (light == null) return;
light.Color = value ? lightColor : Color.Transparent;
if (!value) lightBrightness = 0.0f;
#endif
SetLightSourceState(value, value ? lightBrightness : 0.0f);
}
}
@@ -153,7 +150,8 @@ namespace Barotrauma.Items.Components
Position = item.Position,
CastShadows = castShadows,
IsBackground = drawBehindSubs,
SpriteScale = Vector2.One * item.Scale
SpriteScale = Vector2.One * item.Scale,
Range = range
};
#endif
@@ -161,40 +159,34 @@ namespace Barotrauma.Items.Components
item.AddTag("light");
}
#if CLIENT
public override void OnScaleChanged()
{
light.SpriteScale = Vector2.One * item.Scale;
light.Position = ParentBody != null ? ParentBody.Position : item.Position;
}
#endif
public override void OnItemLoaded()
{
base.OnItemLoaded();
itemLoaded = true;
#if CLIENT
light.Color = IsActive ? lightColor : Color.Transparent;
if (!IsActive) lightBrightness = 0.0f;
#endif
SetLightSourceState(IsActive, lightBrightness);
}
public override void Update(float deltaTime, Camera cam)
{
if (item.AiTarget != null)
{
UpdateAITarget(item.AiTarget);
}
UpdateOnActiveEffects(deltaTime);
#if CLIENT
light.ParentSub = item.Submarine;
#endif
if (item.Container != null)
{
light.Color = Color.Transparent;
SetLightSourceState(false, 0.0f);
return;
}
#if CLIENT
light.Position = ParentBody != null ? ParentBody.Position : item.Position;
#endif
PhysicsBody body = ParentBody ?? item.body;
if (body != null)
{
#if CLIENT
@@ -203,9 +195,7 @@ namespace Barotrauma.Items.Components
#endif
if (!body.Enabled)
{
#if CLIENT
light.Color = Color.Transparent;
#endif
SetLightSourceState(false, 0.0f);
return;
}
}
@@ -217,7 +207,6 @@ namespace Barotrauma.Items.Components
}
currPowerConsumption = powerConsumption;
if (Rand.Range(0.0f, 1.0f) < 0.05f && Voltage < Rand.Range(0.0f, MinVoltage))
{
#if CLIENT
@@ -240,36 +229,21 @@ namespace Barotrauma.Items.Components
if (blinkTimer > 0.5f)
{
#if CLIENT
light.Color = Color.Transparent;
#endif
SetLightSourceState(false, lightBrightness);
}
else
{
#if CLIENT
light.Color = lightColor * lightBrightness * (1.0f - Rand.Range(0.0f, Flicker));
light.Range = range;
#endif
SetLightSourceState(true, lightBrightness * (1.0f - Rand.Range(0.0f, flicker)));
}
if (item.AiTarget != null)
{
UpdateAITarget(item.AiTarget);
}
}
#if CLIENT
public override void UpdateBroken(float deltaTime, Camera cam)
{
light.Color = Color.Transparent;
lightBrightness = 0.0f;
if (powerIn == null && powerConsumption > 0.0f) { Voltage -= deltaTime; }
}
protected override void RemoveComponentSpecific()
public override void UpdateBroken(float deltaTime, Camera cam)
{
base.RemoveComponentSpecific();
light.Remove();
SetLightSourceState(false, 0.0f);
}
#endif
public override bool Use(float deltaTime, Character character = null)
{
return true;
@@ -277,8 +251,6 @@ namespace Barotrauma.Items.Components
public override void ReceiveSignal(int stepsTaken, string signal, Connection connection, Item source, Character sender, float power = 0.0f, float signalStrength = 1.0f)
{
base.ReceiveSignal(stepsTaken, signal, connection, source, sender, power, signalStrength);
switch (connection.Name)
{
case "toggle":
@@ -300,13 +272,14 @@ namespace Barotrauma.Items.Components
private void UpdateAITarget(AITarget target)
{
//voltage > minVoltage || powerConsumption <= 0.0f; <- ?
target.Enabled = IsActive;
if (!IsActive) { return; }
if (target.MaxSightRange <= 0)
{
target.MaxSightRange = Range * 5;
}
target.SightRange = IsActive ? target.MaxSightRange * lightBrightness : 0;
target.SightRange = target.MaxSightRange * lightBrightness;
}
partial void SetLightSourceState(bool enabled, float brightness);
}
}