(ffa3ddbca) Implemented changing mineral sprites when attached to a wall
This commit is contained in:
@@ -101,9 +101,22 @@ namespace Barotrauma
|
|||||||
return color;
|
return color;
|
||||||
}
|
}
|
||||||
|
|
||||||
partial void SetActiveSprite()
|
partial void SetActiveSpriteProjSpecific()
|
||||||
{
|
{
|
||||||
activeSprite = prefab.sprite;
|
activeSprite = prefab.sprite;
|
||||||
|
Holdable holdable = GetComponent<Holdable>();
|
||||||
|
if (holdable != null && holdable.Attached)
|
||||||
|
{
|
||||||
|
foreach (ContainedItemSprite containedSprite in Prefab.ContainedSprites)
|
||||||
|
{
|
||||||
|
if (containedSprite.UseWhenAttached)
|
||||||
|
{
|
||||||
|
activeSprite = containedSprite.Sprite;
|
||||||
|
return;
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
if (Container != null)
|
if (Container != null)
|
||||||
{
|
{
|
||||||
foreach (ContainedItemSprite containedSprite in Prefab.ContainedSprites)
|
foreach (ContainedItemSprite containedSprite in Prefab.ContainedSprites)
|
||||||
@@ -173,8 +186,7 @@ namespace Barotrauma
|
|||||||
|
|
||||||
Color color = isHighlighted && !GUI.DisableItemHighlights && Screen.Selected != GameMain.GameScreen ? Color.Orange : GetSpriteColor();
|
Color color = isHighlighted && !GUI.DisableItemHighlights && Screen.Selected != GameMain.GameScreen ? Color.Orange : GetSpriteColor();
|
||||||
//if (IsSelected && editing) color = Color.Lerp(color, Color.Gold, 0.5f);
|
//if (IsSelected && editing) color = Color.Lerp(color, Color.Gold, 0.5f);
|
||||||
|
|
||||||
Sprite activeSprite = prefab.sprite;
|
|
||||||
BrokenItemSprite fadeInBrokenSprite = null;
|
BrokenItemSprite fadeInBrokenSprite = null;
|
||||||
float fadeInBrokenSpriteAlpha = 0.0f;
|
float fadeInBrokenSpriteAlpha = 0.0f;
|
||||||
if (condition < Prefab.Health)
|
if (condition < Prefab.Health)
|
||||||
@@ -783,7 +795,7 @@ namespace Barotrauma
|
|||||||
{
|
{
|
||||||
if (!ic.CanBeSelected) { continue; }
|
if (!ic.CanBeSelected) { continue; }
|
||||||
|
|
||||||
bool useAlternativeLayout = activeHUDs.Count > 1;
|
bool useAlternativeLayout = ic.Item != this;
|
||||||
bool wasUsingAlternativeLayout = ic.UseAlternativeLayout;
|
bool wasUsingAlternativeLayout = ic.UseAlternativeLayout;
|
||||||
ic.UseAlternativeLayout = useAlternativeLayout;
|
ic.UseAlternativeLayout = useAlternativeLayout;
|
||||||
needsLayoutUpdate |= ic.UseAlternativeLayout != wasUsingAlternativeLayout;
|
needsLayoutUpdate |= ic.UseAlternativeLayout != wasUsingAlternativeLayout;
|
||||||
|
|||||||
@@ -25,12 +25,14 @@ namespace Barotrauma
|
|||||||
class ContainedItemSprite
|
class ContainedItemSprite
|
||||||
{
|
{
|
||||||
public readonly Sprite Sprite;
|
public readonly Sprite Sprite;
|
||||||
|
public readonly bool UseWhenAttached;
|
||||||
public readonly string[] AllowedContainerIdentifiers;
|
public readonly string[] AllowedContainerIdentifiers;
|
||||||
public readonly string[] AllowedContainerTags;
|
public readonly string[] AllowedContainerTags;
|
||||||
|
|
||||||
public ContainedItemSprite(XElement element, string path = "", bool lazyLoad = false)
|
public ContainedItemSprite(XElement element, string path = "", bool lazyLoad = false)
|
||||||
{
|
{
|
||||||
Sprite = new Sprite(element, path, lazyLoad: lazyLoad);
|
Sprite = new Sprite(element, path, lazyLoad: lazyLoad);
|
||||||
|
UseWhenAttached = element.GetAttributeBool("usewhenattached", false);
|
||||||
AllowedContainerIdentifiers = element.GetAttributeStringArray("allowedcontaineridentifiers", new string[0], convertToLowerInvariant: true);
|
AllowedContainerIdentifiers = element.GetAttributeStringArray("allowedcontaineridentifiers", new string[0], convertToLowerInvariant: true);
|
||||||
AllowedContainerTags = element.GetAttributeStringArray("allowedcontainertags", new string[0], convertToLowerInvariant: true);
|
AllowedContainerTags = element.GetAttributeStringArray("allowedcontainertags", new string[0], convertToLowerInvariant: true);
|
||||||
}
|
}
|
||||||
|
|||||||
@@ -44,7 +44,18 @@ namespace Barotrauma.Items.Components
|
|||||||
public bool Attached
|
public bool Attached
|
||||||
{
|
{
|
||||||
get { return attached && item.ParentInventory == null; }
|
get { return attached && item.ParentInventory == null; }
|
||||||
set { attached = value; }
|
set
|
||||||
|
{
|
||||||
|
attached = value;
|
||||||
|
item.SetActiveSprite();
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
[Serialize(true, true)]
|
||||||
|
public bool Aimable
|
||||||
|
{
|
||||||
|
get;
|
||||||
|
set;
|
||||||
}
|
}
|
||||||
|
|
||||||
[Serialize(true, true)]
|
[Serialize(true, true)]
|
||||||
@@ -167,7 +178,7 @@ namespace Barotrauma.Items.Components
|
|||||||
if (item.Submarine.Loading)
|
if (item.Submarine.Loading)
|
||||||
{
|
{
|
||||||
AttachToWall();
|
AttachToWall();
|
||||||
attached = false;
|
Attached = false;
|
||||||
}
|
}
|
||||||
else //the submarine is not being loaded, which means we're either in the sub editor or the item has been spawned mid-round
|
else //the submarine is not being loaded, which means we're either in the sub editor or the item has been spawned mid-round
|
||||||
{
|
{
|
||||||
@@ -409,14 +420,14 @@ namespace Barotrauma.Items.Components
|
|||||||
PickKey = prevPickKey;
|
PickKey = prevPickKey;
|
||||||
requiredItems = new Dictionary<RelatedItem.RelationType, List<RelatedItem>>(prevRequiredItems);
|
requiredItems = new Dictionary<RelatedItem.RelationType, List<RelatedItem>>(prevRequiredItems);
|
||||||
|
|
||||||
attached = true;
|
Attached = true;
|
||||||
}
|
}
|
||||||
|
|
||||||
public void DeattachFromWall()
|
public void DeattachFromWall()
|
||||||
{
|
{
|
||||||
if (!attachable) return;
|
if (!attachable) return;
|
||||||
|
|
||||||
attached = false;
|
Attached = false;
|
||||||
|
|
||||||
//make the item pickable with the default pick key and with no specific tools/items when it's deattached
|
//make the item pickable with the default pick key and with no specific tools/items when it's deattached
|
||||||
requiredItems.Clear();
|
requiredItems.Clear();
|
||||||
@@ -529,6 +540,7 @@ namespace Barotrauma.Items.Components
|
|||||||
{
|
{
|
||||||
if (item.Submarine != null && item.Submarine.Loading) return;
|
if (item.Submarine != null && item.Submarine.Loading) return;
|
||||||
OnMapLoaded();
|
OnMapLoaded();
|
||||||
|
item.SetActiveSprite();
|
||||||
}
|
}
|
||||||
|
|
||||||
public override void OnMapLoaded()
|
public override void OnMapLoaded()
|
||||||
|
|||||||
@@ -11,6 +11,12 @@ namespace Barotrauma.Items.Components
|
|||||||
{
|
{
|
||||||
private float lastSentDeattachTimer;
|
private float lastSentDeattachTimer;
|
||||||
|
|
||||||
|
private PhysicsBody trigger;
|
||||||
|
|
||||||
|
private Holdable holdable;
|
||||||
|
|
||||||
|
private float deattachTimer;
|
||||||
|
|
||||||
[Serialize(1.0f, false)]
|
[Serialize(1.0f, false)]
|
||||||
public float DeattachDuration
|
public float DeattachDuration
|
||||||
{
|
{
|
||||||
@@ -49,13 +55,7 @@ namespace Barotrauma.Items.Components
|
|||||||
#endif
|
#endif
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
private PhysicsBody trigger;
|
|
||||||
|
|
||||||
private Holdable holdable;
|
|
||||||
|
|
||||||
private float deattachTimer;
|
|
||||||
|
|
||||||
public LevelResource(Item item, XElement element) : base(item, element)
|
public LevelResource(Item item, XElement element) : base(item, element)
|
||||||
{
|
{
|
||||||
IsActive = true;
|
IsActive = true;
|
||||||
|
|||||||
@@ -801,7 +801,12 @@ namespace Barotrauma
|
|||||||
if (findNewHull) FindHull();
|
if (findNewHull) FindHull();
|
||||||
}
|
}
|
||||||
|
|
||||||
partial void SetActiveSprite();
|
public void SetActiveSprite()
|
||||||
|
{
|
||||||
|
SetActiveSpriteProjSpecific();
|
||||||
|
}
|
||||||
|
|
||||||
|
partial void SetActiveSpriteProjSpecific();
|
||||||
|
|
||||||
public override void Move(Vector2 amount)
|
public override void Move(Vector2 amount)
|
||||||
{
|
{
|
||||||
|
|||||||
Reference in New Issue
Block a user