Added a light to diving suits (requires a battery to work). Closes #233

This commit is contained in:
Joonas Rikkonen
2018-03-02 13:11:28 +02:00
parent 12d1692bb5
commit f1f190a997
6 changed files with 28 additions and 10 deletions
@@ -226,8 +226,11 @@ namespace Barotrauma.Lights
Vector2 drawPos = Character.Controlled.DrawPosition;
drawPos.Y = -drawPos.Y;
//ambient light decreases the brightness of the halo (no need for a bright halo if the ambient light is bright enough)
float ambientBrightness = (AmbientLight.R + AmbientLight.B + AmbientLight.G) / 255.0f / 3.0f;
Color haloColor = Color.White * (1.0f - ambientBrightness);
spriteBatch.Draw(
LightSource.LightTexture, drawPos, null, Color.White * 0.3f, 0.0f,
LightSource.LightTexture, drawPos, null, haloColor * 0.4f, 0.0f,
new Vector2(LightSource.LightTexture.Width / 2, LightSource.LightTexture.Height / 2), 1.0f, SpriteEffects.None, 0.0f);
}
spriteBatch.End();
@@ -220,6 +220,9 @@
<CopyToOutputDirectory>PreserveNewest</CopyToOutputDirectory>
</Content>
<Content Include="$(MSBuildThisFileDirectory)Content\damageshader.fx" />
<Content Include="$(MSBuildThisFileDirectory)Content\Items\Diving\DivingSuitLight.png">
<CopyToOutputDirectory>PreserveNewest</CopyToOutputDirectory>
</Content>
<Content Include="$(MSBuildThisFileDirectory)Content\Texts.xml">
<CopyToOutputDirectory>PreserveNewest</CopyToOutputDirectory>
</Content>
Binary file not shown.

After

Width:  |  Height:  |  Size: 28 KiB

@@ -81,14 +81,14 @@
<Body width="37" height="113" density="15"/>
<Wearable slots="Head+Torso+Legs">
<sprite texture="DivingSuit.png" limb="Head" sourcerect="0,0,1,1" origin="0.5,0.5" hidelimb="true">
<LightComponent LightColor="1.0,1.0,1.0,1.0" Flicker="0.2" range="800">
<LightTexture texture="Content/Lights/lightcone.png" origin="0.05, 0.5" size="2.0,1.0"/>
<sprite texture="DivingSuit.png" limb="Head" sourcerect="0,0,1,1" origin="0.5,0.5" hidelimb="true"/>
<sprite texture="DivingSuit.png" limb="Torso" sourcerect="42,0,42,97" origin="0.5,0.55" depth="0.004" inheritlimbdepth="false" depthlimb="Head" hidelimb="true">
<LightComponent range="100.0" lightcolor="1.0,1.0,1.0,0.1" powerconsumption="10" IsOn="true">
<sprite texture="Content/Items/Diving/DivingSuitLight.png" depth="0.025" origin="0.1,0.82" alpha="1.0"/>
</LightComponent>
</sprite>
<sprite texture="DivingSuit.png" limb="Torso" sourcerect="42,0,42,97" origin="0.5,0.55" depth="0.004" inheritlimbdepth="false" depthlimb="Head" hidelimb="true"/>
<sprite texture="DivingSuit.png" limb="RightHand" sourcerect="0,78,15,50" origin="0.45,0.4" depth="0.0" inheritlimbdepth="false" hidelimb="true"/>
<sprite texture="DivingSuit.png" limb="LeftHand" sourcerect="0,78,15,50" origin="0.45,0.4" depth="0.016" inheritlimbdepth="false" hidelimb="true"/>
@@ -121,10 +121,13 @@
<damagemodifier damagetype="Slash" armorsector="0.0,360.0" damagemultiplier="0.5" bleedingmultiplier="0.0" damagesound="LimbArmor" deflectprojectiles="true"/>
</Wearable>
<ItemContainer capacity="1" hideitems="true">
<ItemContainer capacity="2" hideitems="true">
<Containable name="Oxygen Tank"/>
<Containable name="Welding Fuel Tank"/>
<Containable name="Oxygenite Shard"/>
<Containable name="Battery Cell, Fulgurium Battery Cell">
<StatusEffect type="OnContaining" target="This" Voltage="1.0" setvalue="true"/>
</Containable>
</ItemContainer>
</Item>
@@ -4,6 +4,7 @@ using System.Xml.Linq;
using Barotrauma.Networking;
using Lidgren.Network;
#if CLIENT
using Microsoft.Xna.Framework.Graphics;
using Barotrauma.Lights;
#endif
@@ -144,6 +145,7 @@ namespace Barotrauma.Items.Components
{
#if CLIENT
light.Rotation = body.Dir > 0.0f ? body.Rotation : body.Rotation - MathHelper.Pi;
light.LightSpriteEffect = (body.Dir > 0.0f) ? SpriteEffects.None : SpriteEffects.FlipVertically;
#endif
if (!body.Enabled)
{
@@ -505,11 +505,18 @@ namespace Barotrauma.Networking
if (divingSuitPrefab != null && oxyPrefab != null)
{
var divingSuit = new Item(divingSuitPrefab, pos, respawnSub);
Entity.Spawner.CreateNetworkEvent(divingSuit, false);
Spawner.CreateNetworkEvent(divingSuit, false);
var oxyTank = new Item(oxyPrefab, pos, respawnSub);
Entity.Spawner.CreateNetworkEvent(oxyTank, false);
divingSuit.Combine(oxyTank);
Spawner.CreateNetworkEvent(oxyTank, false);
divingSuit.Combine(oxyTank);
if (batteryPrefab != null)
{
var battery = new Item(batteryPrefab, pos, respawnSub);
Spawner.CreateNetworkEvent(battery, false);
divingSuit.Combine(battery);
}
}
if (scooterPrefab != null && batteryPrefab != null)