waypoint selection bug, unequipped captain uniform sprites, repairtool sounds & particle tweaking, wire overlap bug, connectionpanel loading bug, looting dead crew members

This commit is contained in:
Regalis
2015-08-04 20:11:59 +03:00
parent 9149408b36
commit 048eb5713f
24 changed files with 154 additions and 71 deletions

View File

@@ -18,12 +18,12 @@
pickdistance="150"
tags="smallitem">
<Sprite texture ="captainTorso.png" depth="0.4"/>
<Sprite texture ="captainLegs.png" sourcerect="0,49,52,17" depth="0.4"/>
<Body radius="8" density="5"/>
<Body width="52" height="17"/>
<Wearable slots="Torso">
<sprite texture="captainTorso.png" limb="Torso" sourcerect="0,3,30,58" origin="0.5,0.45" depth="0.01"/>
<Wearable slots="Any,Torso">
<sprite texture="captainTorso.png" limb="Torso" sourcerect="0,3,30,58" origin="0.5,0.48" depth="0.01"/>
<sprite texture="captainTorso.png" limb="RightHand" sourcerect="47,0,15,39" origin="0.45,0.6"/>
<sprite texture="captainTorso.png" limb="LeftHand" sourcerect="47,0,15,39" origin="0.45,0.6" depth="0.14"/>
@@ -38,11 +38,11 @@
pickdistance="150"
tags="smallitem">
<Sprite texture ="captainLegs.png" depth="0.4"/>
<Sprite texture ="captainLegs.png" sourcerect="0,67,51,13" depth="0.4"/>
<Body radius="8" density="5"/>
<Body width="51" height="13"/>
<Wearable slots="Legs">
<Wearable slots="Any,Legs">
<sprite texture="captainLegs.png" limb="Waist" sourcerect="0,0,1,1" origin="0.5,0.5" hidelimb="true"/>
<sprite texture="captainLegs.png" limb="RightThigh" sourcerect="52,34,28,46" origin="0.5,0.5" depth="0.10" hidelimb="true"/>
<sprite texture="captainLegs.png" limb="LeftThigh" sourcerect="52,34,28,46" origin="0.5,0.5" depth="0.14" hidelimb="true"/>

View File

@@ -20,7 +20,7 @@
pickdistance="200"
price="50">
<Sprite texture ="DivingMask.png" depth="0.4"/>
<Sprite texture ="DivingMask.png" depth="0.5"/>
<Body radius="18" density="5"/>
@@ -42,7 +42,7 @@
pickdistance="200"
price="200">
<Sprite texture ="DivingSuit.png" sourcerect="82,15,46,113" depth="0.4"/>
<Sprite texture ="DivingSuit.png" sourcerect="82,15,46,113" depth="0.5"/>
<Body width="37" height="113" density="5"/>

View File

@@ -77,7 +77,7 @@
<Explosion range="5" damage="20" stun="10" force="5.0"/>
</StatusEffect>
<LightComponent color="1.0,1.0,1.0,1.0" Flicker="0.5">
<LightComponent color="0.1,0.8,1.0,1.0" Flicker="0.5">
<sprite texture="Content/Items/Electricity/lightsprite.png" origin="0.5,0.5"/>
</LightComponent>
</RepairTool>

View File

@@ -11,8 +11,8 @@
<Body width="16" height="7"/>
<Pickable slots="Any">
<StatusEffect type="OnBroken" target="This" Condition="-100.0" sound="Content/Items/Weapons/stunGrenade.ogg">
<Explosion range="10.0" structuredamage="600" damage="100" stun="5" force="20.0"/>
<StatusEffect type="OnBroken" target="This" Condition="-100.0" sound="Content/Items/Reactor/explosion.ogg">
<Explosion range="5.0" structuredamage="300" damage="200" stun="5" force="20.0"/>
</StatusEffect>
</Pickable>
</Item>

View File

@@ -51,7 +51,7 @@
<Sprite texture ="railgunloader.png" depth =" 0.8"/>
<ItemContainer hideitems="false" drawinventory="true" capacity="5" itempos="54,-61" iteminterval="40,0" canbeselected = "true">
<ItemContainer hideitems="false" drawinventory="true" capacity="5" itempos="54,-61" iteminterval="40,0" itemrotation="-90" canbeselected = "true">
<Containable name="Railgun Shell"/>
</ItemContainer>
@@ -63,14 +63,17 @@
<Sprite texture ="railgunshell.png" depth ="0.5"/>
<Body radius="9" height="67"/>
<Body width="87" height="18"/>
<Holdable slots="BothHands" holdpos="0,-50" handle1="-10,0" handle2="10,0" aimable="false"/>
<Projectile launchimpulse="80.0">
<Attack damage="100" bleedingdamage="10" structuredamage="200" damagetype="Blunt"/>
</Projectile>
<ItemContainer hideitems="true" capacity="1" canbeselected = "true">
<Containable name="smallitem"/>
</ItemContainer>
</Item>
</Items>

View File

@@ -5,7 +5,7 @@
Tags="smallitem"
pickdistance="150">
<Sprite texture ="idcard.png"/>
<Sprite texture ="idcard.png" depth="0.5f"/>
<Body width="16" height="16" density="10"/>

View File

@@ -87,10 +87,10 @@
<weld
startsizemin="0.9,0.9" startsizemax="1.1,1.1"
sizechangemin="-0.1,-0.1" sizechangemax="0.1,0.1"
sizechangemin="-4.0,-0.1" sizechangemax="-4.0,-0.5"
startcolor="1.0, 1.0, 1.0" startalpha="1.0"
colorchange="0.0, 0.0, -1.0, -5.0"
lifetime="0.5"
colorchange="0.0, 0.0, 0.0, -4.0"
lifetime="0.25"
inwater="false"
velocitychange="0.0, 0.0">
<sprite texture="Content/Particles/flames.png" sourcerect="0,0,128,64" origin="0.15,0.5"/>
@@ -98,10 +98,10 @@
<plasma
startsizemin="0.9,0.9" startsizemax="1.1,1.1"
sizechangemin="-0.1,-0.1" sizechangemax="0.1,0.1"
sizechangemin="-4.0,-0.5" sizechangemax="-4.0,-0.5"
startcolor="1.0, 1.0, 1.0" startalpha="1.0"
colorchange="0.0, 0.0, -1.0, -5.0"
lifetime="0.5"
colorchange="0.0, 0.0, 0.0, -4.0"
lifetime="0.25"
inwater="false"
velocitychange="0.0, 0.0">
<sprite texture="Content/Particles/flames.png" sourcerect="0,64,128,64" origin="0.15,0.5"/>

View File

@@ -34,7 +34,7 @@ namespace Subsurface
public readonly bool IsNetworkPlayer;
private Inventory inventory;
private CharacterInventory inventory;
public double LastNetworkUpdate;
@@ -66,6 +66,7 @@ namespace Subsurface
protected float maxHealth;
protected Item closestItem;
private Character closestCharacter, selectedCharacter;
protected bool isDead;
@@ -93,7 +94,6 @@ namespace Subsurface
protected float soundInterval;
private float bleeding;
//private float blood;
private Sound[] sounds;
private float[] soundRange;
@@ -113,7 +113,7 @@ namespace Subsurface
get { return AnimController.Mass; }
}
public Inventory Inventory
public CharacterInventory Inventory
{
get { return inventory; }
}
@@ -301,11 +301,11 @@ namespace Subsurface
public Character(string file, Vector2 position, CharacterInfo characterInfo = null, bool isNetworkPlayer = false)
{
selectKeyHit = new Key(false);
actionKeyDown = new Key(true);
actionKeyHit = new Key(false);
secondaryKeyHit = new Key(false);
secondaryKeyDown = new Key(true);
selectKeyHit = new Key(false);
actionKeyDown = new Key(true);
actionKeyHit = new Key(false);
secondaryKeyHit = new Key(false);
secondaryKeyDown = new Key(true);
selectedItems = new Item[2];
@@ -330,7 +330,7 @@ namespace Subsurface
{
AnimController = new HumanoidAnimController(this, doc.Root.Element("ragdoll"));
AnimController.TargetDir = Direction.Right;
inventory = new CharacterInventory(10, this);
inventory = new CharacterInventory(15, this);
}
else
{
@@ -432,11 +432,15 @@ namespace Subsurface
}
Item item = new Item(itemPrefab, Position);
inventory.TryPutItem(item, item.AllowedSlots, false);
if (info.Job.EquipSpawnItem[i])
{
item.Equip(this);
inventory.TryPutItem(item,
item.AllowedSlots.HasFlag(LimbSlot.Any) ? item.AllowedSlots & ~LimbSlot.Any : item.AllowedSlots, false);
}
else
{
inventory.TryPutItem(item, item.AllowedSlots, false);
}
if (item.Prefab.Name == "ID Card" && spawnPoint != null)
@@ -460,8 +464,7 @@ namespace Subsurface
//find the closest item if selectkey has been hit, or if the character is being
//controlled by the player (in order to highlight it)
//closestItem = null;
if (controlled==this)
if (controlled == this)
{
Vector2 mouseSimPos = ConvertUnits.ToSimUnits(cam.ScreenToWorld(PlayerInput.MousePosition));
closestItem = FindClosestItem(mouseSimPos);
@@ -474,6 +477,13 @@ namespace Subsurface
new NetworkEvent(NetworkEventType.PickItem, ID, true, closestItem.ID);
}
}
closestCharacter = FindClosestCharacter(mouseSimPos);
if (closestCharacter != selectedCharacter) selectedCharacter = null;
if (closestCharacter!=null)
{
if (selectKeyHit.State) selectedCharacter = (selectedCharacter==null) ? closestCharacter : null;
}
}
for (int i = 0; i < selectedItems.Length; i++ )
@@ -509,6 +519,31 @@ namespace Subsurface
return Item.FindPickable(pos, selectedConstruction == null ? mouseSimPos : selectedConstruction.SimPosition, null, selectedItems);
}
private Character FindClosestCharacter(Vector2 mouseSimPos, float maxDist = 150.0f)
{
Character closestCharacter = null;
float closestDist = 0.0f;
maxDist = ConvertUnits.ToSimUnits(maxDist);
foreach (Character c in Character.CharacterList)
{
if (c == this) continue;
if (Vector2.Distance(SimPosition, c.SimPosition) > maxDist) continue;
float dist = Vector2.Distance(mouseSimPos, c.SimPosition);
if (dist < maxDist && closestCharacter==null || dist<closestDist)
{
closestCharacter = c;
closestDist = dist;
continue;
}
}
return closestCharacter;
}
/// <summary>
/// Control the character according to player input
/// </summary>
@@ -743,10 +778,10 @@ namespace Subsurface
private static GUIProgressBar drowningBar, healthBar;
public void DrawHud(SpriteBatch spriteBatch, Camera cam)
{
if (drowningBar==null)
if (drowningBar == null)
{
int width = 100, height = 20;
drowningBar = new GUIProgressBar(new Rectangle(20, Game1.GraphicsHeight/2, width, height), Color.Blue, 1.0f);
drowningBar = new GUIProgressBar(new Rectangle(20, Game1.GraphicsHeight / 2, width, height), Color.Blue, 1.0f);
healthBar = new GUIProgressBar(new Rectangle(20, Game1.GraphicsHeight / 2 + 30, width, height), Color.Red, 1.0f);
}
@@ -757,11 +792,26 @@ namespace Subsurface
healthBar.BarSize = health / maxHealth;
if (healthBar.BarSize < 1.0f) healthBar.Draw(spriteBatch);
if (Controlled.Inventory != null) Controlled.Inventory.Draw(spriteBatch);
if (Controlled.Inventory != null) Controlled.Inventory.DrawOwn(spriteBatch);
if (closestItem != null && selectedConstruction==null)
Color color = Color.Orange;
if (closestCharacter != null && closestCharacter.isDead)
{
Vector2 startPos = Position + (closestCharacter.Position - Position) * 0.7f;
startPos = cam.WorldToScreen(startPos);
Vector2 textPos = startPos;
float stringWidth = GUI.Font.MeasureString(closestCharacter.Info.Name).X;
textPos -= new Vector2(stringWidth / 2, 20);
spriteBatch.DrawString(GUI.Font, closestCharacter.Info.Name, textPos, Color.Black);
spriteBatch.DrawString(GUI.Font, closestCharacter.Info.Name, textPos + new Vector2(1, -1), Color.Orange);
if (selectedCharacter==closestCharacter) closestCharacter.inventory.Draw(spriteBatch);
}
else if (closestItem != null && selectedConstruction==null)
{
Color color = Color.Orange;
Vector2 startPos = Position + (closestItem.Position - Position) * 0.7f;
startPos = cam.WorldToScreen(startPos);
@@ -782,7 +832,7 @@ namespace Subsurface
spriteBatch.DrawString(GUI.Font, coloredText.text, textPos + new Vector2(1, -1), coloredText.color);
textPos.Y += 25;
}
}
}
}

View File

@@ -19,7 +19,8 @@ namespace Subsurface
private static LimbSlot[] limbSlots = new LimbSlot[] {
LimbSlot.Head, LimbSlot.Torso, LimbSlot.Legs, LimbSlot.LeftHand, LimbSlot.RightHand,
LimbSlot.Any, LimbSlot.Any, LimbSlot.Any, LimbSlot.Any, LimbSlot.Any };
LimbSlot.Any, LimbSlot.Any, LimbSlot.Any, LimbSlot.Any, LimbSlot.Any,
LimbSlot.Any, LimbSlot.Any, LimbSlot.Any, LimbSlot.Any, LimbSlot.Any};
private Vector2[] slotPositions;
@@ -52,12 +53,12 @@ namespace Subsurface
case 4:
slotPositions[i] = new Vector2(
spacing * 2 + rectWidth + (spacing + rectWidth) * (i - 3),
Game1.GraphicsHeight - (spacing + rectHeight));
Game1.GraphicsHeight - (spacing + rectHeight)*3);
break;
default:
slotPositions[i] = new Vector2(
spacing * (4 + (i - 5)) + rectWidth * (3 + (i - 5)),
Game1.GraphicsHeight - (spacing + rectHeight));
spacing * 2 + rectWidth + (spacing + rectWidth) * ((i - 3)%5),
Game1.GraphicsHeight - (spacing + rectHeight) * ((i>9) ? 2 : 1));
break;
}
}
@@ -212,7 +213,7 @@ namespace Subsurface
}
public override void Draw(SpriteBatch spriteBatch)
public void DrawOwn(SpriteBatch spriteBatch)
{
if (doubleClickedItem!=null && doubleClickedItem.inventory!=this)
{
@@ -251,7 +252,7 @@ namespace Subsurface
slotRect.Y = (int)slotPositions[i].Y;
UpdateSlot(spriteBatch, slotRect, i, items[i], false);
UpdateSlot(spriteBatch, slotRect, i, items[i], i>4);
if (draggingItem!=null && draggingItem == items[i]) draggingItemSlot = slotRect;
}

View File

@@ -58,8 +58,8 @@ namespace Subsurface.Items.Components
[HasDefaultValue(0.0f, false)]
public float ItemRotation
{
get { return itemRotation; }
set { itemRotation = value; }
get { return MathHelper.ToDegrees(itemRotation); }
set { itemRotation = MathHelper.ToRadians(value); }
}
private float itemRotation;

View File

@@ -183,6 +183,17 @@ namespace Subsurface.Items.Components
if (!attachable || item.body==null) return true;
item.Drop();
var containedItems = item.ContainedItems;
if (containedItems!=null)
{
foreach (Item contained in containedItems)
{
if (contained.body == null) continue;
contained.SetTransform(item.SimPosition, contained.body.Rotation);
}
}
item.body.Enabled = false;
item.body = null;

View File

@@ -124,7 +124,7 @@ namespace Subsurface.Items.Components
Body targetBody = Submarine.PickBody(TransformedBarrelPos, targetPosition, ignoredBodies);
pickedPosition = Submarine.LastPickedPosition;
if (targetBody==null || targetBody.UserData==null) return true;
if (targetBody == null || targetBody.UserData == null) return true;
//ApplyStatusEffects(ActionType.OnUse, 1.0f, character);

View File

@@ -550,9 +550,7 @@ namespace Subsurface.Items.Components
public virtual void Load(XElement componentElement)
{
if (componentElement == null) return;
if (componentElement == null) return;
foreach (XAttribute attribute in componentElement.Attributes())
{

View File

@@ -179,6 +179,10 @@ namespace Subsurface.Items.Components
foreach (Item contained in item.ContainedItems)
{
contained.Condition = 0.0f;
if (contained.body!=null)
{
contained.body.SetTransform(item.SimPosition, contained.body.Rotation);
}
}
return true;

View File

@@ -28,7 +28,7 @@ namespace Subsurface.Items.Components
private List<StatusEffect> effects;
int[] wireId;
public readonly int[] wireId;
public List<Connection> Recipients
{
@@ -463,7 +463,7 @@ namespace Subsurface.Items.Components
}
}
wireId = null;
//wireId = null;
}
}

View File

@@ -74,21 +74,26 @@ namespace Subsurface.Items.Components
public override void Load(XElement element)
{
base.Load(element);
connections.Clear();
List<Connection> loadedConnections = new List<Connection>();
foreach (XElement subElement in element.Elements())
{
switch (subElement.Name.ToString())
{
case "input":
connections.Add(new Connection(subElement, item));
loadedConnections.Add(new Connection(subElement, item));
break;
case "output":
connections.Add(new Connection(subElement, item));
loadedConnections.Add(new Connection(subElement, item));
break;
}
}
for (int i = 0; i<loadedConnections.Count && i<connections.Count; i++)
{
loadedConnections[i].wireId.CopyTo(connections[i].wireId, 0);
}
}
public override void Remove()

View File

@@ -274,12 +274,12 @@ namespace Subsurface.Items.Components
for (int i = 1; i < Nodes.Count; i++)
{
DrawSection(spriteBatch, Nodes[i], Nodes[i - 1], i, item.Color);
DrawSection(spriteBatch, Nodes[i], Nodes[i - 1], item.Color);
}
if (isActive && Vector2.Distance(newNodePos, Nodes[Nodes.Count - 1]) > nodeDistance)
{
DrawSection(spriteBatch, Nodes[Nodes.Count - 1], newNodePos, Nodes.Count, item.Color * 0.5f);
DrawSection(spriteBatch, Nodes[Nodes.Count - 1], newNodePos, item.Color * 0.5f);
//nodes.Add(newNodePos);
}
@@ -333,7 +333,7 @@ selectedNodeIndex = null;
}
private void DrawSection(SpriteBatch spriteBatch, Vector2 start, Vector2 end, int i, Color color)
private void DrawSection(SpriteBatch spriteBatch, Vector2 start, Vector2 end, Color color)
{
start.Y = -start.Y;
end.Y = -end.Y;
@@ -344,7 +344,7 @@ selectedNodeIndex = null;
new Vector2(0.0f, wireSprite.size.Y / 2.0f),
new Vector2((Vector2.Distance(start, end)) / wireSprite.Texture.Width, 0.3f),
SpriteEffects.None,
wireSprite.Depth + 0.1f + i * 0.00001f);
wireSprite.Depth + ((item.ID % 100) * 0.00001f));
}
public override XElement Save(XElement parentElement)

View File

@@ -450,13 +450,21 @@ namespace Subsurface
{
if (ic.Parent != null) ic.IsActive = ic.Parent.IsActive;
if (!ic.WasUsed) ic.StopSounds(ActionType.OnUse);
ic.WasUsed = false;
//if (!ic.WasUsed)
//{
// if (ic.Name == "RepairTool" && ic.IsActive)
// {
// System.Diagnostics.Debug.WriteLine("stop sounds");
// }
// ic.StopSounds(ActionType.OnUse);
//}
//ic.WasUsed = false;
if (!ic.IsActive)
{
ic.StopSounds(ActionType.OnActive);
ic.StopSounds(ActionType.OnUse);
continue;
}
if (condition > 0.0f)

View File

@@ -436,7 +436,7 @@ namespace Subsurface
float dragCoefficient = 0.00001f;
float speedLength = speed.Length();
float speedLength = (speed == Vector2.Zero) ? 0.0f : speed.Length();
float drag = speedLength * speedLength * dragCoefficient * mass;
if (speed != Vector2.Zero)

View File

@@ -73,7 +73,7 @@ namespace Subsurface
public override void DrawEditing(SpriteBatch spriteBatch, Camera cam)
{
if (editingHUD==null)
if (editingHUD == null || editingHUD.UserData != this)
{
editingHUD = CreateEditingHUD();
}

View File

@@ -258,7 +258,6 @@ namespace Subsurface.Networking
{
Character.Controlled = null;
Game1.GameScreen.Cam.TargetPos = Vector2.Zero;
Game1.GameScreen.Cam.Zoom = 1.0f;
}
else
{

View File

@@ -161,9 +161,8 @@ namespace Subsurface.Particles
float drawRotation = Physics.Interpolate(prevRotation, rotation);
drawPosition = ConvertUnits.ToDisplayUnits(drawPosition);
prefab.sprite.Draw(spriteBatch, drawPosition, color*alpha, drawRotation, size.X, SpriteEffects.None, prefab.sprite.Depth);
prefab.sprite.Draw(spriteBatch, drawPosition, color*alpha, prefab.sprite.origin, drawRotation, size, SpriteEffects.None, prefab.sprite.Depth);
//spriteBatch.Draw(
// prefab.sprite.Texture,

View File

@@ -194,6 +194,11 @@ namespace Subsurface
{
spriteBatch.Draw(texture, pos + offset, sourceRect, color, rotation + rotate, origin, scale, spriteEffect, depth == null ? this.depth : (float)depth);
}
public void Draw(SpriteBatch spriteBatch, Vector2 pos, Color color, Vector2 origin, float rotate, Vector2 scale, SpriteEffects spriteEffect = SpriteEffects.None, float? depth = null)
{
spriteBatch.Draw(texture, pos + offset, sourceRect, color, rotation + rotate, origin, scale, spriteEffect, depth == null ? this.depth : (float)depth);
}
public void DrawTiled(SpriteBatch spriteBatch, Vector2 pos, Vector2 targetSize, Color color)
{

Binary file not shown.