38f1ddb...178a853: v0.8.9.1, removed content folder

This commit is contained in:
Joonas Rikkonen
2019-03-18 19:46:58 +02:00
parent 38f1ddb6fe
commit 6c0679c297
1054 changed files with 151673 additions and 144931 deletions
@@ -4,34 +4,155 @@ using System.Collections.Generic;
using System.IO;
using System.Linq;
using System.Xml.Linq;
using Barotrauma.Items.Components;
namespace Barotrauma
{
public enum WearableType
{
Item,
Hair,
Beard,
Moustache,
FaceAttachment,
JobIndicator
}
class WearableSprite
{
public string SpritePath { get; private set; }
public XElement SourceElement { get; private set; }
public WearableType Type { get; private set; }
private Sprite _sprite;
public Sprite Sprite
{
get { return _sprite; }
set
{
if (value == _sprite) { return; }
if (_sprite != null)
{
_sprite.Remove();
}
_sprite = value;
}
}
public LimbType Limb { get; private set; }
public bool HideLimb { get; private set; }
public bool HideOtherWearables { get; private set; }
public bool InheritLimbDepth { get; private set; }
public bool InheritTextureScale { get; private set; }
public bool InheritOrigin { get; private set; }
public bool InheritSourceRect { get; private set; }
public LimbType DepthLimb { get; private set; }
private Wearable _wearableComponent;
public Wearable WearableComponent
{
get { return _wearableComponent; }
set
{
if (value == _wearableComponent) { return; }
if (_wearableComponent != null)
{
_wearableComponent.Remove();
}
_wearableComponent = value;
}
}
public string Sound { get; private set; }
public Point? SheetIndex { get; private set; }
public LightComponent LightComponent { get; set; }
private Gender _gender;
/// <summary>
/// None = Any/Not Defined -> no effect.
/// Changing the gender forces re-initialization, because the textures can be different for male and female characters.
/// </summary>
public Gender Gender
{
get { return _gender; }
set
{
if (value == _gender) { return; }
_gender = value;
IsInitialized = false;
Init(_gender);
}
}
public WearableSprite(XElement subElement, WearableType type)
{
Type = type;
SourceElement = subElement;
SpritePath = subElement.Attribute("texture").Value;
Init();
switch (type)
{
case WearableType.Hair:
case WearableType.Beard:
case WearableType.Moustache:
case WearableType.FaceAttachment:
case WearableType.JobIndicator:
Limb = LimbType.Head;
HideLimb = false;
HideOtherWearables = false;
InheritLimbDepth = true;
InheritTextureScale = true;
InheritOrigin = true;
InheritSourceRect = true;
break;
}
}
/// <summary>
/// Note: this constructor cannot initialize automatically, because the gender is unknown at this point. We only know it when the item is equipped.
/// </summary>
public WearableSprite(XElement subElement, Wearable item)
{
Type = WearableType.Item;
WearableComponent = item;
string texturePath = subElement.GetAttributeString("texture", string.Empty);
SpritePath = texturePath.Contains("/") ? texturePath : $"{Path.GetDirectoryName(item.Item.Prefab.ConfigFile)}/{texturePath}";
SourceElement = subElement;
}
public bool IsInitialized { get; private set; }
public void Init(Gender gender = Gender.None)
{
if (IsInitialized) { return; }
_gender = SpritePath.Contains("[GENDER]") ? gender : Gender.None;
if (_gender != Gender.None)
{
SpritePath = SpritePath.Replace("[GENDER]", (_gender == Gender.Female) ? "female" : "male");
}
if (Sprite != null)
{
Sprite.Remove();
}
Sprite = new Sprite(SourceElement, "", SpritePath);
Limb = (LimbType)Enum.Parse(typeof(LimbType), SourceElement.GetAttributeString("limb", "Head"), true);
HideLimb = SourceElement.GetAttributeBool("hidelimb", false);
HideOtherWearables = SourceElement.GetAttributeBool("hideotherwearables", false);
InheritLimbDepth = SourceElement.GetAttributeBool("inheritlimbdepth", true);
InheritTextureScale = SourceElement.GetAttributeBool("inherittexturescale", false);
InheritOrigin = SourceElement.GetAttributeBool("inheritorigin", false);
InheritSourceRect = SourceElement.GetAttributeBool("inheritsourcerect", false);
DepthLimb = (LimbType)Enum.Parse(typeof(LimbType), SourceElement.GetAttributeString("depthlimb", "None"), true);
Sound = SourceElement.GetAttributeString("sound", "");
var index = SourceElement.GetAttributePoint("sheetindex", new Point(-1, -1));
if (index.X > -1 && index.Y > -1)
{
SheetIndex = index;
}
IsInitialized = true;
}
}
}
namespace Barotrauma.Items.Components
{
class WearableSprite
{
public readonly Sprite Sprite;
public readonly LimbType Limb;
public readonly bool HideLimb;
public readonly bool InheritLimbDepth;
public readonly LimbType DepthLimb;
public LightComponent LightComponent;
public readonly Wearable WearableComponent;
public readonly string Sound;
public WearableSprite(Wearable item, Sprite sprite, LimbType limb, bool hideLimb, bool inheritLimbDepth = true, LimbType depthLimb = LimbType.None, string sound = null)
{
WearableComponent = item;
Sprite = sprite;
Limb = limb;
HideLimb = hideLimb;
InheritLimbDepth = inheritLimbDepth;
DepthLimb = depthLimb;
Sound = sound;
}
}
class Wearable : Pickable
{
private WearableSprite[] wearableSprites;
@@ -45,8 +166,7 @@ namespace Barotrauma.Items.Components
get { return damageModifiers; }
}
public Wearable (Item item, XElement element)
: base(item, element)
public Wearable (Item item, XElement element) : base(item, element)
{
this.item = item;
@@ -69,18 +189,10 @@ namespace Barotrauma.Items.Components
return;
}
string spritePath = subElement.Attribute("texture").Value;
spritePath = Path.GetDirectoryName(item.Prefab.ConfigFile) + "/" + spritePath;
var sound = subElement.GetAttributeString("sound", "");
var sprite = new Sprite(subElement, "", spritePath);
limbType[i] = (LimbType)Enum.Parse(typeof(LimbType),
subElement.GetAttributeString("limb", "Head"), true);
wearableSprites[i] = new WearableSprite(this, sprite, limbType[i],
subElement.GetAttributeBool("hidelimb", false),
subElement.GetAttributeBool("inheritlimbdepth", true),
(LimbType)Enum.Parse(typeof(LimbType), subElement.GetAttributeString("depthlimb", "None"), true), sound);
wearableSprites[i] = new WearableSprite(subElement, this);
foreach (XElement lightElement in subElement.Elements())
{
@@ -93,7 +205,7 @@ namespace Barotrauma.Items.Components
i++;
break;
case "damagemodifier":
damageModifiers.Add(new DamageModifier(subElement));
damageModifiers.Add(new DamageModifier(subElement, item.Name + ", Wearable"));
break;
}
}
@@ -104,20 +216,28 @@ namespace Barotrauma.Items.Components
picker = character;
for (int i = 0; i < wearableSprites.Length; i++ )
{
var wearableSprite = wearableSprites[i];
if (!wearableSprite.IsInitialized) { wearableSprite.Init(picker.Info?.Gender ?? Gender.None); }
if (picker.Info?.Gender != Gender.None && (wearableSprite.Gender != Gender.None))
{
// If the item is gender specific (it has a different textures for male and female), we have to change the gender here so that the texture is updated.
wearableSprite.Gender = picker.Info.Gender;
}
Limb equipLimb = character.AnimController.GetLimb(limbType[i]);
if (equipLimb == null) continue;
item.body.Enabled = false;
IsActive = true;
if (wearableSprites[i].LightComponent != null)
if (wearableSprite.LightComponent != null)
{
wearableSprites[i].LightComponent.ParentBody = equipLimb.body;
wearableSprite.LightComponent.ParentBody = equipLimb.body;
}
limb[i] = equipLimb;
if (!equipLimb.WearingItems.Contains(wearableSprites[i]))
if (!equipLimb.WearingItems.Contains(wearableSprite))
{
equipLimb.WearingItems.Add(wearableSprites[i]);
equipLimb.WearingItems.Add(wearableSprite);
}
}
}
@@ -160,13 +280,19 @@ namespace Barotrauma.Items.Components
public override void Update(float deltaTime, Camera cam)
{
if (picker.Removed)
{
IsActive = false;
return;
}
item.SetTransform(picker.SimPosition, 0.0f);
item.SetContainedItemPositions();
item.ApplyStatusEffects(ActionType.OnWearing, deltaTime, picker);
#if CLIENT
PlaySound(ActionType.OnWearing, picker.WorldPosition);
PlaySound(ActionType.OnWearing, picker.WorldPosition, picker);
#endif
}