Added a collider to railgun (-> cannot go through walls or enemy subs anymore). Closes #444
This commit is contained in:
@@ -8,6 +8,8 @@
|
|||||||
|
|
||||||
<Sprite texture="railgunbase.png" depth="0.01" sourcerect="0,0,256,256"/>
|
<Sprite texture="railgunbase.png" depth="0.01" sourcerect="0,0,256,256"/>
|
||||||
|
|
||||||
|
<StaticBody width="80" radius="80"/>
|
||||||
|
|
||||||
<Turret barrelsprite="railgunbarrel.png" canbeselected = "true" linkable="true" origin="0.5, 0.85" barrelpos="128, 128"
|
<Turret barrelsprite="railgunbarrel.png" canbeselected = "true" linkable="true" origin="0.5, 0.85" barrelpos="128, 128"
|
||||||
rotationlimits="180,360"
|
rotationlimits="180,360"
|
||||||
powerconsumption="20000.0"
|
powerconsumption="20000.0"
|
||||||
|
|||||||
@@ -46,6 +46,8 @@ namespace Barotrauma
|
|||||||
|
|
||||||
public PhysicsBody body;
|
public PhysicsBody body;
|
||||||
|
|
||||||
|
public readonly XElement staticBodyConfig;
|
||||||
|
|
||||||
private Vector2 lastSentPos;
|
private Vector2 lastSentPos;
|
||||||
private bool prevBodyAwake;
|
private bool prevBodyAwake;
|
||||||
|
|
||||||
@@ -399,6 +401,9 @@ namespace Barotrauma
|
|||||||
case "deconstruct":
|
case "deconstruct":
|
||||||
case "brokensprite":
|
case "brokensprite":
|
||||||
break;
|
break;
|
||||||
|
case "staticbody":
|
||||||
|
staticBodyConfig = subElement;
|
||||||
|
break;
|
||||||
case "aitarget":
|
case "aitarget":
|
||||||
aiTarget = new AITarget(this);
|
aiTarget = new AITarget(this);
|
||||||
aiTarget.SightRange = subElement.GetAttributeFloat("sightrange", 1000.0f);
|
aiTarget.SightRange = subElement.GetAttributeFloat("sightrange", 1000.0f);
|
||||||
|
|||||||
@@ -128,10 +128,38 @@ namespace Barotrauma
|
|||||||
ConvertUnits.ToSimUnits(new Vector2(rect.X + rect.Width / 2, rect.Y - rect.Height / 2)),
|
ConvertUnits.ToSimUnits(new Vector2(rect.X + rect.Width / 2, rect.Y - rect.Height / 2)),
|
||||||
farseerBody, this);
|
farseerBody, this);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
foreach (Item item in Item.ItemList)
|
||||||
|
{
|
||||||
|
if (item.staticBodyConfig == null) continue;
|
||||||
|
|
||||||
|
float radius = ConvertUnits.ToSimUnits(item.staticBodyConfig.GetAttributeFloat("radius", 0.0f));
|
||||||
|
float width = ConvertUnits.ToSimUnits(item.staticBodyConfig.GetAttributeFloat("width", 0.0f));
|
||||||
|
float height = ConvertUnits.ToSimUnits(item.staticBodyConfig.GetAttributeFloat("height", 0.0f));
|
||||||
|
|
||||||
|
if (width != 0.0f && height != 0.0f)
|
||||||
|
{
|
||||||
|
FixtureFactory.AttachRectangle(width, height, 5.0f, ConvertUnits.ToSimUnits(item.Position), farseerBody, this);
|
||||||
|
}
|
||||||
|
else if (radius != 0.0f && width != 0.0f)
|
||||||
|
{
|
||||||
|
FixtureFactory.AttachRectangle(width, radius * 2, 5.0f, ConvertUnits.ToSimUnits(item.Position), farseerBody, this);
|
||||||
|
FixtureFactory.AttachCircle(radius, 5.0f, farseerBody, ConvertUnits.ToSimUnits(item.Position) - Vector2.UnitX * width / 2, this);
|
||||||
|
FixtureFactory.AttachCircle(radius, 5.0f, farseerBody, ConvertUnits.ToSimUnits(item.Position) + Vector2.UnitX * width / 2, this);
|
||||||
|
}
|
||||||
|
else if (radius != 0.0f && height != 0.0f)
|
||||||
|
{
|
||||||
|
FixtureFactory.AttachRectangle(radius * 2, height, 5.0f, ConvertUnits.ToSimUnits(item.Position), farseerBody, this);
|
||||||
|
FixtureFactory.AttachCircle(radius, 5.0f, farseerBody, ConvertUnits.ToSimUnits(item.Position) - Vector2.UnitY * height / 2, this);
|
||||||
|
FixtureFactory.AttachCircle(radius, 5.0f, farseerBody, ConvertUnits.ToSimUnits(item.Position) + Vector2.UnitX * height / 2, this);
|
||||||
|
}
|
||||||
|
else if (radius != 0.0f)
|
||||||
|
{
|
||||||
|
FixtureFactory.AttachCircle(radius, 5.0f, farseerBody, ConvertUnits.ToSimUnits(item.Position), this);
|
||||||
|
}
|
||||||
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
farseerBody.BodyType = BodyType.Dynamic;
|
farseerBody.BodyType = BodyType.Dynamic;
|
||||||
farseerBody.CollisionCategories = Physics.CollisionWall;
|
farseerBody.CollisionCategories = Physics.CollisionWall;
|
||||||
farseerBody.CollidesWith =
|
farseerBody.CollidesWith =
|
||||||
|
|||||||
Reference in New Issue
Block a user