storedOffset bugfix (#33606)
* Update ItemGridPiece.cs * Update SharedItemSystem.cs * Update ItemGridPiece.cs * EmoGarbage Review --------- Co-authored-by: EmoGarbage404 <retron404@gmail.com>
This commit is contained in:
@@ -163,14 +163,16 @@ public sealed class ItemGridPiece : Control, IEntityControl
|
|||||||
}
|
}
|
||||||
|
|
||||||
// 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 iconPosition = new Vector2((boundingGrid.Width + 1) * size.X + itemComponent.StoredOffset.X * 2,
|
var iconOffset = Location.Rotation.RotateVec(itemComponent.StoredOffset) * 2 * UIScale;
|
||||||
(boundingGrid.Height + 1) * size.Y + itemComponent.StoredOffset.Y * 2);
|
var iconPosition = new Vector2(
|
||||||
|
(boundingGrid.Width + 1) * size.X + iconOffset.X,
|
||||||
|
(boundingGrid.Height + 1) * size.Y + iconOffset.Y);
|
||||||
var iconRotation = Location.Rotation + Angle.FromDegrees(itemComponent.StoredRotation);
|
var iconRotation = Location.Rotation + Angle.FromDegrees(itemComponent.StoredRotation);
|
||||||
|
|
||||||
if (itemComponent.StoredSprite is { } storageSprite)
|
if (itemComponent.StoredSprite is { } storageSprite)
|
||||||
{
|
{
|
||||||
var scale = 2 * UIScale;
|
var scale = 2 * UIScale;
|
||||||
var offset = (((Box2) boundingGrid).Size - Vector2.One) * size;
|
var offset = (((Box2) boundingGrid).Size - Vector2.One) * size + iconOffset;
|
||||||
var sprite = _entityManager.System<SpriteSystem>().Frame0(storageSprite);
|
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 spriteBox = new Box2Rotated(new Box2(0f, sprite.Height * scale, sprite.Width * scale, 0f), -iconRotation, Vector2.Zero);
|
||||||
|
|||||||
@@ -55,6 +55,20 @@ public abstract class SharedItemSystem : EntitySystem
|
|||||||
Dirty(uid, component);
|
Dirty(uid, component);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
/// <summary>
|
||||||
|
/// Sets the offset used for the item's sprite inside the storage UI.
|
||||||
|
/// Dirties.
|
||||||
|
/// </summary>
|
||||||
|
[PublicAPI]
|
||||||
|
public void SetStoredOffset(EntityUid uid, Vector2i newOffset, ItemComponent? component = null)
|
||||||
|
{
|
||||||
|
if (!Resolve(uid, ref component, false))
|
||||||
|
return;
|
||||||
|
|
||||||
|
component.StoredOffset = newOffset;
|
||||||
|
Dirty(uid, component);
|
||||||
|
}
|
||||||
|
|
||||||
public void SetHeldPrefix(EntityUid uid, string? heldPrefix, bool force = false, ItemComponent? component = null)
|
public void SetHeldPrefix(EntityUid uid, string? heldPrefix, bool force = false, ItemComponent? component = null)
|
||||||
{
|
{
|
||||||
if (!Resolve(uid, ref component, false))
|
if (!Resolve(uid, ref component, false))
|
||||||
|
|||||||
Reference in New Issue
Block a user