(3a5d98b) v0.9.6.0
This commit is contained in:
@@ -258,7 +258,7 @@ namespace Barotrauma.Items.Components
|
||||
|
||||
foreach (StatusEffect effect in recipient.Effects)
|
||||
{
|
||||
recipient.Item.ApplyStatusEffect(effect, ActionType.OnUse, (float)Timing.Step, null, null, false, false);
|
||||
recipient.Item.ApplyStatusEffect(effect, ActionType.OnUse, (float)Timing.Step);
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
@@ -35,6 +35,11 @@ namespace Barotrauma.Items.Components
|
||||
set { /*do nothing*/ }
|
||||
}
|
||||
|
||||
public Character User
|
||||
{
|
||||
get { return user; }
|
||||
}
|
||||
|
||||
public ConnectionPanel(Item item, XElement element)
|
||||
: base(item, element)
|
||||
{
|
||||
@@ -126,6 +131,9 @@ namespace Barotrauma.Items.Components
|
||||
|
||||
if (user == null || user.SelectedConstruction != item)
|
||||
{
|
||||
#if SERVER
|
||||
if (user != null) { item.CreateServerEvent(this); }
|
||||
#endif
|
||||
user = null;
|
||||
return;
|
||||
}
|
||||
@@ -135,6 +143,11 @@ namespace Barotrauma.Items.Components
|
||||
user.AnimController.UpdateUseItem(true, item.WorldPosition + new Vector2(0.0f, 100.0f) * (((float)Timing.TotalTime / 10.0f) % 0.1f));
|
||||
}
|
||||
|
||||
public override void UpdateBroken(float deltaTime, Camera cam)
|
||||
{
|
||||
Update(deltaTime, cam);
|
||||
}
|
||||
|
||||
partial void UpdateProjSpecific(float deltaTime);
|
||||
|
||||
public override bool Select(Character picker)
|
||||
@@ -147,13 +160,16 @@ namespace Barotrauma.Items.Components
|
||||
}
|
||||
|
||||
user = picker;
|
||||
#if SERVER
|
||||
if (user != null) { item.CreateServerEvent(this); }
|
||||
#endif
|
||||
IsActive = true;
|
||||
return true;
|
||||
}
|
||||
|
||||
public override bool Use(float deltaTime, Character character = null)
|
||||
{
|
||||
if (character == null || character != user) return false;
|
||||
if (character == null || character != user) { return false; }
|
||||
|
||||
var powered = item.GetComponent<Powered>();
|
||||
if (powered != null)
|
||||
@@ -257,6 +273,10 @@ namespace Barotrauma.Items.Components
|
||||
|
||||
public void ClientWrite(IWriteMessage msg, object[] extraData = null)
|
||||
{
|
||||
#if CLIENT
|
||||
TriggerRewiringSound();
|
||||
#endif
|
||||
|
||||
foreach (Connection connection in Connections)
|
||||
{
|
||||
foreach (Wire wire in connection.Wires)
|
||||
|
||||
@@ -172,7 +172,7 @@ namespace Barotrauma.Items.Components
|
||||
|
||||
foreach (StatusEffect effect in ciElement.StatusEffects)
|
||||
{
|
||||
item.ApplyStatusEffect(effect, ciElement.State ? ActionType.OnUse : ActionType.OnSecondaryUse, 1.0f, null, null, true, false);
|
||||
item.ApplyStatusEffect(effect, ciElement.State ? ActionType.OnUse : ActionType.OnSecondaryUse, 1.0f, null, null, null, true, false);
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
@@ -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);
|
||||
}
|
||||
}
|
||||
|
||||
@@ -102,7 +102,7 @@ namespace Barotrauma.Items.Components
|
||||
|
||||
public override void ReceivePowerProbeSignal(Connection connection, Item source, float power)
|
||||
{
|
||||
if (!IsOn) { return; }
|
||||
if (!IsOn || item.Condition <= 0.0f) { return; }
|
||||
|
||||
//we've already received this signal
|
||||
if (lastPowerProbeRecipients.Contains(this)) { return; }
|
||||
|
||||
Reference in New Issue
Block a user