assigning jobs when a round starts, crew tab in multiplayer, repairtool particles light & sounds, attachable buttons, increased repairtool range & limbdamage, captain's uniform, wearable sprite bugfixes
This commit is contained in:
@@ -14,8 +14,6 @@ namespace Subsurface.Items.Components
|
||||
|
||||
string prevMsg;
|
||||
|
||||
//protected Character picker;
|
||||
|
||||
//the distance from the holding characters elbow to center of the physics body of the item
|
||||
protected Vector2 holdPos;
|
||||
|
||||
@@ -23,8 +21,7 @@ namespace Subsurface.Items.Components
|
||||
|
||||
protected bool aimable;
|
||||
|
||||
private bool attachable;
|
||||
private bool attached;
|
||||
private bool attachable, attached, attachedByDefault;
|
||||
private PhysicsBody body;
|
||||
|
||||
//the angle in which the character holds the item
|
||||
@@ -51,6 +48,13 @@ namespace Subsurface.Items.Components
|
||||
set { attachable = value; }
|
||||
}
|
||||
|
||||
[HasDefaultValue(false, false)]
|
||||
public bool AttachedByDefault
|
||||
{
|
||||
get { return attachedByDefault; }
|
||||
set { attachedByDefault = value; }
|
||||
}
|
||||
|
||||
[HasDefaultValue("0.0,0.0", false)]
|
||||
public string HoldPos
|
||||
{
|
||||
@@ -97,6 +101,8 @@ namespace Subsurface.Items.Components
|
||||
Msg = "";
|
||||
}
|
||||
|
||||
if (attachedByDefault) Use(1.0f);
|
||||
|
||||
|
||||
//holdAngle = ToolBox.GetAttributeFloat(element, "holdangle", 0.0f);
|
||||
//holdAngle = MathHelper.ToRadians(holdAngle);
|
||||
|
||||
@@ -19,6 +19,8 @@ namespace Subsurface.Items.Components
|
||||
|
||||
Vector2 barrelPos;
|
||||
|
||||
private string particles;
|
||||
|
||||
float structureFixAmount, limbFixAmount;
|
||||
|
||||
[HasDefaultValue(0.0f, false)]
|
||||
@@ -42,6 +44,13 @@ namespace Subsurface.Items.Components
|
||||
set { limbFixAmount = value; }
|
||||
}
|
||||
|
||||
[HasDefaultValue("", false)]
|
||||
public string Particles
|
||||
{
|
||||
get { return particles; }
|
||||
set { particles = value; }
|
||||
}
|
||||
|
||||
[HasDefaultValue("0.0,0.0", false)]
|
||||
public string BarrelPos
|
||||
{
|
||||
@@ -178,12 +187,17 @@ namespace Subsurface.Items.Components
|
||||
{
|
||||
if (!isActive) return;
|
||||
|
||||
Vector2 particleSpeed = new Vector2(
|
||||
(float)Math.Cos(item.body.Rotation),
|
||||
(float)Math.Sin(item.body.Rotation)) *item.body.Dir * 5.0f;
|
||||
//Vector2 particleSpeed = new Vector2(
|
||||
// (float)Math.Cos(item.body.Rotation),
|
||||
// (float)Math.Sin(item.body.Rotation)) *item.body.Dir * 0.1f;
|
||||
|
||||
Game1.ParticleManager.CreateParticle("weld", TransformedBarrelPos, particleSpeed);
|
||||
|
||||
if (!string.IsNullOrWhiteSpace(particles))
|
||||
{
|
||||
Game1.ParticleManager.CreateParticle(particles, TransformedBarrelPos,
|
||||
-item.body.Rotation + ((item.body.Dir>0.0f) ? 0.0f : MathHelper.Pi), 0.0f);
|
||||
}
|
||||
|
||||
//Vector2 startPos = ConvertUnits.ToDisplayUnits(item.body.Position);
|
||||
//Vector2 endPos = ConvertUnits.ToDisplayUnits(pickedPosition);
|
||||
//endPos = new Vector2(endPos.X + Game1.localRandom.Next(-2, 2), endPos.Y + Game1.localRandom.Next(-2, 2));
|
||||
|
||||
@@ -22,12 +22,16 @@ namespace Subsurface.Items.Components
|
||||
public float VolumeMultiplier;
|
||||
|
||||
public readonly float Range;
|
||||
|
||||
public readonly bool Loop;
|
||||
|
||||
public ItemSound(Sound sound, ActionType type, float range)
|
||||
public ItemSound(Sound sound, ActionType type, float range, bool loop = true)
|
||||
{
|
||||
this.Sound = sound;
|
||||
this.Type = type;
|
||||
this.Range = range;
|
||||
|
||||
this.Loop = loop;
|
||||
}
|
||||
}
|
||||
|
||||
@@ -47,6 +51,8 @@ namespace Subsurface.Items.Components
|
||||
protected bool canBePicked;
|
||||
protected bool canBeSelected;
|
||||
|
||||
public bool WasUsed;
|
||||
|
||||
public List<StatusEffect> statusEffects;
|
||||
|
||||
protected bool updated;
|
||||
@@ -59,6 +65,8 @@ namespace Subsurface.Items.Components
|
||||
|
||||
private GUIFrame guiFrame;
|
||||
|
||||
public ItemComponent Parent;
|
||||
|
||||
public readonly Dictionary<string, ObjectProperty> properties;
|
||||
public Dictionary<string, ObjectProperty> ObjectProperties
|
||||
{
|
||||
@@ -217,9 +225,6 @@ namespace Subsurface.Items.Components
|
||||
if (filePath=="") continue;
|
||||
if (!filePath.Contains("\\")) filePath = Path.GetDirectoryName(item.Prefab.ConfigFile)+"\\"+filePath;
|
||||
|
||||
//int index = item.Prefab.sounds.FindIndex(x => x.FilePath == filePath);
|
||||
|
||||
|
||||
ActionType type;
|
||||
|
||||
try
|
||||
@@ -240,6 +245,13 @@ namespace Subsurface.Items.Components
|
||||
itemSound.VolumeMultiplier = ToolBox.GetAttributeFloat(subElement, "volumemultiplier", 1.0f);
|
||||
sounds.Add(itemSound);
|
||||
break;
|
||||
default:
|
||||
ItemComponent ic = ItemComponent.Load(subElement, item, item.ConfigFile, false);
|
||||
if (ic == null) break;
|
||||
|
||||
ic.Parent = this;
|
||||
item.components.Add(ic);
|
||||
break;
|
||||
}
|
||||
|
||||
}
|
||||
@@ -247,34 +259,52 @@ namespace Subsurface.Items.Components
|
||||
|
||||
private ItemSound loopingSound;
|
||||
private int loopingSoundIndex;
|
||||
public void PlaySound(ActionType type, Vector2 position, bool loop=false)
|
||||
public void PlaySound(ActionType type, Vector2 position)
|
||||
{
|
||||
ItemSound itemSound = null;
|
||||
if (!loop || !Sounds.SoundManager.IsPlaying(loopingSoundIndex))
|
||||
if (!Sounds.SoundManager.IsPlaying(loopingSoundIndex))
|
||||
{
|
||||
List<ItemSound> matchingSounds = sounds.FindAll(x => x.Type == type);
|
||||
if (matchingSounds.Count == 0) return;
|
||||
|
||||
int index = Rand.Int(matchingSounds.Count);
|
||||
itemSound = matchingSounds[index];
|
||||
|
||||
|
||||
|
||||
if (loop) loopingSound = itemSound;
|
||||
}
|
||||
|
||||
|
||||
if (loop)
|
||||
|
||||
if (loopingSound!=null)
|
||||
{
|
||||
loopingSoundIndex = loopingSound.Sound.Loop(loopingSoundIndex, GetSoundVolume(loopingSound), position, loopingSound.Range);
|
||||
}
|
||||
else
|
||||
else if (itemSound!=null)
|
||||
{
|
||||
|
||||
itemSound.Sound.Play(GetSoundVolume(itemSound), itemSound.Range, position);
|
||||
if (itemSound.Loop)
|
||||
{
|
||||
loopingSound = itemSound;
|
||||
}
|
||||
else
|
||||
{
|
||||
itemSound.Sound.Play(GetSoundVolume(itemSound), itemSound.Range, position);
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
public void StopSounds(ActionType type)
|
||||
{
|
||||
if (loopingSoundIndex <= 0) return;
|
||||
|
||||
if (loopingSound == null) return;
|
||||
|
||||
if (loopingSound.Type != type) return;
|
||||
|
||||
if (Sounds.SoundManager.IsPlaying(loopingSoundIndex))
|
||||
{
|
||||
Sounds.SoundManager.Stop(loopingSoundIndex);
|
||||
loopingSound = null;
|
||||
loopingSoundIndex = -1;
|
||||
}
|
||||
}
|
||||
|
||||
private float GetSoundVolume(ItemSound sound)
|
||||
{
|
||||
if (sound.VolumeProperty == "") return 1.0f;
|
||||
@@ -326,13 +356,7 @@ namespace Subsurface.Items.Components
|
||||
//called when isActive is true and condition == 0.0f
|
||||
public virtual void UpdateBroken(float deltaTime, Camera cam)
|
||||
{
|
||||
if (loopingSoundIndex <= 0) return;
|
||||
|
||||
if (Sounds.SoundManager.IsPlaying(loopingSoundIndex))
|
||||
{
|
||||
Sounds.SoundManager.Stop(loopingSoundIndex);
|
||||
}
|
||||
|
||||
StopSounds(ActionType.OnActive);
|
||||
}
|
||||
|
||||
//called when the item is equipped and left mouse button is pressed
|
||||
@@ -565,30 +589,30 @@ namespace Subsurface.Items.Components
|
||||
|
||||
public virtual void OnMapLoaded() { }
|
||||
|
||||
public static ItemComponent Load(XElement element, Item item, string file)
|
||||
public static ItemComponent Load(XElement element, Item item, string file, bool errorMessages = true)
|
||||
{
|
||||
Type t;
|
||||
string type = element.Name.ToString().ToLower();
|
||||
try
|
||||
{
|
||||
// Get the type of a specified class.
|
||||
t = Type.GetType("Subsurface.Items.Components." + type + ", Subsurface", true, true);
|
||||
// Get the type of a specified class.
|
||||
t = Type.GetType("Subsurface.Items.Components." + type + ", Subsurface", false, true);
|
||||
if (t == null)
|
||||
{
|
||||
DebugConsole.ThrowError("Could not find the component ''" + type + "'' (" + file + ")");
|
||||
if (errorMessages) DebugConsole.ThrowError("Could not find the component ''" + type + "'' (" + file + ")");
|
||||
return null;
|
||||
}
|
||||
}
|
||||
catch (Exception e)
|
||||
{
|
||||
DebugConsole.ThrowError("Could not find the component ''" + type + "'' (" + file + ")", e);
|
||||
if (errorMessages) DebugConsole.ThrowError("Could not find the component ''" + type + "'' (" + file + ")", e);
|
||||
return null;
|
||||
}
|
||||
|
||||
ConstructorInfo constructor;
|
||||
try
|
||||
{
|
||||
if (t!=typeof(ItemComponent) && !t.IsSubclassOf(typeof(ItemComponent))) return null;
|
||||
if (t != typeof(ItemComponent) && !t.IsSubclassOf(typeof(ItemComponent))) return null;
|
||||
constructor = t.GetConstructor(new Type[] { typeof(Item), typeof(XElement) });
|
||||
if (constructor == null)
|
||||
{
|
||||
|
||||
@@ -136,27 +136,8 @@ namespace Subsurface.Items.Components
|
||||
|
||||
private bool OnProjectileCollision(Fixture f1, Fixture f2, Contact contact)
|
||||
{
|
||||
//doesn't collide with items
|
||||
//if (f2.Body.UserData is Item) return false;
|
||||
|
||||
if (ignoredBodies.Contains(f2.Body)) return false;
|
||||
|
||||
//Structure structure = f1.Body.UserData as Structure;
|
||||
//if (structure!=null && (structure.IsPlatform || structure.StairDirection != Direction.None)) return false;
|
||||
|
||||
//Vector2 force = f1.Body.LinearVelocity * f1.Body.Mass;
|
||||
//float forceLength = force.Length();
|
||||
|
||||
//if (forceLength > 20.0f)
|
||||
//{
|
||||
// force = force / forceLength * 20.0f;
|
||||
//}
|
||||
|
||||
//f2.Body.ApplyLinearImpulse(force);
|
||||
//f1.Body.ApplyLinearImpulse(-f1.Body.LinearVelocity * f1.Body.Mass);
|
||||
|
||||
//float damage = f1.Body.LinearVelocity.Length();
|
||||
|
||||
AttackResult attackResult = new AttackResult(0.0f, 0.0f);
|
||||
if (attack!=null)
|
||||
{
|
||||
@@ -195,6 +176,11 @@ namespace Subsurface.Items.Components
|
||||
if (Vector2.Dot(f1.Body.LinearVelocity, normal)<0 ) return StickToTarget(f2.Body, dir);
|
||||
}
|
||||
|
||||
foreach (Item contained in item.ContainedItems)
|
||||
{
|
||||
contained.Condition = 0.0f;
|
||||
}
|
||||
|
||||
return true;
|
||||
}
|
||||
|
||||
|
||||
@@ -22,6 +22,8 @@ namespace Subsurface.Items.Components
|
||||
|
||||
float lightBrightness;
|
||||
|
||||
private float flicker;
|
||||
|
||||
[Editable, HasDefaultValue(100.0f, true)]
|
||||
public float Range
|
||||
{
|
||||
@@ -31,6 +33,16 @@ namespace Subsurface.Items.Components
|
||||
range = MathHelper.Clamp(value, 0.0f, 2048.0f);
|
||||
}
|
||||
}
|
||||
|
||||
[HasDefaultValue(0.0f, false)]
|
||||
public float Flicker
|
||||
{
|
||||
get { return flicker; }
|
||||
set
|
||||
{
|
||||
flicker = MathHelper.Clamp(value, 0.0f, 1.0f);
|
||||
}
|
||||
}
|
||||
|
||||
[InGameEditable, HasDefaultValue("1.0,1.0,1.0,1.0", true)]
|
||||
public string LightColor
|
||||
@@ -61,7 +73,7 @@ namespace Subsurface.Items.Components
|
||||
string dir = Path.GetDirectoryName(item.Prefab.ConfigFile)+"\\";
|
||||
for (int i = 0; i<4; i++)
|
||||
{
|
||||
sparkSounds[i] = Sound.Load(dir+"zap"+(i+1)+".ogg");
|
||||
sparkSounds[i] = Sound.Load("Content/Items/Electricity/zap"+(i+1)+".ogg");
|
||||
}
|
||||
}
|
||||
|
||||
@@ -89,7 +101,7 @@ namespace Subsurface.Items.Components
|
||||
}
|
||||
|
||||
Pickable pickable = item.GetComponent<Pickable>();
|
||||
if (item.container!= null || (pickable!=null && pickable.Picker!=null))
|
||||
if (item.container!= null)
|
||||
{
|
||||
light.Color = Color.Transparent;
|
||||
return;
|
||||
@@ -114,7 +126,7 @@ namespace Subsurface.Items.Components
|
||||
lightBrightness = MathHelper.Lerp(lightBrightness, Math.Min(voltage, 1.0f), 0.1f);
|
||||
}
|
||||
|
||||
light.Color = lightColor * lightBrightness;
|
||||
light.Color = lightColor * lightBrightness * (1.0f-Rand.Range(0.0f,Flicker));
|
||||
|
||||
light.Range = range * (float)Math.Sqrt(lightBrightness);
|
||||
|
||||
|
||||
@@ -5,9 +5,21 @@ using System.Xml.Linq;
|
||||
|
||||
namespace Subsurface.Items.Components
|
||||
{
|
||||
class WearableSprite
|
||||
{
|
||||
public Sprite Sprite;
|
||||
public bool HideLimb;
|
||||
|
||||
public WearableSprite(Sprite sprite, bool hideLimb)
|
||||
{
|
||||
Sprite = sprite;
|
||||
HideLimb = hideLimb;
|
||||
}
|
||||
}
|
||||
|
||||
class Wearable : Pickable
|
||||
{
|
||||
Sprite[] sprite;
|
||||
WearableSprite[] wearableSprite;
|
||||
LimbType[] limbType;
|
||||
Limb[] limb;
|
||||
|
||||
@@ -18,7 +30,7 @@ namespace Subsurface.Items.Components
|
||||
|
||||
var sprites = element.Elements().Where(x => x.Name.ToString() == "sprite").ToList();
|
||||
int spriteCount = sprites.Count();
|
||||
sprite = new Sprite[spriteCount];
|
||||
wearableSprite = new WearableSprite[spriteCount];
|
||||
limbType = new LimbType[spriteCount];
|
||||
limb = new Limb[spriteCount];
|
||||
|
||||
@@ -40,7 +52,8 @@ namespace Subsurface.Items.Components
|
||||
string spritePath = subElement.Attribute("texture").Value;
|
||||
spritePath = Path.GetDirectoryName( item.Prefab.ConfigFile)+"\\"+spritePath;
|
||||
|
||||
sprite[i] = new Sprite(subElement, "", spritePath);
|
||||
var sprite = new Sprite(subElement, "", spritePath);
|
||||
wearableSprite[i] = new WearableSprite(sprite, ToolBox.GetAttributeBool(subElement, "hidelimb", false));
|
||||
//sprite[i].origin = new Vector2(sourceRect.Width / 2.0f, sourceRect.Height / 2.0f);
|
||||
|
||||
limbType[i] = (LimbType)Enum.Parse(typeof(LimbType),
|
||||
@@ -53,7 +66,7 @@ namespace Subsurface.Items.Components
|
||||
public override void Equip(Character character)
|
||||
{
|
||||
picker = character;
|
||||
for (int i = 0; i < sprite.Length; i++ )
|
||||
for (int i = 0; i < wearableSprite.Length; i++ )
|
||||
{
|
||||
Limb equipLimb = character.AnimController.GetLimb(limbType[i]);
|
||||
if (equipLimb == null) continue;
|
||||
@@ -64,7 +77,7 @@ namespace Subsurface.Items.Components
|
||||
equipLimb.WearingItem.Unequip(character);
|
||||
}
|
||||
|
||||
sprite[i].Depth = equipLimb.sprite.Depth - 0.001f;
|
||||
//sprite[i].Depth = equipLimb.sprite.Depth - 0.001f;
|
||||
|
||||
item.body.Enabled = false;
|
||||
|
||||
@@ -72,7 +85,7 @@ namespace Subsurface.Items.Components
|
||||
|
||||
limb[i] = equipLimb;
|
||||
equipLimb.WearingItem = item;
|
||||
equipLimb.WearingItemSprite = sprite[i];
|
||||
equipLimb.WearingItemSprite = wearableSprite[i];
|
||||
}
|
||||
}
|
||||
|
||||
@@ -89,7 +102,7 @@ namespace Subsurface.Items.Components
|
||||
public override void Unequip(Character character)
|
||||
{
|
||||
if (picker == null) return;
|
||||
for (int i = 0; i < sprite.Length; i++)
|
||||
for (int i = 0; i < wearableSprite.Length; i++)
|
||||
{
|
||||
Limb equipLimb = character.AnimController.GetLimb(limbType[i]);
|
||||
if (equipLimb == null) continue;
|
||||
|
||||
Reference in New Issue
Block a user