Option to hide waypoints and spawnpoints in editor, fixed cam "twitching" in multiplayer, additional light sprites for lightcomponents, wire bugfixes, fixed excessive camera shake when firing the railgun

This commit is contained in:
Regalis
2016-01-04 22:36:39 +02:00
parent bc9ff32023
commit ca7febfcab
20 changed files with 123 additions and 55 deletions
+21 -1
View File
@@ -367,7 +367,27 @@ namespace Launcher2
xml = xml.Remove(0, _byteOrderMarkUtf8.Length); xml = xml.Remove(0, _byteOrderMarkUtf8.Length);
} }
return XDocument.Parse(xml); try
{
return XDocument.Parse(xml);
}
catch
{
}
try
{
int index = xml.IndexOf('<');
xml = xml.Substring(index, xml.Length-index);
return XDocument.Parse(xml);
}
catch
{
return null;
}
} }
private bool CheckUpdateXML(XDocument doc) private bool CheckUpdateXML(XDocument doc)
Binary file not shown.

Before

Width:  |  Height:  |  Size: 2.8 KiB

After

Width:  |  Height:  |  Size: 2.8 KiB

@@ -10,7 +10,9 @@
<Sprite texture="lamp.png" sourcerect="0,0,16,32" depth="0.8"/> <Sprite texture="lamp.png" sourcerect="0,0,16,32" depth="0.8"/>
<LightComponent color="1.0,1.0,1.0,1.0" range ="800.0" powerconsumption="50"/> <LightComponent color="1.0,1.0,1.0,1.0" range ="800.0" powerconsumption="50">
<sprite texture="Content/Items/Electricity/lamp.png" sourcerect="33,0,31,39"/>
</LightComponent>
<ConnectionPanel selectkey="Action" canbeselected = "true" msg="Rewire [Screwdriver]"> <ConnectionPanel selectkey="Action" canbeselected = "true" msg="Rewire [Screwdriver]">
<requireditem name="Screwdriver,Wire" type="Equipped"/> <requireditem name="Screwdriver,Wire" type="Equipped"/>
Binary file not shown.

Before

Width:  |  Height:  |  Size: 7.4 KiB

After

Width:  |  Height:  |  Size: 7.4 KiB

@@ -221,7 +221,7 @@
<Sprite texture="signalcomp.png" depth="0.8" sourcerect="48,0,16,16"/> <Sprite texture="signalcomp.png" depth="0.8" sourcerect="48,0,16,16"/>
<LightComponent canbeselected = "true" color="1.0,0.0,0.0,1.0"> <LightComponent canbeselected = "true" color="1.0,0.0,0.0,1.0">
<sprite texture="Content/Items/Electricity/lightsprite.png" origin="0.5,0.5"/> <sprite texture="Content/Items/Electricity/signalcomp.png" sourcerect="0,96,31,32"/>
</LightComponent> </LightComponent>
<Body width="16" height="16"/> <Body width="16" height="16"/>
+1 -1
View File
@@ -13,7 +13,7 @@
rotationlimits="180,360" rotationlimits="180,360"
powerconsumption="500.0"> powerconsumption="500.0">
<StatusEffect type="OnUse" target="This" sound="Content/Items/Weapons/railgun.ogg"> <StatusEffect type="OnUse" target="This" sound="Content/Items/Weapons/railgun.ogg">
<Explosion range="1000.0" structuredamage="0" force="0.01"/> <Explosion range="1000.0" structuredamage="0" force="0.01" camerashake="10.0"/>
</StatusEffect> </StatusEffect>
</Turret> </Turret>
+1 -1
View File
@@ -55,7 +55,7 @@
<GUITextBox <GUITextBox
color="0.0, 0.0, 0.0, 1.0" color="0.0, 0.0, 0.0, 1.0"
hovercolor="0.8, 0.8, 0.8, 1.0" hovercolor="0.5, 0.5, 0.5, 0.7"
textcolor="1.0, 1.0, 1.0, 1.0" textcolor="1.0, 1.0, 1.0, 1.0"
outlinecolor="0.5, 0.57, 0.6, 1.0"> outlinecolor="0.5, 0.57, 0.6, 1.0">
</GUITextBox> </GUITextBox>
+1 -1
View File
@@ -499,7 +499,7 @@ namespace Barotrauma
damagedSprite.Draw(spriteBatch, damagedSprite.Draw(spriteBatch,
new Vector2(body.DrawPosition.X, -body.DrawPosition.Y), new Vector2(body.DrawPosition.X, -body.DrawPosition.Y),
color*Math.Min(damage/50.0f,1.0f), sprite.origin, color*Math.Min(damage/50.0f,1.0f), sprite.Origin,
-body.DrawRotation, -body.DrawRotation,
1.0f, spriteEffect, depth); 1.0f, spriteEffect, depth);
} }
+13
View File
@@ -70,6 +70,19 @@ namespace Barotrauma
} }
} }
public override Color HoverColor
{
get
{
return base.HoverColor;
}
set
{
base.HoverColor = value;
textBlock.HoverColor = value;
}
}
public bool CaretEnabled; public bool CaretEnabled;
public String Text public String Text
@@ -325,10 +325,12 @@ namespace Barotrauma.Items.Components
if (index>-1 && wireComponent!=null && !Wires.Contains(wireComponent)) if (index>-1 && wireComponent!=null && !Wires.Contains(wireComponent))
{ {
bool alreadyConnected = wireComponent.IsConnectedTo(item);
wireComponent.RemoveConnection(item); wireComponent.RemoveConnection(item);
Wires[index] = wireComponent; Wires[index] = wireComponent;
wireComponent.Connect(this); wireComponent.Connect(this, !alreadyConnected);
} }
} }
//far away -> disconnect if the wire is linked to this connector //far away -> disconnect if the wire is linked to this connector
@@ -13,13 +13,11 @@ namespace Barotrauma.Items.Components
private Color lightColor; private Color lightColor;
//private Sprite sprite; private LightSource light;
LightSource light; private float range;
float range; private float lightBrightness;
float lightBrightness;
private float flicker; private float flicker;
@@ -81,18 +79,17 @@ namespace Barotrauma.Items.Components
public LightComponent(Item item, XElement element) public LightComponent(Item item, XElement element)
: base (item, element) : base (item, element)
{ {
//foreach (XElement subElement in element.Elements())
//{
// if (subElement.Name.ToString().ToLower() != "sprite") continue;
// sprite = new Sprite(subElement);
// break;
//}
light = new LightSource(item.Position, 100.0f, Color.White, item.CurrentHull == null ? null : item.CurrentHull.Submarine); light = new LightSource(item.Position, 100.0f, Color.White, item.CurrentHull == null ? null : item.CurrentHull.Submarine);
IsActive = true; IsActive = true;
//lightColor = new Color(ToolBox.GetAttributeVector4(element, "color", Vector4.One)); foreach (XElement subElement in element.Elements())
{
if (subElement.Name.ToString().ToLower() != "sprite") continue;
light.LightSprite = new Sprite(subElement);
light.LightSprite.Origin = light.LightSprite.size / 2.0f;
break;
}
} }
public override void Update(float deltaTime, Camera cam) public override void Update(float deltaTime, Camera cam)
@@ -101,9 +98,7 @@ namespace Barotrauma.Items.Components
if (item.CurrentHull != null) if (item.CurrentHull != null)
{ {
light.Submarine = item.CurrentHull.Submarine; light.Submarine = item.CurrentHull.Submarine;
} }
if (item.container != null) if (item.container != null)
{ {
@@ -57,6 +57,12 @@ namespace Barotrauma.Items.Components
return null; return null;
} }
public bool IsConnectedTo(Item item)
{
if (connections[0] != null && connections[0].Item == item) return true;
return (connections[1] != null && connections[1].Item == item);
}
public void RemoveConnection(Item item) public void RemoveConnection(Item item)
{ {
for (int i = 0; i<2; i++) for (int i = 0; i<2; i++)
+10 -1
View File
@@ -8,7 +8,16 @@ namespace Barotrauma.Lights
class LightManager class LightManager
{ {
//public static Vector2 ViewPos; //public static Vector2 ViewPos;
public static Entity ViewTarget; private static Entity viewTarget;
public static Entity ViewTarget
{
get { return viewTarget; }
set {
if (viewTarget == value) return;
viewTarget = value;
}
}
public Color AmbientLight; public Color AmbientLight;
+8 -1
View File
@@ -19,6 +19,8 @@ namespace Barotrauma.Lights
private Texture2D texture; private Texture2D texture;
public Sprite LightSprite;
public Entity Submarine; public Entity Submarine;
//what was the range of the light when HullsInRange were last updated //what was the range of the light when HullsInRange were last updated
@@ -85,7 +87,7 @@ namespace Barotrauma.Lights
this.range = range; this.range = range;
this.color = color; this.color = color;
texture = lightTexture; texture = LightTexture;
GameMain.LightManager.AddLight(this); GameMain.LightManager.AddLight(this);
} }
@@ -106,6 +108,11 @@ namespace Barotrauma.Lights
Vector2 center = new Vector2(LightTexture.Width / 2, LightTexture.Height / 2); Vector2 center = new Vector2(LightTexture.Width / 2, LightTexture.Height / 2);
float scale = range / (lightTexture.Width / 2.0f); float scale = range / (lightTexture.Width / 2.0f);
spriteBatch.Draw(lightTexture, new Vector2(WorldPosition.X, -WorldPosition.Y), null, color, 0, center, scale, SpriteEffects.None, 1); spriteBatch.Draw(lightTexture, new Vector2(WorldPosition.X, -WorldPosition.Y), null, color, 0, center, scale, SpriteEffects.None, 1);
if (LightSprite != null)
{
LightSprite.Draw(spriteBatch, new Vector2(WorldPosition.X, -WorldPosition.Y), Color);
}
} }
public void Remove() public void Remove()
+16 -9
View File
@@ -35,7 +35,7 @@ namespace Barotrauma
private Body body; private Body body;
private Vector2 targetPosition; private Vector2? targetPosition;
float mass = 10000.0f; float mass = 10000.0f;
@@ -60,7 +60,7 @@ namespace Barotrauma
public Vector2 TargetPosition public Vector2 TargetPosition
{ {
get { return targetPosition; } //get { return targetPosition; }
set set
{ {
if (!MathUtils.IsValid(value)) return; if (!MathUtils.IsValid(value)) return;
@@ -210,26 +210,33 @@ namespace Barotrauma
public void Update(float deltaTime) public void Update(float deltaTime)
{ {
if (targetPosition != Vector2.Zero && targetPosition != Position) if (targetPosition != null && targetPosition != Position)
{ {
float dist = Vector2.Distance(targetPosition, Position); Vector2 targetSimPos = ConvertUnits.ToSimUnits((Vector2)targetPosition);
float dist = Vector2.Distance((Vector2)targetPosition, Position);
if (dist > 1000.0f) if (dist > 1000.0f)
{ {
body.SetTransform(ConvertUnits.ToSimUnits(targetPosition), 0.0f); body.SetTransform(targetSimPos, 0.0f);
targetPosition = Vector2.Zero; targetPosition = null;
} }
else if (dist > 50.0f) else if (dist > 50.0f)
{ {
body.SetTransform((ConvertUnits.ToSimUnits(targetPosition) - body.Position) * 0.01f, 0.0f); Vector2 moveAmount = Vector2.Normalize(targetSimPos - body.Position);
moveAmount *= Math.Min(dist, 100.0f);
body.SetTransform(body.Position + moveAmount * deltaTime, 0.0f);
}
else
{
targetPosition = null;
} }
} }
else else
{ {
targetPosition = Vector2.Zero; targetPosition = null;
} }
//------------------------- //-------------------------
Vector2 totalForce = CalculateBuoyancy(); Vector2 totalForce = CalculateBuoyancy();
+12 -1
View File
@@ -15,6 +15,8 @@ namespace Barotrauma
{ {
public static List<WayPoint> WayPointList = new List<WayPoint>(); public static List<WayPoint> WayPointList = new List<WayPoint>();
public static bool ShowWayPoints, ShowSpawnPoints;
private SpawnType spawnType; private SpawnType spawnType;
//characters spawning at the waypoint will be given an ID card with these tags //characters spawning at the waypoint will be given an ID card with these tags
@@ -84,6 +86,15 @@ namespace Barotrauma
{ {
if (!editing && !GameMain.DebugDraw) return; if (!editing && !GameMain.DebugDraw) return;
if (spawnType == SpawnType.Path)
{
if (!GameMain.DebugDraw && !ShowWayPoints) return;
}
else
{
if (!GameMain.DebugDraw && !ShowSpawnPoints) return;
}
Rectangle drawRect = Rectangle drawRect =
Submarine == null ? rect : new Rectangle((int)(Submarine.DrawPosition.X + rect.X), (int)(Submarine.DrawPosition.Y + rect.Y), rect.Width, rect.Height); Submarine == null ? rect : new Rectangle((int)(Submarine.DrawPosition.X + rect.X), (int)(Submarine.DrawPosition.Y + rect.Y), rect.Width, rect.Height);
@@ -96,7 +107,7 @@ namespace Barotrauma
foreach (MapEntity e in linkedTo) foreach (MapEntity e in linkedTo)
{ {
GUI.DrawLine(spriteBatch, GUI.DrawLine(spriteBatch,
new Vector2(drawRect.X, -drawRect.Y), new Vector2(drawRect.X+rect.Width/2.0f, -drawRect.Y+rect.Height/2.0f),
new Vector2(e.DrawPosition.X, -e.DrawPosition.Y), new Vector2(e.DrawPosition.X, -e.DrawPosition.Y),
Color.Green); Color.Green);
} }
+1 -1
View File
@@ -271,7 +271,7 @@ namespace Barotrauma.Particles
prefab.Sprites[spriteIndex].Draw(spriteBatch, prefab.Sprites[spriteIndex].Draw(spriteBatch,
new Vector2(drawPosition.X, -drawPosition.Y), new Vector2(drawPosition.X, -drawPosition.Y),
color * alpha, color * alpha,
prefab.Sprites[spriteIndex].origin, drawRotation, prefab.Sprites[spriteIndex].Origin, drawRotation,
drawSize, SpriteEffects.None, prefab.Sprites[spriteIndex].Depth); drawSize, SpriteEffects.None, prefab.Sprites[spriteIndex].Depth);
prevPosition = position; prevPosition = position;
+13 -17
View File
@@ -143,28 +143,24 @@ namespace Barotrauma
} }
y+=50;
button = new GUIButton(new Rectangle(0, y+50, 0, 20), "Character mode", Alignment.Left, GUI.Style, GUIpanel); button = new GUIButton(new Rectangle(0, y, 0, 20), "Character mode", Alignment.Left, GUI.Style, GUIpanel);
button.ToolTip = "Allows you to pick up and use items. Useful for things such as placing items inside closets, turning devices on/off and doing the wiring."; button.ToolTip = "Allows you to pick up and use items. Useful for things such as placing items inside closets, turning devices on/off and doing the wiring.";
button.OnClicked = ToggleCharacterMode; button.OnClicked = ToggleCharacterMode;
button = new GUIButton(new Rectangle(0, y+100, 0, 20), "Generate waypoints", Alignment.Left, GUI.Style, GUIpanel); y+=50;
button = new GUIButton(new Rectangle(0, y, 0, 20), "Generate waypoints", Alignment.Left, GUI.Style, GUIpanel);
button.OnClicked = GenerateWaypoints; button.OnClicked = GenerateWaypoints;
y+=50;
new GUITextBlock(new Rectangle(0, y, 0, 20), "Show:", GUI.Style, GUIpanel);
var tickBox = new GUITickBox(new Rectangle(0,y+20,20,20), "Waypoints", Alignment.TopLeft, GUIpanel);
//GUItabs[0] = new GUIFrame(new Rectangle(GameMain.GraphicsWidth/2-width/2, GameMain.GraphicsHeight/2-height/2, width, height), GUI.Style); tickBox.OnSelected = (GUITickBox obj) => { WayPoint.ShowWayPoints = !WayPoint.ShowWayPoints; return true; };
//GUItabs[0].Padding = new Vector4(10.0f, 10.0f, 10.0f, 10.0f); tickBox = new GUITickBox(new Rectangle(0, y + 40, 20, 20), "Spawnpoints", Alignment.TopLeft, GUIpanel);
//GUIListBox itemList = new GUIListBox(new Rectangle(0, 0, 0, 0), Color.White * 0.7f, GUI.Style, GUItabs[0]); tickBox.OnSelected = (GUITickBox obj) => { WayPoint.ShowSpawnPoints = !WayPoint.ShowSpawnPoints; return true; };
//itemList.OnSelected = SelectPrefab;
//itemList.CheckSelected = MapEntityPrefab.GetSelected;
//GUItabs[1] = new GUIFrame(new Rectangle(GameMain.GraphicsWidth / 2 - width / 2, GameMain.GraphicsHeight / 2 - height / 2, width, height), GUI.Style);
//GUItabs[1].Padding = new Vector4(10.0f, 10.0f, 10.0f, 10.0f);
//GUIListBox structureList = new GUIListBox(new Rectangle(0, 0, 0, 0), Color.White * 0.7f, GUI.Style, GUItabs[1]);
//structureList.OnSelected = SelectPrefab;
//structureList.CheckSelected = MapEntityPrefab.GetSelected;
} }
public override void Select() public override void Select()
+2 -2
View File
@@ -22,7 +22,7 @@ namespace Barotrauma
//the offset used when drawing the sprite //the offset used when drawing the sprite
Vector2 offset; Vector2 offset;
public Vector2 origin; private Vector2 origin;
//the size of the drawn sprite, if larger than the source, //the size of the drawn sprite, if larger than the source,
//the sprite is tiled to fill the target size //the sprite is tiled to fill the target size
@@ -43,7 +43,7 @@ namespace Barotrauma
public float Depth public float Depth
{ {
get { return depth; } get { return depth; }
set { depth = Math.Min(Math.Max(value, 0.0f), 1.0f); } set { depth = MathHelper.Clamp(value, 0.0f, 1.0f); }
} }
public Vector2 Origin public Vector2 Origin
Binary file not shown.