Inventory sprite rotation (#22201)
This commit is contained in:
@@ -78,7 +78,7 @@ public sealed class ItemGridPiece : Control
|
|||||||
base.Draw(handle);
|
base.Draw(handle);
|
||||||
|
|
||||||
// really just an "oh shit" catch.
|
// really just an "oh shit" catch.
|
||||||
if (!_entityManager.EntityExists(Entity))
|
if (!_entityManager.EntityExists(Entity) || !_entityManager.TryGetComponent<ItemComponent>(Entity, out var itemComponent))
|
||||||
{
|
{
|
||||||
Dispose();
|
Dispose();
|
||||||
return;
|
return;
|
||||||
@@ -87,7 +87,7 @@ public sealed class ItemGridPiece : Control
|
|||||||
if (_storageController.IsDragging && _storageController.CurrentlyDragging == this)
|
if (_storageController.IsDragging && _storageController.CurrentlyDragging == this)
|
||||||
return;
|
return;
|
||||||
|
|
||||||
var adjustedShape = _entityManager.System<ItemSystem>().GetAdjustedItemShape((Entity, null), Location.Rotation, Vector2i.Zero);
|
var adjustedShape = _entityManager.System<ItemSystem>().GetAdjustedItemShape((Entity, itemComponent), Location.Rotation, Vector2i.Zero);
|
||||||
var boundingGrid = adjustedShape.GetBoundingBox();
|
var boundingGrid = adjustedShape.GetBoundingBox();
|
||||||
var size = _centerTexture!.Size * 2 * UIScale;
|
var size = _centerTexture!.Size * 2 * UIScale;
|
||||||
|
|
||||||
@@ -130,16 +130,38 @@ public sealed class ItemGridPiece : Control
|
|||||||
}
|
}
|
||||||
|
|
||||||
// typically you'd divide by two, but since the textures are half a tile, this is done implicitly
|
// typically you'd divide by two, but since the textures are half a tile, this is done implicitly
|
||||||
var iconOffset = new Vector2((boundingGrid.Width + 1) * size.X ,
|
var iconPosition = new Vector2((boundingGrid.Width + 1) * size.X ,
|
||||||
(boundingGrid.Height + 1) * size.Y);
|
(boundingGrid.Height + 1) * size.Y);
|
||||||
|
var iconRotation = Location.Rotation + Angle.FromDegrees(itemComponent.StoredRotation);
|
||||||
|
|
||||||
|
if (itemComponent.StoredSprite is { } storageSprite)
|
||||||
|
{
|
||||||
|
var scale = 2 * UIScale;
|
||||||
|
var offset = (((Box2) boundingGrid).Size - Vector2.One) * size;
|
||||||
|
var sprite = _entityManager.System<SpriteSystem>().Frame0(storageSprite);
|
||||||
|
|
||||||
|
var spriteBox = new Box2Rotated(new Box2(0f, sprite.Height * scale, sprite.Width * scale, 0f), -iconRotation, Vector2.Zero);
|
||||||
|
var root = spriteBox.CalcBoundingBox().BottomLeft;
|
||||||
|
var pos = PixelPosition * 2
|
||||||
|
+ (Parent?.GlobalPixelPosition ?? Vector2.Zero)
|
||||||
|
+ offset;
|
||||||
|
|
||||||
|
handle.SetTransform(pos, iconRotation);
|
||||||
|
var box = new UIBox2(root, root + sprite.Size * scale);
|
||||||
|
handle.DrawTextureRect(sprite, box);
|
||||||
|
handle.SetTransform(Matrix3.Identity);
|
||||||
|
}
|
||||||
|
else
|
||||||
|
{
|
||||||
_entityManager.System<SpriteSystem>().ForceUpdate(Entity);
|
_entityManager.System<SpriteSystem>().ForceUpdate(Entity);
|
||||||
handle.DrawEntity(Entity,
|
handle.DrawEntity(Entity,
|
||||||
PixelPosition + iconOffset,
|
PixelPosition + iconPosition,
|
||||||
Vector2.One * 2 * UIScale,
|
Vector2.One * 2 * UIScale,
|
||||||
Angle.Zero,
|
Angle.Zero,
|
||||||
|
eyeRotation: iconRotation,
|
||||||
overrideDirection: Direction.South);
|
overrideDirection: Direction.South);
|
||||||
}
|
}
|
||||||
|
}
|
||||||
|
|
||||||
protected override bool HasPoint(Vector2 point)
|
protected override bool HasPoint(Vector2 point)
|
||||||
{
|
{
|
||||||
|
|||||||
@@ -2,6 +2,7 @@ using Content.Shared.Hands.Components;
|
|||||||
using Robust.Shared.GameStates;
|
using Robust.Shared.GameStates;
|
||||||
using Robust.Shared.Prototypes;
|
using Robust.Shared.Prototypes;
|
||||||
using Robust.Shared.Serialization;
|
using Robust.Shared.Serialization;
|
||||||
|
using Robust.Shared.Utility;
|
||||||
|
|
||||||
namespace Content.Shared.Item;
|
namespace Content.Shared.Item;
|
||||||
|
|
||||||
@@ -41,6 +42,18 @@ public sealed partial class ItemComponent : Component
|
|||||||
/// </summary>
|
/// </summary>
|
||||||
[DataField, AutoNetworkedField]
|
[DataField, AutoNetworkedField]
|
||||||
public List<Box2i>? Shape;
|
public List<Box2i>? Shape;
|
||||||
|
|
||||||
|
/// <summary>
|
||||||
|
/// A sprite used to depict this entity specifically when it is displayed in the storage UI.
|
||||||
|
/// </summary>
|
||||||
|
[DataField, AutoNetworkedField]
|
||||||
|
public SpriteSpecifier? StoredSprite;
|
||||||
|
|
||||||
|
/// <summary>
|
||||||
|
/// An additional angle offset, in degrees, applied to the visual depiction of the item when displayed in the storage UI.
|
||||||
|
/// </summary>
|
||||||
|
[DataField, AutoNetworkedField]
|
||||||
|
public float StoredRotation = 0;
|
||||||
}
|
}
|
||||||
|
|
||||||
[Serializable, NetSerializable]
|
[Serializable, NetSerializable]
|
||||||
|
|||||||
@@ -37,6 +37,7 @@
|
|||||||
cutters: Rainbow
|
cutters: Rainbow
|
||||||
- type: Item
|
- type: Item
|
||||||
sprite: Objects/Tools/wirecutters.rsi
|
sprite: Objects/Tools/wirecutters.rsi
|
||||||
|
storedRotation: -90
|
||||||
- type: LatticeCutting
|
- type: LatticeCutting
|
||||||
- type: PhysicalComposition
|
- type: PhysicalComposition
|
||||||
materialComposition:
|
materialComposition:
|
||||||
@@ -64,6 +65,7 @@
|
|||||||
- state: screwdriver-screwybits
|
- state: screwdriver-screwybits
|
||||||
- type: Item
|
- type: Item
|
||||||
sprite: Objects/Tools/screwdriver.rsi
|
sprite: Objects/Tools/screwdriver.rsi
|
||||||
|
storedRotation: -90
|
||||||
- type: ItemCooldown
|
- type: ItemCooldown
|
||||||
- type: MeleeWeapon
|
- type: MeleeWeapon
|
||||||
wideAnimationRotation: -90
|
wideAnimationRotation: -90
|
||||||
@@ -105,6 +107,9 @@
|
|||||||
state: icon
|
state: icon
|
||||||
- type: Item
|
- type: Item
|
||||||
sprite: Objects/Tools/wrench.rsi
|
sprite: Objects/Tools/wrench.rsi
|
||||||
|
storedSprite:
|
||||||
|
sprite: Objects/Tools/wrench.rsi
|
||||||
|
state: storage
|
||||||
- type: ItemCooldown
|
- type: ItemCooldown
|
||||||
- type: MeleeWeapon
|
- type: MeleeWeapon
|
||||||
wideAnimationRotation: 135
|
wideAnimationRotation: 135
|
||||||
@@ -141,6 +146,9 @@
|
|||||||
- type: Item
|
- type: Item
|
||||||
sprite: Objects/Tools/crowbar.rsi
|
sprite: Objects/Tools/crowbar.rsi
|
||||||
size: Small
|
size: Small
|
||||||
|
storedSprite:
|
||||||
|
sprite: Objects/Tools/crowbar.rsi
|
||||||
|
state: storage
|
||||||
- type: ItemCooldown
|
- type: ItemCooldown
|
||||||
- type: MeleeWeapon
|
- type: MeleeWeapon
|
||||||
wideAnimationRotation: -135
|
wideAnimationRotation: -135
|
||||||
@@ -174,6 +182,9 @@
|
|||||||
state: red-icon
|
state: red-icon
|
||||||
- type: Item
|
- type: Item
|
||||||
heldPrefix: red
|
heldPrefix: red
|
||||||
|
storedSprite:
|
||||||
|
sprite: Objects/Tools/crowbar.rsi
|
||||||
|
state: red-storage
|
||||||
|
|
||||||
- type: entity
|
- type: entity
|
||||||
name: multitool
|
name: multitool
|
||||||
|
|||||||
@@ -1,7 +1,7 @@
|
|||||||
{
|
{
|
||||||
"version": 1,
|
"version": 1,
|
||||||
"license": "CC-BY-SA-3.0",
|
"license": "CC-BY-SA-3.0",
|
||||||
"copyright": "Taken from tgstation at https://github.com/tgstation/tgstation/commit/eea0599511b088fdab9d43e562210cdbd51c6a98",
|
"copyright": "Taken from tgstation at https://github.com/tgstation/tgstation/commit/eea0599511b088fdab9d43e562210cdbd51c6a98, storage and red-storage by Flareguy",
|
||||||
"size": {
|
"size": {
|
||||||
"x": 32,
|
"x": 32,
|
||||||
"y": 32
|
"y": 32
|
||||||
@@ -36,6 +36,12 @@
|
|||||||
{
|
{
|
||||||
"name": "red-equipped-BELT",
|
"name": "red-equipped-BELT",
|
||||||
"directions": 4
|
"directions": 4
|
||||||
|
},
|
||||||
|
{
|
||||||
|
"name": "storage"
|
||||||
|
},
|
||||||
|
{
|
||||||
|
"name": "red-storage"
|
||||||
}
|
}
|
||||||
]
|
]
|
||||||
}
|
}
|
||||||
|
|||||||
BIN
Resources/Textures/Objects/Tools/crowbar.rsi/red-storage.png
Normal file
BIN
Resources/Textures/Objects/Tools/crowbar.rsi/red-storage.png
Normal file
Binary file not shown.
|
After Width: | Height: | Size: 371 B |
BIN
Resources/Textures/Objects/Tools/crowbar.rsi/storage.png
Normal file
BIN
Resources/Textures/Objects/Tools/crowbar.rsi/storage.png
Normal file
Binary file not shown.
|
After Width: | Height: | Size: 334 B |
@@ -1,7 +1,7 @@
|
|||||||
{
|
{
|
||||||
"version": 1,
|
"version": 1,
|
||||||
"license": "CC-BY-SA-3.0",
|
"license": "CC-BY-SA-3.0",
|
||||||
"copyright": "Taken from vgstation at commit https://github.com/vgstation-coders/vgstation13/commit/1cdfb0230cc96d0ba751fa002d04f8aa2f25ad7d",
|
"copyright": "Taken from vgstation at commit https://github.com/vgstation-coders/vgstation13/commit/1cdfb0230cc96d0ba751fa002d04f8aa2f25ad7d, storage by EmoGarbage404 (github)",
|
||||||
"size": {
|
"size": {
|
||||||
"x": 32,
|
"x": 32,
|
||||||
"y": 32
|
"y": 32
|
||||||
@@ -21,6 +21,9 @@
|
|||||||
{
|
{
|
||||||
"name": "equipped-BELT",
|
"name": "equipped-BELT",
|
||||||
"directions": 4
|
"directions": 4
|
||||||
|
},
|
||||||
|
{
|
||||||
|
"name": "storage"
|
||||||
}
|
}
|
||||||
]
|
]
|
||||||
}
|
}
|
||||||
|
|||||||
BIN
Resources/Textures/Objects/Tools/wrench.rsi/storage.png
Normal file
BIN
Resources/Textures/Objects/Tools/wrench.rsi/storage.png
Normal file
Binary file not shown.
|
After Width: | Height: | Size: 408 B |
Reference in New Issue
Block a user