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

View File

@@ -367,7 +367,27 @@ namespace Launcher2
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)

Binary file not shown.

Before

Width:  |  Height:  |  Size: 2.8 KiB

After

Width:  |  Height:  |  Size: 2.8 KiB

View File

@@ -10,7 +10,9 @@
<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]">
<requireditem name="Screwdriver,Wire" type="Equipped"/>

Binary file not shown.

Before

Width:  |  Height:  |  Size: 7.4 KiB

After

Width:  |  Height:  |  Size: 7.4 KiB

View File

@@ -221,7 +221,7 @@
<Sprite texture="signalcomp.png" depth="0.8" sourcerect="48,0,16,16"/>
<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>
<Body width="16" height="16"/>

View File

@@ -13,7 +13,7 @@
rotationlimits="180,360"
powerconsumption="500.0">
<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>
</Turret>

View File

@@ -55,7 +55,7 @@
<GUITextBox
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"
outlinecolor="0.5, 0.57, 0.6, 1.0">
</GUITextBox>

View File

@@ -499,7 +499,7 @@ namespace Barotrauma
damagedSprite.Draw(spriteBatch,
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,
1.0f, spriteEffect, depth);
}

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 String Text

View File

@@ -325,10 +325,12 @@ namespace Barotrauma.Items.Components
if (index>-1 && wireComponent!=null && !Wires.Contains(wireComponent))
{
bool alreadyConnected = wireComponent.IsConnectedTo(item);
wireComponent.RemoveConnection(item);
Wires[index] = wireComponent;
wireComponent.Connect(this);
wireComponent.Connect(this, !alreadyConnected);
}
}
//far away -> disconnect if the wire is linked to this connector

View File

@@ -13,13 +13,11 @@ namespace Barotrauma.Items.Components
private Color lightColor;
//private Sprite sprite;
private LightSource light;
LightSource light;
private float range;
float range;
float lightBrightness;
private float lightBrightness;
private float flicker;
@@ -81,18 +79,17 @@ namespace Barotrauma.Items.Components
public LightComponent(Item item, XElement 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);
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)
@@ -101,9 +98,7 @@ namespace Barotrauma.Items.Components
if (item.CurrentHull != null)
{
light.Submarine = item.CurrentHull.Submarine;
}
}
if (item.container != null)
{

View File

@@ -57,6 +57,12 @@ namespace Barotrauma.Items.Components
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)
{
for (int i = 0; i<2; i++)

View File

@@ -8,7 +8,16 @@ namespace Barotrauma.Lights
class LightManager
{
//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;

View File

@@ -19,6 +19,8 @@ namespace Barotrauma.Lights
private Texture2D texture;
public Sprite LightSprite;
public Entity Submarine;
//what was the range of the light when HullsInRange were last updated
@@ -85,7 +87,7 @@ namespace Barotrauma.Lights
this.range = range;
this.color = color;
texture = lightTexture;
texture = LightTexture;
GameMain.LightManager.AddLight(this);
}
@@ -106,6 +108,11 @@ namespace Barotrauma.Lights
Vector2 center = new Vector2(LightTexture.Width / 2, LightTexture.Height / 2);
float scale = range / (lightTexture.Width / 2.0f);
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()

View File

@@ -35,7 +35,7 @@ namespace Barotrauma
private Body body;
private Vector2 targetPosition;
private Vector2? targetPosition;
float mass = 10000.0f;
@@ -60,7 +60,7 @@ namespace Barotrauma
public Vector2 TargetPosition
{
get { return targetPosition; }
//get { return targetPosition; }
set
{
if (!MathUtils.IsValid(value)) return;
@@ -210,26 +210,33 @@ namespace Barotrauma
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)
{
body.SetTransform(ConvertUnits.ToSimUnits(targetPosition), 0.0f);
targetPosition = Vector2.Zero;
body.SetTransform(targetSimPos, 0.0f);
targetPosition = null;
}
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
{
targetPosition = Vector2.Zero;
targetPosition = null;
}
//-------------------------
Vector2 totalForce = CalculateBuoyancy();

View File

@@ -15,6 +15,8 @@ namespace Barotrauma
{
public static List<WayPoint> WayPointList = new List<WayPoint>();
public static bool ShowWayPoints, ShowSpawnPoints;
private SpawnType spawnType;
//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 (spawnType == SpawnType.Path)
{
if (!GameMain.DebugDraw && !ShowWayPoints) return;
}
else
{
if (!GameMain.DebugDraw && !ShowSpawnPoints) return;
}
Rectangle drawRect =
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)
{
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),
Color.Green);
}

View File

@@ -271,7 +271,7 @@ namespace Barotrauma.Particles
prefab.Sprites[spriteIndex].Draw(spriteBatch,
new Vector2(drawPosition.X, -drawPosition.Y),
color * alpha,
prefab.Sprites[spriteIndex].origin, drawRotation,
prefab.Sprites[spriteIndex].Origin, drawRotation,
drawSize, SpriteEffects.None, prefab.Sprites[spriteIndex].Depth);
prevPosition = position;

View File

@@ -143,28 +143,24 @@ namespace Barotrauma
}
button = new GUIButton(new Rectangle(0, y+50, 0, 20), "Character mode", Alignment.Left, GUI.Style, GUIpanel);
y+=50;
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.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;
y+=50;
new GUITextBlock(new Rectangle(0, y, 0, 20), "Show:", GUI.Style, GUIpanel);
//GUItabs[0] = new GUIFrame(new Rectangle(GameMain.GraphicsWidth/2-width/2, GameMain.GraphicsHeight/2-height/2, width, height), GUI.Style);
//GUItabs[0].Padding = new Vector4(10.0f, 10.0f, 10.0f, 10.0f);
//GUIListBox itemList = new GUIListBox(new Rectangle(0, 0, 0, 0), Color.White * 0.7f, GUI.Style, GUItabs[0]);
//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;
var tickBox = new GUITickBox(new Rectangle(0,y+20,20,20), "Waypoints", Alignment.TopLeft, GUIpanel);
tickBox.OnSelected = (GUITickBox obj) => { WayPoint.ShowWayPoints = !WayPoint.ShowWayPoints; return true; };
tickBox = new GUITickBox(new Rectangle(0, y + 40, 20, 20), "Spawnpoints", Alignment.TopLeft, GUIpanel);
tickBox.OnSelected = (GUITickBox obj) => { WayPoint.ShowSpawnPoints = !WayPoint.ShowSpawnPoints; return true; };
}
public override void Select()

View File

@@ -22,7 +22,7 @@ namespace Barotrauma
//the offset used when drawing the sprite
Vector2 offset;
public Vector2 origin;
private Vector2 origin;
//the size of the drawn sprite, if larger than the source,
//the sprite is tiled to fill the target size
@@ -43,7 +43,7 @@ namespace Barotrauma
public float 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

Binary file not shown.