Attachable items aren't automatically attached when loading a sub in edit screen, bunch of new item sprites, Aegir Mark II, client reconnect bugfixes

This commit is contained in:
Regalis
2015-09-27 15:46:55 +03:00
parent da00b083ed
commit c8ee9e085f
30 changed files with 249 additions and 149 deletions
@@ -66,12 +66,14 @@ namespace Subsurface
protected override void DropItem(Item item)
{
bool enabled = draggingItem.body.Enabled;
if (item.body == null) return;
bool enabled = item.body.Enabled;
item.Drop(character);
if (!enabled)
{
draggingItem.body.SetTransform(character.SimPosition, 0.0f);
item.SetTransform(character.SimPosition, 0.0f);
}
}
@@ -101,7 +101,7 @@ namespace Subsurface.Items.Components
Msg = "";
}
if (attachedByDefault || Screen.Selected == GameMain.EditMapScreen) Use(1.0f);
if (attachedByDefault || (Screen.Selected == GameMain.EditMapScreen && Submarine.Loaded!=null)) Use(1.0f);
//holdAngle = ToolBox.GetAttributeFloat(element, "holdangle", 0.0f);
@@ -131,9 +131,9 @@ namespace Subsurface.Items.Components
public override bool Use(float deltaTime, Character activator = null)
{
if (character.SelectedConstruction != item)
if (activator.SelectedConstruction != item)
{
character = null;
activator = null;
return false;
}
@@ -299,7 +299,7 @@ namespace Subsurface.Items.Components
if (selectedNodeIndex == null && !MapEntity.SelectedAny)
{
if (PlayerInput.LeftButtonDown())
if (PlayerInput.LeftButtonDown() && PlayerInput.GetOldMouseState.LeftButton == Microsoft.Xna.Framework.Input.ButtonState.Released)
{
MapEntity.SelectEntity(item);
selectedNodeIndex = i;
@@ -130,10 +130,14 @@ namespace Subsurface.Items.Components
{
base.Update(deltaTime, cam);
item.SetTransform(picker.SimPosition, 0.0f);
Item[] containedItems = item.ContainedItems;
ApplyStatusEffects(ActionType.OnWearing, deltaTime, picker);
PlaySound(ActionType.OnWearing, picker.Position);
if (containedItems == null) return;
for (int j = 0; j<containedItems.Length; j++)
{
+26 -21
View File
@@ -27,8 +27,7 @@ namespace Subsurface
protected ItemPrefab prefab;
private List<string> tags;
public Hull CurrentHull;
//components that determine the functionality of the item
@@ -79,6 +78,22 @@ namespace Subsurface
get { return prefab.PickDistance; }
}
protected Color spriteColor;
[Editable, HasDefaultValue("1.0,1.0,1.0,1.0", true)]
public string SpriteColor
{
get { return ToolBox.Vector4ToString(spriteColor.ToVector4()); }
set
{
spriteColor = new Color(ToolBox.ParseToVector4(value));
}
}
public Color Color
{
get { return spriteColor; }
}
public float Condition
{
get { return condition; }
@@ -104,22 +119,6 @@ namespace Subsurface
get { return condition; }
}
private Color spriteColor;
[Editable, HasDefaultValue("1.0,1.0,1.0,1.0", true)]
public string SpriteColor
{
get { return ToolBox.Vector4ToString(spriteColor.ToVector4()); }
set
{
spriteColor = new Color(ToolBox.ParseToVector4(value));
}
}
public Color Color
{
get { return spriteColor; }
}
[Editable, HasDefaultValue("", true)]
public string Tags
{
@@ -242,6 +241,8 @@ namespace Subsurface
{
prefab = itemPrefab;
spriteColor = prefab.SpriteColor;
linkedTo = new ObservableCollection<MapEntity>();
components = new List<ItemComponent>();
FixRequirements = new List<FixRequirement>();
@@ -323,11 +324,15 @@ namespace Subsurface
}
public void SetTransform(Vector2 position, float rotation)
public void SetTransform(Vector2 simPosition, float rotation)
{
body.SetTransform(position, rotation);
if (body != null)
{
body.SetTransform(simPosition, rotation);
}
Vector2 displayPos = ConvertUnits.ToDisplayUnits(body.SimPosition);
Vector2 displayPos = ConvertUnits.ToDisplayUnits(simPosition);
rect.X = (int)(displayPos.X - rect.Width / 2.0f);
rect.Y = (int)(displayPos.Y + rect.Height / 2.0f);
+3
View File
@@ -157,6 +157,9 @@ namespace Subsurface
offsetOnSelected = ToolBox.GetAttributeFloat(element, "offsetonselected", 0.0f);
string spriteColorStr = ToolBox.GetAttributeString(element, "spritecolor", "1.0,1.0,1.0,1.0");
SpriteColor = new Color(ToolBox.ParseToVector4(spriteColorStr));
price = ToolBox.GetAttributeInt(element, "price", 0);
Triggers = new List<Rectangle>();