Merge branch 'master' of https://github.com/Regalis11/Barotrauma
This commit is contained in:
@@ -87,10 +87,6 @@ namespace Barotrauma.Items.Components
|
|||||||
public void Draw(SpriteBatch spriteBatch, bool editing)
|
public void Draw(SpriteBatch spriteBatch, bool editing)
|
||||||
{
|
{
|
||||||
Color color = (item.IsSelected) ? Color.Green : Color.White;
|
Color color = (item.IsSelected) ? Color.Green : Color.White;
|
||||||
color = color * (item.Condition / item.Prefab.Health);
|
|
||||||
color.A = 255;
|
|
||||||
|
|
||||||
//prefab.sprite.Draw(spriteBatch, new Vector2(rect.X, -rect.Y), new Vector2(rect.Width, rect.Height), color);
|
|
||||||
|
|
||||||
if (stuck > 0.0f && weldedSprite != null)
|
if (stuck > 0.0f && weldedSprite != null)
|
||||||
{
|
{
|
||||||
@@ -114,10 +110,25 @@ namespace Barotrauma.Items.Components
|
|||||||
if (item.Submarine != null) pos += item.Submarine.DrawPosition;
|
if (item.Submarine != null) pos += item.Submarine.DrawPosition;
|
||||||
pos.Y = -pos.Y;
|
pos.Y = -pos.Y;
|
||||||
|
|
||||||
spriteBatch.Draw(doorSprite.Texture, pos,
|
if (brokenSprite == null || item.Health > 0.0f)
|
||||||
new Rectangle((int)(doorSprite.SourceRect.X + doorSprite.size.X * openState), (int)doorSprite.SourceRect.Y,
|
{
|
||||||
(int)(doorSprite.size.X * (1.0f - openState)), (int)doorSprite.size.Y),
|
spriteBatch.Draw(doorSprite.Texture, pos,
|
||||||
color, 0.0f, doorSprite.Origin, 1.0f, SpriteEffects.None, doorSprite.Depth);
|
new Rectangle((int) (doorSprite.SourceRect.X + doorSprite.size.X * openState),
|
||||||
|
(int) doorSprite.SourceRect.Y,
|
||||||
|
(int) (doorSprite.size.X * (1.0f - openState)), (int) doorSprite.size.Y),
|
||||||
|
color, 0.0f, doorSprite.Origin, 1.0f, SpriteEffects.None, doorSprite.Depth);
|
||||||
|
}
|
||||||
|
|
||||||
|
if (brokenSprite != null && item.Health < item.Prefab.Health)
|
||||||
|
{
|
||||||
|
Vector2 scale = scaleBrokenSprite ? new Vector2(1.0f, 1.0f - item.Health / item.Prefab.Health) : Vector2.One;
|
||||||
|
float alpha = fadeBrokenSprite ? 1.0f - item.Health / item.Prefab.Health : 1.0f;
|
||||||
|
spriteBatch.Draw(brokenSprite.Texture, pos,
|
||||||
|
new Rectangle((int)(brokenSprite.SourceRect.X + brokenSprite.size.X * openState), brokenSprite.SourceRect.Y,
|
||||||
|
(int)(brokenSprite.size.X * (1.0f - openState)), (int)brokenSprite.size.Y),
|
||||||
|
color * alpha, 0.0f, brokenSprite.Origin, scale, SpriteEffects.None,
|
||||||
|
brokenSprite.Depth);
|
||||||
|
}
|
||||||
}
|
}
|
||||||
else
|
else
|
||||||
{
|
{
|
||||||
@@ -125,10 +136,25 @@ namespace Barotrauma.Items.Components
|
|||||||
if (item.Submarine != null) pos += item.Submarine.DrawPosition;
|
if (item.Submarine != null) pos += item.Submarine.DrawPosition;
|
||||||
pos.Y = -pos.Y;
|
pos.Y = -pos.Y;
|
||||||
|
|
||||||
spriteBatch.Draw(doorSprite.Texture, pos,
|
if (brokenSprite == null || item.Health > 0.0f)
|
||||||
new Rectangle(doorSprite.SourceRect.X, (int)(doorSprite.SourceRect.Y + doorSprite.size.Y * openState),
|
{
|
||||||
(int)doorSprite.size.X, (int)(doorSprite.size.Y * (1.0f - openState))),
|
spriteBatch.Draw(doorSprite.Texture, pos,
|
||||||
color, 0.0f, doorSprite.Origin, 1.0f, SpriteEffects.None, doorSprite.Depth);
|
new Rectangle(doorSprite.SourceRect.X,
|
||||||
|
(int) (doorSprite.SourceRect.Y + doorSprite.size.Y * openState),
|
||||||
|
(int) doorSprite.size.X, (int) (doorSprite.size.Y * (1.0f - openState))),
|
||||||
|
color, 0.0f, doorSprite.Origin, 1.0f, SpriteEffects.None, doorSprite.Depth);
|
||||||
|
}
|
||||||
|
|
||||||
|
if (brokenSprite != null && item.Health < item.Prefab.Health)
|
||||||
|
{
|
||||||
|
Vector2 scale = scaleBrokenSprite ? new Vector2(1.0f - item.Health / item.Prefab.Health, 1.0f) : Vector2.One;
|
||||||
|
float alpha = fadeBrokenSprite ? 1.0f - item.Health / item.Prefab.Health : 1.0f;
|
||||||
|
spriteBatch.Draw(brokenSprite.Texture, pos,
|
||||||
|
new Rectangle(brokenSprite.SourceRect.X, (int)(brokenSprite.SourceRect.Y + brokenSprite.size.Y * openState),
|
||||||
|
(int)brokenSprite.size.X, (int)(brokenSprite.size.Y * (1.0f - openState))),
|
||||||
|
color * alpha, 0.0f, brokenSprite.Origin, scale, SpriteEffects.None, brokenSprite.Depth);
|
||||||
|
}
|
||||||
|
|
||||||
}
|
}
|
||||||
|
|
||||||
}
|
}
|
||||||
|
|||||||
@@ -289,6 +289,9 @@
|
|||||||
<Content Include="$(MSBuildThisFileDirectory)Content\Items\Door\doors.xml">
|
<Content Include="$(MSBuildThisFileDirectory)Content\Items\Door\doors.xml">
|
||||||
<CopyToOutputDirectory>PreserveNewest</CopyToOutputDirectory>
|
<CopyToOutputDirectory>PreserveNewest</CopyToOutputDirectory>
|
||||||
</Content>
|
</Content>
|
||||||
|
<Content Include="$(MSBuildThisFileDirectory)Content\Items\Door\hatch.png">
|
||||||
|
<CopyToOutputDirectory>PreserveNewest</CopyToOutputDirectory>
|
||||||
|
</Content>
|
||||||
<Content Include="$(MSBuildThisFileDirectory)Content\Items\Electricity\battery.png">
|
<Content Include="$(MSBuildThisFileDirectory)Content\Items\Electricity\battery.png">
|
||||||
<CopyToOutputDirectory>PreserveNewest</CopyToOutputDirectory>
|
<CopyToOutputDirectory>PreserveNewest</CopyToOutputDirectory>
|
||||||
</Content>
|
</Content>
|
||||||
|
|||||||
Binary file not shown.
|
Before Width: | Height: | Size: 54 KiB After Width: | Height: | Size: 56 KiB |
@@ -9,6 +9,7 @@
|
|||||||
<Door canbeselected="true">
|
<Door canbeselected="true">
|
||||||
<Sprite texture ="door.png" sourcerect="80,0,19,208" depth="0.05" origin="0.5,0.0"/>
|
<Sprite texture ="door.png" sourcerect="80,0,19,208" depth="0.05" origin="0.5,0.0"/>
|
||||||
<WeldedSprite texture ="door.png" sourcerect="99,0,32,188" depth="0.0" origin="0.5,0.5"/>
|
<WeldedSprite texture ="door.png" sourcerect="99,0,32,188" depth="0.0" origin="0.5,0.5"/>
|
||||||
|
<BrokenSprite texture ="door.png" sourcerect="133,0,58,208" depth="0.051" origin="0.5,0.0" scale="true"/>
|
||||||
<sound file="door.ogg" type="OnUse" range="500.0"/>
|
<sound file="door.ogg" type="OnUse" range="500.0"/>
|
||||||
</Door>
|
</Door>
|
||||||
|
|
||||||
@@ -32,11 +33,12 @@
|
|||||||
linkable="true"
|
linkable="true"
|
||||||
>
|
>
|
||||||
|
|
||||||
<Sprite texture ="door.png" sourcerect="1,0,48,208" depth="0.01" origin="0.5,0.5"/>
|
<Sprite texture="door.png" sourcerect="1,0,48,208" depth="0.01" origin="0.5,0.5"/>
|
||||||
|
|
||||||
<Door window="0,-32,10,75" canbeselected="true">
|
<Door window="0,-32,10,75" canbeselected="true">
|
||||||
<Sprite texture ="door.png" sourcerect="56,0,19,208" depth="0.05" origin="0.5,0.0"/>
|
<Sprite texture="door.png" sourcerect="56,0,19,208" depth="0.05" origin="0.5,0.0"/>
|
||||||
<WeldedSprite texture ="door.png" sourcerect="9,0,32,188" depth="0.0" origin="0.5,0.5"/>
|
<WeldedSprite texture="door.png" sourcerect="9,0,32,188" depth="0.0" origin="0.5,0.5"/>
|
||||||
|
<BrokenSprite texture="door.png" sourcerect="192,0,40,208" depth="0.051" origin="0.5,0.0" scale="true"/>
|
||||||
<sound file="door.ogg" type="OnUse" range="500.0"/>
|
<sound file="door.ogg" type="OnUse" range="500.0"/>
|
||||||
</Door>
|
</Door>
|
||||||
|
|
||||||
@@ -60,11 +62,12 @@
|
|||||||
linkable="true"
|
linkable="true"
|
||||||
>
|
>
|
||||||
|
|
||||||
<Sprite texture ="door.png" sourcerect="0,209,128,46" depth="0.01" origin="0.5,0.5"/>
|
<Sprite texture="hatch.png" sourcerect="0,0,128,46" depth="0.01" origin="0.5,0.5"/>
|
||||||
|
|
||||||
<Door canbeselected="true" horizontal="true">
|
<Door canbeselected="true" horizontal="true">
|
||||||
<Sprite texture ="door.png" sourcerect="128,208,128,19" depth="0.05" origin="0.0,0.5"/>
|
<Sprite texture="hatch.png" sourcerect="128,0,128,19" depth="0.05" origin="0.0,0.5"/>
|
||||||
<WeldedSprite texture ="door.png" sourcerect="0,148,108,33" depth="0.0" origin="0.5,0.5"/>
|
<WeldedSprite texture="hatch.png" sourcerect="0,56,108,33" depth="0.0" origin="0.5,0.5"/>
|
||||||
|
<BrokenSprite texture="hatch.png" sourcerect="128,21,128,58" depth="0.051" origin="0.0,0.5" scale="true"/>
|
||||||
<sound file="door.ogg" type="OnUse" range="500.0"/>
|
<sound file="door.ogg" type="OnUse" range="500.0"/>
|
||||||
</Door>
|
</Door>
|
||||||
|
|
||||||
|
|||||||
Binary file not shown.
|
After Width: | Height: | Size: 30 KiB |
@@ -25,7 +25,8 @@ namespace Barotrauma.Items.Components
|
|||||||
|
|
||||||
private PhysicsBody body;
|
private PhysicsBody body;
|
||||||
|
|
||||||
private Sprite doorSprite, weldedSprite;
|
private Sprite doorSprite, weldedSprite, brokenSprite;
|
||||||
|
private bool scaleBrokenSprite, fadeBrokenSprite;
|
||||||
|
|
||||||
private bool isHorizontal;
|
private bool isHorizontal;
|
||||||
|
|
||||||
@@ -34,6 +35,28 @@ namespace Barotrauma.Items.Components
|
|||||||
private bool? predictedState;
|
private bool? predictedState;
|
||||||
private float resetPredictionTimer;
|
private float resetPredictionTimer;
|
||||||
|
|
||||||
|
private Rectangle doorRect;
|
||||||
|
|
||||||
|
private bool isBroken;
|
||||||
|
|
||||||
|
public bool IsBroken
|
||||||
|
{
|
||||||
|
get { return isBroken; }
|
||||||
|
set
|
||||||
|
{
|
||||||
|
if (isBroken == value) return;
|
||||||
|
isBroken = value;
|
||||||
|
if (isBroken)
|
||||||
|
{
|
||||||
|
DisableBody();
|
||||||
|
}
|
||||||
|
else
|
||||||
|
{
|
||||||
|
EnableBody();
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
public PhysicsBody Body
|
public PhysicsBody Body
|
||||||
{
|
{
|
||||||
get { return body; }
|
get { return body; }
|
||||||
@@ -45,7 +68,7 @@ namespace Barotrauma.Items.Components
|
|||||||
get { return stuck; }
|
get { return stuck; }
|
||||||
set
|
set
|
||||||
{
|
{
|
||||||
if (isOpen) return;
|
if (isOpen || isBroken) return;
|
||||||
stuck = MathHelper.Clamp(value, 0.0f, 100.0f);
|
stuck = MathHelper.Clamp(value, 0.0f, 100.0f);
|
||||||
if (stuck == 0.0f) isStuck = false;
|
if (stuck == 0.0f) isStuck = false;
|
||||||
if (stuck == 100.0f) isStuck = true;
|
if (stuck == 100.0f) isStuck = true;
|
||||||
@@ -118,8 +141,6 @@ namespace Barotrauma.Items.Components
|
|||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
private Rectangle doorRect;
|
|
||||||
|
|
||||||
public float OpenState
|
public float OpenState
|
||||||
{
|
{
|
||||||
get { return openState; }
|
get { return openState; }
|
||||||
@@ -139,11 +160,8 @@ namespace Barotrauma.Items.Components
|
|||||||
public Door(Item item, XElement element)
|
public Door(Item item, XElement element)
|
||||||
: base(item, element)
|
: base(item, element)
|
||||||
{
|
{
|
||||||
//Vector2 position = new Vector2(newRect.X, newRect.Y);
|
|
||||||
|
|
||||||
isHorizontal = element.GetAttributeBool("horizontal", false);
|
isHorizontal = element.GetAttributeBool("horizontal", false);
|
||||||
|
|
||||||
// isOpen = false;
|
|
||||||
foreach (XElement subElement in element.Elements())
|
foreach (XElement subElement in element.Elements())
|
||||||
{
|
{
|
||||||
string texturePath = subElement.GetAttributeString("texture", "");
|
string texturePath = subElement.GetAttributeString("texture", "");
|
||||||
@@ -155,6 +173,11 @@ namespace Barotrauma.Items.Components
|
|||||||
case "weldedsprite":
|
case "weldedsprite":
|
||||||
weldedSprite = new Sprite(subElement, texturePath.Contains("/") ? "" : Path.GetDirectoryName(item.Prefab.ConfigFile));
|
weldedSprite = new Sprite(subElement, texturePath.Contains("/") ? "" : Path.GetDirectoryName(item.Prefab.ConfigFile));
|
||||||
break;
|
break;
|
||||||
|
case "brokensprite":
|
||||||
|
brokenSprite = new Sprite(subElement, texturePath.Contains("/") ? "" : Path.GetDirectoryName(item.Prefab.ConfigFile));
|
||||||
|
scaleBrokenSprite = subElement.GetAttributeBool("scale", false);
|
||||||
|
fadeBrokenSprite = subElement.GetAttributeBool("fade", false);
|
||||||
|
break;
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
@@ -178,9 +201,6 @@ namespace Barotrauma.Items.Components
|
|||||||
0.0f);
|
0.0f);
|
||||||
body.Friction = 0.5f;
|
body.Friction = 0.5f;
|
||||||
|
|
||||||
|
|
||||||
//string spritePath = Path.GetDirectoryName(item.Prefab.ConfigFile) + "\\"+ ToolBox.GetAttributeString(element, "sprite", "");
|
|
||||||
|
|
||||||
IsActive = true;
|
IsActive = true;
|
||||||
}
|
}
|
||||||
|
|
||||||
@@ -188,16 +208,11 @@ namespace Barotrauma.Items.Components
|
|||||||
{
|
{
|
||||||
base.Move(amount);
|
base.Move(amount);
|
||||||
|
|
||||||
//LinkedGap.Move(amount);
|
|
||||||
|
|
||||||
body.SetTransform(body.SimPosition + ConvertUnits.ToSimUnits(amount), 0.0f);
|
body.SetTransform(body.SimPosition + ConvertUnits.ToSimUnits(amount), 0.0f);
|
||||||
|
|
||||||
#if CLIENT
|
#if CLIENT
|
||||||
UpdateConvexHulls();
|
UpdateConvexHulls();
|
||||||
#endif
|
#endif
|
||||||
|
|
||||||
//convexHull.Move(amount);
|
|
||||||
//if (convexHull2 != null) convexHull2.Move(amount);
|
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
@@ -216,17 +231,27 @@ namespace Barotrauma.Items.Components
|
|||||||
|
|
||||||
public override void Update(float deltaTime, Camera cam)
|
public override void Update(float deltaTime, Camera cam)
|
||||||
{
|
{
|
||||||
|
if (isBroken)
|
||||||
|
{
|
||||||
|
//the door has to be restored to 50% health before collision detection on the body is re-enabled
|
||||||
|
if (item.Condition > 50.0f)
|
||||||
|
{
|
||||||
|
IsBroken = false;
|
||||||
|
}
|
||||||
|
return;
|
||||||
|
}
|
||||||
|
|
||||||
bool isClosing = false;
|
bool isClosing = false;
|
||||||
if (!isStuck)
|
if (!isStuck)
|
||||||
{
|
{
|
||||||
if (predictedState == null)
|
if (predictedState == null)
|
||||||
{
|
{
|
||||||
OpenState += deltaTime * ((isOpen) ? 2.0f : -2.0f);
|
OpenState += deltaTime * (isOpen ? 2.0f : -2.0f);
|
||||||
isClosing = openState > 0.0f && openState < 1.0f && !isOpen;
|
isClosing = openState > 0.0f && openState < 1.0f && !isOpen;
|
||||||
}
|
}
|
||||||
else
|
else
|
||||||
{
|
{
|
||||||
OpenState += deltaTime * (((bool)predictedState) ? 2.0f : -2.0f);
|
OpenState += deltaTime * ((bool)predictedState ? 2.0f : -2.0f);
|
||||||
isClosing = openState > 0.0f && openState < 1.0f && !(bool)predictedState;
|
isClosing = openState > 0.0f && openState < 1.0f && !(bool)predictedState;
|
||||||
|
|
||||||
resetPredictionTimer -= deltaTime;
|
resetPredictionTimer -= deltaTime;
|
||||||
@@ -255,9 +280,29 @@ namespace Barotrauma.Items.Components
|
|||||||
|
|
||||||
public override void UpdateBroken(float deltaTime, Camera cam)
|
public override void UpdateBroken(float deltaTime, Camera cam)
|
||||||
{
|
{
|
||||||
body.Enabled = false;
|
IsBroken = true;
|
||||||
|
}
|
||||||
|
|
||||||
|
private void EnableBody()
|
||||||
|
{
|
||||||
|
body.FarseerBody.IsSensor = false;
|
||||||
|
#if CLIENT
|
||||||
|
UpdateConvexHulls();
|
||||||
|
#endif
|
||||||
|
isBroken = false;
|
||||||
|
}
|
||||||
|
|
||||||
|
private void DisableBody()
|
||||||
|
{
|
||||||
|
//change the body to a sensor instead of disabling it completely,
|
||||||
|
//because otherwise repairtool raycasts won't hit it
|
||||||
|
body.FarseerBody.IsSensor = true;
|
||||||
linkedGap.Open = 1.0f;
|
linkedGap.Open = 1.0f;
|
||||||
|
IsOpen = false;
|
||||||
|
#if CLIENT
|
||||||
|
if (convexHull != null) convexHull.Enabled = false;
|
||||||
|
if (convexHull2 != null) convexHull2.Enabled = false;
|
||||||
|
#endif
|
||||||
}
|
}
|
||||||
|
|
||||||
public override void OnMapLoaded()
|
public override void OnMapLoaded()
|
||||||
@@ -286,13 +331,13 @@ namespace Barotrauma.Items.Components
|
|||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
if (linkedGap!=null) linkedGap.Remove();
|
if (linkedGap != null) linkedGap.Remove();
|
||||||
|
|
||||||
doorSprite.Remove();
|
doorSprite.Remove();
|
||||||
if (weldedSprite != null) weldedSprite.Remove();
|
if (weldedSprite != null) weldedSprite.Remove();
|
||||||
|
|
||||||
#if CLIENT
|
#if CLIENT
|
||||||
if (convexHull!=null) convexHull.Remove();
|
if (convexHull != null) convexHull.Remove();
|
||||||
if (convexHull2 != null) convexHull2.Remove();
|
if (convexHull2 != null) convexHull2.Remove();
|
||||||
#endif
|
#endif
|
||||||
}
|
}
|
||||||
@@ -398,8 +443,8 @@ namespace Barotrauma.Items.Components
|
|||||||
{
|
{
|
||||||
//clients can "predict" that the door opens/closes when a signal is received
|
//clients can "predict" that the door opens/closes when a signal is received
|
||||||
|
|
||||||
//the prediction will be reset after 1 second, setting the door to a state
|
//the prediction will be reset after 1 second, setting the door to a state
|
||||||
//sent by the server, or reverting it back to its old state if no msg from server was received
|
//sent by the server, or reverting it back to its old state if no msg from server was received
|
||||||
|
|
||||||
#if CLIENT
|
#if CLIENT
|
||||||
if (open != predictedState) PlaySound(ActionType.OnUse, item.WorldPosition);
|
if (open != predictedState) PlaySound(ActionType.OnUse, item.WorldPosition);
|
||||||
|
|||||||
@@ -176,7 +176,7 @@ namespace Barotrauma.Items.Components
|
|||||||
}
|
}
|
||||||
|
|
||||||
Body targetBody = Submarine.PickBody(rayStart, rayEnd, ignoredBodies,
|
Body targetBody = Submarine.PickBody(rayStart, rayEnd, ignoredBodies,
|
||||||
Physics.CollisionWall | Physics.CollisionCharacter | Physics.CollisionItem | Physics.CollisionLevel);
|
Physics.CollisionWall | Physics.CollisionCharacter | Physics.CollisionItem | Physics.CollisionLevel, false);
|
||||||
|
|
||||||
if (targetBody == null || targetBody.UserData == null) return;
|
if (targetBody == null || targetBody.UserData == null) return;
|
||||||
|
|
||||||
|
|||||||
@@ -509,7 +509,7 @@ namespace Barotrauma
|
|||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
public static Body PickBody(Vector2 rayStart, Vector2 rayEnd, List<Body> ignoredBodies = null, Category? collisionCategory = null)
|
public static Body PickBody(Vector2 rayStart, Vector2 rayEnd, List<Body> ignoredBodies = null, Category? collisionCategory = null, bool ignoreSensors = true)
|
||||||
{
|
{
|
||||||
if (Vector2.DistanceSquared(rayStart, rayEnd) < 0.00001f)
|
if (Vector2.DistanceSquared(rayStart, rayEnd) < 0.00001f)
|
||||||
{
|
{
|
||||||
@@ -521,7 +521,7 @@ namespace Barotrauma
|
|||||||
GameMain.World.RayCast((fixture, point, normal, fraction) =>
|
GameMain.World.RayCast((fixture, point, normal, fraction) =>
|
||||||
{
|
{
|
||||||
if (fixture == null ||
|
if (fixture == null ||
|
||||||
fixture.IsSensor ||
|
(ignoreSensors && fixture.IsSensor) ||
|
||||||
fixture.CollisionCategories == Category.None ||
|
fixture.CollisionCategories == Category.None ||
|
||||||
fixture.CollisionCategories == Physics.CollisionItem) return -1;
|
fixture.CollisionCategories == Physics.CollisionItem) return -1;
|
||||||
|
|
||||||
@@ -556,7 +556,7 @@ namespace Barotrauma
|
|||||||
/// check visibility between two points (in sim units)
|
/// check visibility between two points (in sim units)
|
||||||
/// </summary>
|
/// </summary>
|
||||||
/// <returns>a physics body that was between the points (or null)</returns>
|
/// <returns>a physics body that was between the points (or null)</returns>
|
||||||
public static Body CheckVisibility(Vector2 rayStart, Vector2 rayEnd, bool ignoreLevel = false, bool ignoreSubs = false)
|
public static Body CheckVisibility(Vector2 rayStart, Vector2 rayEnd, bool ignoreLevel = false, bool ignoreSubs = false, bool ignoreSensors = true)
|
||||||
{
|
{
|
||||||
Body closestBody = null;
|
Body closestBody = null;
|
||||||
float closestFraction = 1.0f;
|
float closestFraction = 1.0f;
|
||||||
@@ -569,7 +569,8 @@ namespace Barotrauma
|
|||||||
|
|
||||||
GameMain.World.RayCast((fixture, point, normal, fraction) =>
|
GameMain.World.RayCast((fixture, point, normal, fraction) =>
|
||||||
{
|
{
|
||||||
if (fixture == null || fixture.IsSensor ||
|
if (fixture == null ||
|
||||||
|
(ignoreSensors && fixture.IsSensor) ||
|
||||||
(!fixture.CollisionCategories.HasFlag(Physics.CollisionWall) && !fixture.CollisionCategories.HasFlag(Physics.CollisionLevel))) return -1;
|
(!fixture.CollisionCategories.HasFlag(Physics.CollisionWall) && !fixture.CollisionCategories.HasFlag(Physics.CollisionLevel))) return -1;
|
||||||
|
|
||||||
if (ignoreLevel && fixture.CollisionCategories == Physics.CollisionLevel) return -1;
|
if (ignoreLevel && fixture.CollisionCategories == Physics.CollisionLevel) return -1;
|
||||||
|
|||||||
Reference in New Issue
Block a user