Holdable items can be held in any limb slot, not just hands. + Characters can hold a flashlight in their mouth.
This commit is contained in:
@@ -219,7 +219,6 @@
|
|||||||
name="Flashlight"
|
name="Flashlight"
|
||||||
category="Equipment"
|
category="Equipment"
|
||||||
Tags="smallitem"
|
Tags="smallitem"
|
||||||
|
|
||||||
price="10">
|
price="10">
|
||||||
|
|
||||||
<Deconstruct time="15">
|
<Deconstruct time="15">
|
||||||
@@ -231,12 +230,11 @@
|
|||||||
|
|
||||||
<Body width="27" height="10" density="15"/>
|
<Body width="27" height="10" density="15"/>
|
||||||
|
|
||||||
<Holdable slots="Any,RightHand,LeftHand" aimpos="100,0" handle1="0,0">
|
<Holdable slots="Any,RightHand,LeftHand,Face" holdpos="100,0" aimpos="100,0" handle1="-13" handle2="-13">
|
||||||
<StatusEffect type="OnActive" target="Contained" Condition="-0.2"/>
|
<StatusEffect type="OnActive" target="Contained" Condition="-0.2"/>
|
||||||
</Holdable>
|
</Holdable>
|
||||||
|
|
||||||
<LightComponent LightColor="1.0,1.0,1.0,1.0" Flicker="0.1" range="800" powerconsumption="10" IsOn="true">
|
<LightComponent LightColor="1.0,1.0,1.0,1.0" Flicker="0.1" range="800" powerconsumption="10" IsOn="true">
|
||||||
|
|
||||||
<LightTexture texture="Content/Lights/lightcone.png" origin="0.0, 0.5" size="2.0,1.0"/>
|
<LightTexture texture="Content/Lights/lightcone.png" origin="0.0, 0.5" size="2.0,1.0"/>
|
||||||
</LightComponent>
|
</LightComponent>
|
||||||
|
|
||||||
|
|||||||
@@ -1011,8 +1011,6 @@ namespace Barotrauma
|
|||||||
|
|
||||||
public override void HoldItem(float deltaTime, Item item, Vector2[] handlePos, Vector2 holdPos, Vector2 aimPos, bool aim, float holdAngle)
|
public override void HoldItem(float deltaTime, Item item, Vector2[] handlePos, Vector2 holdPos, Vector2 aimPos, bool aim, float holdAngle)
|
||||||
{
|
{
|
||||||
Holdable holdable = item.GetComponent<Holdable>();
|
|
||||||
|
|
||||||
if (character.IsUnconscious || character.Stun > 0.0f) aim = false;
|
if (character.IsUnconscious || character.Stun > 0.0f) aim = false;
|
||||||
|
|
||||||
//calculate the handle positions
|
//calculate the handle positions
|
||||||
@@ -1030,7 +1028,6 @@ namespace Barotrauma
|
|||||||
|
|
||||||
bool usingController = character.SelectedConstruction != null && character.SelectedConstruction.GetComponent<Controller>() != null;
|
bool usingController = character.SelectedConstruction != null && character.SelectedConstruction.GetComponent<Controller>() != null;
|
||||||
|
|
||||||
|
|
||||||
float itemAngle;
|
float itemAngle;
|
||||||
if (Anim != Animation.Climbing && !usingController && character.Stun <= 0.0f && aim && itemPos != Vector2.Zero)
|
if (Anim != Animation.Climbing && !usingController && character.Stun <= 0.0f && aim && itemPos != Vector2.Zero)
|
||||||
{
|
{
|
||||||
@@ -1042,6 +1039,7 @@ namespace Barotrauma
|
|||||||
|
|
||||||
itemAngle = (torso.body.Rotation + holdAngle * Dir);
|
itemAngle = (torso.body.Rotation + holdAngle * Dir);
|
||||||
|
|
||||||
|
Holdable holdable = item.GetComponent<Holdable>();
|
||||||
if (holdable.ControlPose)
|
if (holdable.ControlPose)
|
||||||
{
|
{
|
||||||
head.body.SmoothRotate(itemAngle);
|
head.body.SmoothRotate(itemAngle);
|
||||||
|
|||||||
@@ -184,8 +184,8 @@ namespace Barotrauma.Items.Components
|
|||||||
item.SetTransform(rightHand.SimPosition, 0.0f);
|
item.SetTransform(rightHand.SimPosition, 0.0f);
|
||||||
}
|
}
|
||||||
|
|
||||||
bool alreadySelected = character.HasSelectedItem(item);
|
bool alreadySelected = character.HasEquippedItem(item);
|
||||||
if (picker.TrySelectItem(item))
|
if (picker.TrySelectItem(item) || picker.HasEquippedItem(item))
|
||||||
{
|
{
|
||||||
item.body.Enabled = true;
|
item.body.Enabled = true;
|
||||||
IsActive = true;
|
IsActive = true;
|
||||||
@@ -308,7 +308,7 @@ namespace Barotrauma.Items.Components
|
|||||||
public override void Update(float deltaTime, Camera cam)
|
public override void Update(float deltaTime, Camera cam)
|
||||||
{
|
{
|
||||||
if (item.body == null || !item.body.Enabled) return;
|
if (item.body == null || !item.body.Enabled) return;
|
||||||
if (picker == null || !picker.HasSelectedItem(item))
|
if (picker == null || !picker.HasEquippedItem(item))
|
||||||
{
|
{
|
||||||
IsActive = false;
|
IsActive = false;
|
||||||
return;
|
return;
|
||||||
@@ -320,7 +320,37 @@ namespace Barotrauma.Items.Components
|
|||||||
|
|
||||||
item.Submarine = picker.Submarine;
|
item.Submarine = picker.Submarine;
|
||||||
|
|
||||||
picker.AnimController.HoldItem(deltaTime, item, handlePos, holdPos, aimPos, picker.IsKeyDown(InputType.Aim), holdAngle);
|
if (picker.HasSelectedItem(item))
|
||||||
|
{
|
||||||
|
picker.AnimController.HoldItem(deltaTime, item, handlePos, holdPos, aimPos, picker.IsKeyDown(InputType.Aim), holdAngle);
|
||||||
|
}
|
||||||
|
else
|
||||||
|
{
|
||||||
|
Limb equipLimb = null;
|
||||||
|
if (picker.Inventory.IsInLimbSlot(item, InvSlotType.Face) || picker.Inventory.IsInLimbSlot(item, InvSlotType.Head))
|
||||||
|
{
|
||||||
|
equipLimb = picker.AnimController.GetLimb(LimbType.Head);
|
||||||
|
}
|
||||||
|
else if (picker.Inventory.IsInLimbSlot(item, InvSlotType.Torso))
|
||||||
|
{
|
||||||
|
equipLimb = picker.AnimController.GetLimb(LimbType.Torso);
|
||||||
|
}
|
||||||
|
else if (picker.Inventory.IsInLimbSlot(item, InvSlotType.Legs))
|
||||||
|
{
|
||||||
|
equipLimb = picker.AnimController.GetLimb(LimbType.Waist);
|
||||||
|
}
|
||||||
|
|
||||||
|
if (equipLimb != null)
|
||||||
|
{
|
||||||
|
float itemAngle = (equipLimb.Rotation + holdAngle * picker.AnimController.Dir);
|
||||||
|
|
||||||
|
Matrix itemTransfrom = Matrix.CreateRotationZ(equipLimb.Rotation);
|
||||||
|
Vector2 transformedHandlePos = Vector2.Transform(handlePos[0], itemTransfrom);
|
||||||
|
|
||||||
|
item.body.ResetDynamics();
|
||||||
|
item.SetTransform(equipLimb.SimPosition - transformedHandlePos, itemAngle);
|
||||||
|
}
|
||||||
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
protected void Flip(Item item)
|
protected void Flip(Item item)
|
||||||
|
|||||||
Reference in New Issue
Block a user