Handheld sonars only consume batteries when they're on, endworms aren't "flipped" when they turn around, every limb is checked in SubmarineBody.DisplaceCharacters (instead of just reflimb)

This commit is contained in:
Regalis
2016-04-24 20:31:26 +03:00
parent d4816c3ee9
commit c08029dea8
8 changed files with 52 additions and 32 deletions
@@ -5,40 +5,40 @@
<sound file="Content/Characters/Endworm/endwormattack1.ogg" state="Attack" range="8000" /> <sound file="Content/Characters/Endworm/endwormattack1.ogg" state="Attack" range="8000" />
<sound file="Content/Characters/Endworm/endwormattack2.ogg" state="Attack" range="8000" /> <sound file="Content/Characters/Endworm/endwormattack2.ogg" state="Attack" range="8000" />
<ragdoll waveamplitude="100.0" wavelength="1000" speed="1.5" scale ="2.0"> <ragdoll waveamplitude="100.0" wavelength="1000" speed="1.5" scale ="2.0" flip="false" canentersubmarine="false">
<!-- head --> <!-- head -->
<limb id = "0" width="600" height="450" type="Head" steerforce="3.0"> <limb id = "0" radius="300" type="Head" steerforce="3.0">
<sprite texture="Content/Characters/Endworm/endworm.png" sourcerect="0,478,720,546" depth="0.05"/> <sprite texture="Content/Characters/Endworm/endworm.png" sourcerect="0,478,720,546" depth="0.05"/>
</limb> </limb>
<!-- body --> <!-- body -->
<limb id = "1" width="600" height="400" type="Torso"> <limb id = "1" radius="300" type="Torso">
<sprite texture="Content/Characters/Endworm/endworm.png" sourcerect="0,0,702,448" depth="0.01" origin="0.5,0.5"/> <sprite texture="Content/Characters/Endworm/endworm.png" sourcerect="0,0,702,448" depth="0.01" origin="0.5,0.5"/>
</limb> </limb>
<!-- body --> <!-- body -->
<limb id = "2" width="600" height="400" type="Torso"> <limb id = "2" radius="300" type="Torso">
<sprite texture="Content/Characters/Endworm/endworm.png" sourcerect="0,0,702,448" depth="0.02" origin="0.5,0.5"/> <sprite texture="Content/Characters/Endworm/endworm.png" sourcerect="0,0,702,448" depth="0.02" origin="0.5,0.5"/>
</limb> </limb>
<limb id = "3" width="600" height="400" type="Torso"> <limb id = "3" radius="300" type="Torso">
<sprite texture="Content/Characters/Endworm/endworm.png" sourcerect="0,0,702,448" depth="0.03" origin="0.5,0.5"/> <sprite texture="Content/Characters/Endworm/endworm.png" sourcerect="0,0,702,448" depth="0.03" origin="0.5,0.5"/>
</limb> </limb>
<limb id = "4" width="600" height="400" type="Tail"> <limb id = "4" radius="300" type="Tail">
<sprite texture="Content/Characters/Endworm/endworm.png" sourcerect="0,0,702,448" depth="0.04" origin="0.5,0.5"/> <sprite texture="Content/Characters/Endworm/endworm.png" sourcerect="0,0,702,448" depth="0.04" origin="0.5,0.5"/>
</limb> </limb>
<limb id = "5" width="600" height="400" type="Tail"> <limb id = "5" radius="300" type="Tail">
<sprite texture="Content/Characters/Endworm/endworm.png" sourcerect="0,0,702,448" depth="0.05" origin="0.5,0.5"/> <sprite texture="Content/Characters/Endworm/endworm.png" sourcerect="0,0,702,448" depth="0.05" origin="0.5,0.5"/>
</limb> </limb>
<limb id = "6" width="600" height="400" type="Tail"> <limb id = "6" radius="300" type="Tail">
<sprite texture="Content/Characters/Endworm/endworm.png" sourcerect="0,0,702,448" depth="0.06" origin="0.5,0.5"/> <sprite texture="Content/Characters/Endworm/endworm.png" sourcerect="0,0,702,448" depth="0.06" origin="0.5,0.5"/>
</limb> </limb>
<limb id = "7" width="300" height="400" type="Tail"> <limb id = "7" radius="150" type="Tail">
<sprite texture="Content/Characters/Endworm/endworm.png" sourcerect="704,0,320,400" depth="0.07" origin="0.5,0.5"/> <sprite texture="Content/Characters/Endworm/endworm.png" sourcerect="704,0,320,400" depth="0.07" origin="0.5,0.5"/>
</limb> </limb>
@@ -6,7 +6,7 @@
<sound file="Content/Characters/Moloch/idle1.ogg" state="None" range="3000"/> <sound file="Content/Characters/Moloch/idle1.ogg" state="None" range="3000"/>
<sound file="Content/Characters/Moloch/idle2.ogg" state="None" range="3000"/> <sound file="Content/Characters/Moloch/idle2.ogg" state="None" range="3000"/>
<ragdoll waveamplitude="0.0" swimspeed="1.0" walkspeed="0.3" flip="true" rotatetowardsmovement="false" headangle="-90"> <ragdoll waveamplitude="0.0" swimspeed="1.0" walkspeed="0.3" mirror="true" rotatetowardsmovement="false" headangle="-90">
<!-- head --> <!-- head -->
<limb id = "0" radius="230" height="500" type="Head" steerforce="1.0" flip="true" armorsector="0.0,180.0" armorvalue="100.0" impacttolerance="100"> <limb id = "0" radius="230" height="500" type="Head" steerforce="1.0" flip="true" armorsector="0.0,180.0" armorvalue="100.0" impacttolerance="100">
@@ -1,7 +1,7 @@
<?xml version="1.0" encoding="utf-8" ?> <?xml version="1.0" encoding="utf-8" ?>
<Character name ="watcher" humanoid="false" health ="1000"> <Character name ="watcher" humanoid="false" health ="1000">
<ragdoll waveamplitude="0.0" swimspeed="0.5" walkspeed="0.3" flip="true" rotatetowardsmovement="false" headangle="-90"> <ragdoll waveamplitude="0.0" swimspeed="0.5" walkspeed="0.3" mirror="true" rotatetowardsmovement="false" headangle="-90">
<!-- head --> <!-- head -->
<limb id = "0" width="350" height="320" type="Head" steerforce="1.0" flip="true" armorsector="0.0,360.0" armorvalue="100.0"> <limb id = "0" width="350" height="320" type="Head" steerforce="1.0" flip="true" armorsector="0.0,360.0" armorvalue="100.0">
+1 -1
View File
@@ -199,6 +199,7 @@
holdangle="30" handle1="-10,0"/> holdangle="30" handle1="-10,0"/>
<Radar range="6000.0" powerconsumption="10" drawhudwhenequipped="true" detectsubmarinewalls="true"> <Radar range="6000.0" powerconsumption="10" drawhudwhenequipped="true" detectsubmarinewalls="true">
<StatusEffect type="OnUse" target="Contained" Condition="-1.0" disabledeltatime="true"/>
<sound file="Content/Items/Engine/radarPing.ogg" type="OnUse" range="1000.0"/> <sound file="Content/Items/Engine/radarPing.ogg" type="OnUse" range="1000.0"/>
<GuiFrame rect="0,0,0.5,0.5" alignment="Center" color="0.0,0.0,0.0,0.6"/> <GuiFrame rect="0,0,0.5,0.5" alignment="Center" color="0.0,0.0,0.0,0.6"/>
<PingCircle texture="Content/Items/Engine/pingCircle.png" origin="0.5,0.5"/> <PingCircle texture="Content/Items/Engine/pingCircle.png" origin="0.5,0.5"/>
@@ -208,7 +209,6 @@
<ItemContainer capacity="1" hideitems="true"> <ItemContainer capacity="1" hideitems="true">
<Containable name="Battery Cell"> <Containable name="Battery Cell">
<StatusEffect type="OnContaining" target="This" Voltage="1.0" setvalue="true"/> <StatusEffect type="OnContaining" target="This" Voltage="1.0" setvalue="true"/>
<StatusEffect type="OnContaining" target="Contained" Condition="-0.5"/>
</Containable> </Containable>
</ItemContainer> </ItemContainer>
</Item> </Item>
@@ -17,7 +17,7 @@ namespace Barotrauma
private bool rotateTowardsMovement; private bool rotateTowardsMovement;
private bool flip; private bool mirror, flip;
private float flipTimer; private float flipTimer;
@@ -29,7 +29,8 @@ namespace Barotrauma
waveAmplitude = ConvertUnits.ToSimUnits(ToolBox.GetAttributeFloat(element, "waveamplitude", 0.0f)); waveAmplitude = ConvertUnits.ToSimUnits(ToolBox.GetAttributeFloat(element, "waveamplitude", 0.0f));
waveLength = ConvertUnits.ToSimUnits(ToolBox.GetAttributeFloat(element, "wavelength", 0.0f)); waveLength = ConvertUnits.ToSimUnits(ToolBox.GetAttributeFloat(element, "wavelength", 0.0f));
flip = ToolBox.GetAttributeBool(element, "flip", false); flip = ToolBox.GetAttributeBool(element, "flip", true);
mirror = ToolBox.GetAttributeBool(element, "mirror", false);
float footRot = ToolBox.GetAttributeFloat(element,"footrotation", float.NaN); float footRot = ToolBox.GetAttributeFloat(element,"footrotation", float.NaN);
if (float.IsNaN(footRot)) if (float.IsNaN(footRot))
@@ -82,7 +83,7 @@ namespace Barotrauma
} }
} }
if (flip) if (mirror)
{ {
if (!character.IsNetworkPlayer) if (!character.IsNetworkPlayer)
{ {
@@ -117,6 +118,8 @@ namespace Barotrauma
} }
//if (stunTimer > gameTime.TotalGameTime.TotalMilliseconds) return; //if (stunTimer > gameTime.TotalGameTime.TotalMilliseconds) return;
if (!flip) return;
flipTimer += deltaTime; flipTimer += deltaTime;
if (TargetDir != dir) if (TargetDir != dir)
@@ -124,7 +127,7 @@ namespace Barotrauma
if (flipTimer>1.0f || character.IsNetworkPlayer) if (flipTimer>1.0f || character.IsNetworkPlayer)
{ {
Flip(); Flip();
if (flip) Mirror(); if (mirror) Mirror();
flipTimer = 0.0f; flipTimer = 0.0f;
} }
} }
@@ -112,8 +112,8 @@ namespace Barotrauma
set set
{ {
if (!MathUtils.IsValid(value)) return; if (!MathUtils.IsValid(value)) return;
targetMovement.X = MathHelper.Clamp(value.X, -3.0f, 3.0f); targetMovement.X = MathHelper.Clamp(value.X, -5.0f, 5.0f);
targetMovement.Y = MathHelper.Clamp(value.Y, -3.0f, 3.0f); targetMovement.Y = MathHelper.Clamp(value.Y, -5.0f, 5.0f);
} }
} }
@@ -152,6 +152,8 @@ namespace Barotrauma
get { return headInWater; } get { return headInWater; }
} }
public readonly bool CanEnterSubmarine;
public Hull CurrentHull public Hull CurrentHull
{ {
get { return currentHull; } get { return currentHull; }
@@ -214,6 +216,8 @@ namespace Barotrauma
torsoPosition = ConvertUnits.ToSimUnits(torsoPosition); torsoPosition = ConvertUnits.ToSimUnits(torsoPosition);
torsoAngle = MathHelper.ToRadians(ToolBox.GetAttributeFloat(element, "torsoangle", 0.0f)); torsoAngle = MathHelper.ToRadians(ToolBox.GetAttributeFloat(element, "torsoangle", 0.0f));
CanEnterSubmarine = ToolBox.GetAttributeBool(element, "canentersubmarine", true);
foreach (XElement subElement in element.Elements()) foreach (XElement subElement in element.Elements())
{ {
switch (subElement.Name.ToString()) switch (subElement.Name.ToString())
@@ -272,6 +276,8 @@ namespace Barotrauma
if (refLimb == null) refLimb = GetLimb(LimbType.Head); if (refLimb == null) refLimb = GetLimb(LimbType.Head);
if (refLimb == null) DebugConsole.ThrowError("Character ''" + character + "'' doesn't have a head or torso!"); if (refLimb == null) DebugConsole.ThrowError("Character ''" + character + "'' doesn't have a head or torso!");
UpdateCollisionCategories();
foreach (var joint in limbJoints) foreach (var joint in limbJoints)
{ {
@@ -550,6 +556,11 @@ namespace Barotrauma
public void FindHull(Vector2? worldPosition = null, bool setSubmarine = true) public void FindHull(Vector2? worldPosition = null, bool setSubmarine = true)
{ {
if (!CanEnterSubmarine)
{
return;
}
Vector2 findPos = worldPosition==null ? refLimb.WorldPosition : (Vector2)worldPosition; Vector2 findPos = worldPosition==null ? refLimb.WorldPosition : (Vector2)worldPosition;
Hull newHull = Hull.FindHull(findPos, currentHull); Hull newHull = Hull.FindHull(findPos, currentHull);
@@ -747,7 +758,7 @@ namespace Barotrauma
} }
} }
if (lerp) if (lerp)
{ {
limb.body.TargetPosition = movePos; limb.body.TargetPosition = movePos;
limb.body.MoveToTargetPosition(Vector2.Distance(limb.SimPosition, movePos) < 10.0f); limb.body.MoveToTargetPosition(Vector2.Distance(limb.SimPosition, movePos) < 10.0f);
+16 -10
View File
@@ -297,19 +297,25 @@ namespace Barotrauma
{ {
if (c.AnimController.CurrentHull != null) continue; if (c.AnimController.CurrentHull != null) continue;
//if the character isn't inside the bounding box, continue foreach (Limb limb in c.AnimController.Limbs)
if (!Submarine.RectContains(worldBorders, c.WorldPosition)) continue; {
//if the character isn't inside the bounding box, continue
if (!Submarine.RectContains(worldBorders, limb.WorldPosition)) continue;
//cast a line from the position of the character to the same direction as the translation of the sub //cast a line from the position of the character to the same direction as the translation of the sub
//and see where it intersects with the bounding box //and see where it intersects with the bounding box
Vector2? intersection = MathUtils.GetLineRectangleIntersection(c.WorldPosition, Vector2? intersection = MathUtils.GetLineRectangleIntersection(limb.WorldPosition,
c.WorldPosition + translateDir*100000.0f, worldBorders); limb.WorldPosition + translateDir*100000.0f, worldBorders);
//should never be null when casting a line out from inside the bounding box //should never be null when casting a line out from inside the bounding box
Debug.Assert(intersection != null); Debug.Assert(intersection != null);
//''+ translatedir'' in order to move the character slightly away from the wall
c.AnimController.SetPosition(c.WorldPosition + ConvertUnits.ToSimUnits((Vector2)intersection - limb.WorldPosition) + translateDir);
return;
}
c.AnimController.SetPosition(ConvertUnits.ToSimUnits((Vector2)intersection) + translateDir);
//''+ translatedir'' in order to move the character slightly away from the wall
} }
} }
+1 -1
View File
@@ -313,7 +313,7 @@ namespace Barotrauma
prevPosition = targetPosition; prevPosition = targetPosition;
} }
body.SetTransform(targetPosition, targetRotation); body.SetTransform(targetPosition, targetRotation == 0.0f ? body.Rotation : targetRotation);
body.LinearVelocity = targetVelocity; body.LinearVelocity = targetVelocity;
body.AngularVelocity = targetAngularVelocity; body.AngularVelocity = targetAngularVelocity;
targetPosition = Vector2.Zero; targetPosition = Vector2.Zero;