v0.2: iteminventory sync bugfix, meleeweapon "reload time", spears can be picked even if they're stuck inside a wall, tutorial bugfixes, "submarine godmode", removed round duration, drag character sync, reliable structure damage messages, job assignment bugfixes, some extra sounds

This commit is contained in:
Regalis
2015-10-17 16:01:42 +03:00
parent 838022fcd5
commit 3c1a66078c
51 changed files with 457 additions and 213 deletions
@@ -2,6 +2,7 @@
using FarseerPhysics.Dynamics;
using FarseerPhysics.Dynamics.Contacts;
using Microsoft.Xna.Framework;
using System;
using System.Xml.Linq;
namespace Barotrauma.Items.Components
@@ -18,6 +19,10 @@ namespace Barotrauma.Items.Components
private Character user;
private float reload;
private float reloadTimer;
[HasDefaultValue(0.0f, false)]
public float Range
{
@@ -25,6 +30,13 @@ namespace Barotrauma.Items.Components
set { range = ConvertUnits.ToSimUnits(value); }
}
[HasDefaultValue(0.5f, false)]
public float Reload
{
get { return reload; }
set { reload = Math.Max(0.0f, value); }
}
public MeleeWeapon(Item item, XElement element)
: base(item, element)
{
@@ -35,22 +47,19 @@ namespace Barotrauma.Items.Components
if (subElement.Name.ToString().ToLower() != "attack") continue;
attack = new Attack(subElement);
}
if (attack==null)
{
DebugConsole.ThrowError("Item ''"+item.Name+"'' doesn't have an attack configured");
}
}
public override bool Use(float deltaTime, Character character = null)
{
if (character == null) return false;
if (character == null || reloadTimer>0.0f) return false;
if (!character.GetInputState(InputType.SecondaryHeld) || hitting) return false;
user = character;
if (hitPos < MathHelper.Pi * 0.69f) return false;
reloadTimer = reload;
item.body.FarseerBody.CollisionCategories = Physics.CollisionProjectile;
item.body.FarseerBody.CollidesWith = Physics.CollisionCharacter | Physics.CollisionWall;
item.body.FarseerBody.OnCollision += OnCollision;
@@ -95,6 +104,8 @@ namespace Barotrauma.Items.Components
if (!item.body.Enabled) return;
if (!picker.HasSelectedItem(item)) IsActive = false;
reloadTimer -= deltaTime;
if (!picker.GetInputState(InputType.SecondaryHeld) && !hitting) hitPos = 0.0f;
ApplyStatusEffects(ActionType.OnActive, deltaTime, picker);
@@ -117,8 +128,6 @@ namespace Barotrauma.Items.Components
{
ac.HoldItem(deltaTime, item, handlePos, new Vector2(hitPos, 0.0f), aimPos, false, 0.0f);
}
}
else
{
@@ -174,20 +183,24 @@ namespace Barotrauma.Items.Components
if (limb.character == picker) return false;
target = limb.character;
}
else
{
return false;
}
if (target==null)
if (target == null)
{
target = f2.Body.UserData as IDamageable;
}
if (target == null) return false;
attack.DoDamage(user, target, item.Position, 1.0f);
if (attack!=null) attack.DoDamage(user, target, item.Position, 1.0f);
RestoreCollision();
hitting = false;
ApplyStatusEffects(ActionType.OnUse, 1.0f, picker);
ApplyStatusEffects(ActionType.OnUse, 1.0f, limb.character);
return true;
}