Wearables can attach lightsources to limbs
This commit is contained in:
@@ -81,7 +81,11 @@
|
|||||||
<Body width="37" height="113" density="15"/>
|
<Body width="37" height="113" density="15"/>
|
||||||
|
|
||||||
<Wearable slots="Head+Torso+Legs">
|
<Wearable slots="Head+Torso+Legs">
|
||||||
<sprite texture="DivingSuit.png" limb="Head" sourcerect="0,0,1,1" origin="0.5,0.5" hidelimb="true"/>
|
<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"/>
|
||||||
|
</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="Torso" sourcerect="42,0,42,97" origin="0.5,0.55" depth="0.004" inheritlimbdepth="false" depthlimb="Head" hidelimb="true"/>
|
||||||
|
|
||||||
|
|||||||
@@ -21,6 +21,8 @@ namespace Barotrauma.Items.Components
|
|||||||
|
|
||||||
private bool castShadows;
|
private bool castShadows;
|
||||||
|
|
||||||
|
public PhysicsBody ParentBody;
|
||||||
|
|
||||||
[Editable(0.0f, 2048.0f), Serialize(100.0f, true)]
|
[Editable(0.0f, 2048.0f), Serialize(100.0f, true)]
|
||||||
public float Range
|
public float Range
|
||||||
{
|
{
|
||||||
@@ -133,15 +135,17 @@ namespace Barotrauma.Items.Components
|
|||||||
light.Color = Color.Transparent;
|
light.Color = Color.Transparent;
|
||||||
return;
|
return;
|
||||||
}
|
}
|
||||||
light.Position = item.Position;
|
light.Position = ParentBody != null ? ParentBody.Position : item.Position;
|
||||||
#endif
|
#endif
|
||||||
|
|
||||||
if (item.body != null)
|
PhysicsBody body = ParentBody ?? item.body;
|
||||||
|
|
||||||
|
if (body != null)
|
||||||
{
|
{
|
||||||
#if CLIENT
|
#if CLIENT
|
||||||
light.Rotation = item.body.Dir > 0.0f ? item.body.Rotation : item.body.Rotation - MathHelper.Pi;
|
light.Rotation = body.Dir > 0.0f ? body.Rotation : body.Rotation - MathHelper.Pi;
|
||||||
#endif
|
#endif
|
||||||
if (!item.body.Enabled)
|
if (!body.Enabled)
|
||||||
{
|
{
|
||||||
#if CLIENT
|
#if CLIENT
|
||||||
light.Color = Color.Transparent;
|
light.Color = Color.Transparent;
|
||||||
|
|||||||
@@ -15,6 +15,8 @@ namespace Barotrauma.Items.Components
|
|||||||
public readonly bool InheritLimbDepth;
|
public readonly bool InheritLimbDepth;
|
||||||
public readonly LimbType DepthLimb;
|
public readonly LimbType DepthLimb;
|
||||||
|
|
||||||
|
public LightComponent LightComponent;
|
||||||
|
|
||||||
public readonly Wearable WearableComponent;
|
public readonly Wearable WearableComponent;
|
||||||
public readonly string Sound;
|
public readonly string Sound;
|
||||||
|
|
||||||
@@ -80,6 +82,14 @@ namespace Barotrauma.Items.Components
|
|||||||
subElement.GetAttributeBool("inheritlimbdepth", true),
|
subElement.GetAttributeBool("inheritlimbdepth", true),
|
||||||
(LimbType)Enum.Parse(typeof(LimbType), subElement.GetAttributeString("depthlimb", "None"), true), sound);
|
(LimbType)Enum.Parse(typeof(LimbType), subElement.GetAttributeString("depthlimb", "None"), true), sound);
|
||||||
|
|
||||||
|
foreach (XElement lightElement in subElement.Elements())
|
||||||
|
{
|
||||||
|
if (lightElement.Name.ToString().ToLowerInvariant() != "lightcomponent") continue;
|
||||||
|
wearableSprites[i].LightComponent = new LightComponent(item, lightElement);
|
||||||
|
wearableSprites[i].LightComponent.Parent = this;
|
||||||
|
item.components.Add(wearableSprites[i].LightComponent);
|
||||||
|
}
|
||||||
|
|
||||||
i++;
|
i++;
|
||||||
break;
|
break;
|
||||||
case "damagemodifier":
|
case "damagemodifier":
|
||||||
@@ -98,8 +108,11 @@ namespace Barotrauma.Items.Components
|
|||||||
if (equipLimb == null) continue;
|
if (equipLimb == null) continue;
|
||||||
|
|
||||||
item.body.Enabled = false;
|
item.body.Enabled = false;
|
||||||
|
|
||||||
IsActive = true;
|
IsActive = true;
|
||||||
|
if (wearableSprites[i].LightComponent != null)
|
||||||
|
{
|
||||||
|
wearableSprites[i].LightComponent.ParentBody = equipLimb.body;
|
||||||
|
}
|
||||||
|
|
||||||
limb[i] = equipLimb;
|
limb[i] = equipLimb;
|
||||||
if (!equipLimb.WearingItems.Contains(wearableSprites[i]))
|
if (!equipLimb.WearingItems.Contains(wearableSprites[i]))
|
||||||
@@ -127,6 +140,11 @@ namespace Barotrauma.Items.Components
|
|||||||
Limb equipLimb = character.AnimController.GetLimb(limbType[i]);
|
Limb equipLimb = character.AnimController.GetLimb(limbType[i]);
|
||||||
if (equipLimb == null) continue;
|
if (equipLimb == null) continue;
|
||||||
|
|
||||||
|
if (wearableSprites[i].LightComponent != null)
|
||||||
|
{
|
||||||
|
wearableSprites[i].LightComponent.ParentBody = null;
|
||||||
|
}
|
||||||
|
|
||||||
equipLimb.WearingItems.RemoveAll(w => w != null && w == wearableSprites[i]);
|
equipLimb.WearingItems.RemoveAll(w => w != null && w == wearableSprites[i]);
|
||||||
|
|
||||||
limb[i] = null;
|
limb[i] = null;
|
||||||
|
|||||||
Reference in New Issue
Block a user