13234546tyu
@@ -1,5 +1,6 @@
|
||||
using System.Diagnostics;
|
||||
using System.Numerics;
|
||||
using Content.Client.Resources;
|
||||
using Content.Shared._CP14.Fishing;
|
||||
using Content.Shared._CP14.Fishing.Components;
|
||||
using Content.Shared.Interaction;
|
||||
@@ -17,10 +18,6 @@ public sealed class CP14FishingSystem : CP14SharedFishingSystem
|
||||
[Dependency] private readonly IPrototypeManager _prototypeManager = default!;
|
||||
[Dependency] private readonly IResourceCache _resourceCache = default!;
|
||||
|
||||
private Popup? _fishingPopup;
|
||||
private const int FishingMinigameSizeX = 41;
|
||||
private const int FishingMinigameSizeY = 149;
|
||||
|
||||
public override void Initialize()
|
||||
{
|
||||
base.Initialize();
|
||||
@@ -42,44 +39,41 @@ public sealed class CP14FishingSystem : CP14SharedFishingSystem
|
||||
if (component.FishingProcess)
|
||||
return;
|
||||
|
||||
OpenFishingPopup(component);
|
||||
OpenFishingPopup(uid, component, args);
|
||||
}
|
||||
|
||||
private void OpenFishingPopup(CP14FishingRodComponent component)
|
||||
private void OpenFishingPopup(EntityUid uid, CP14FishingRodComponent component, AfterInteractEvent args)
|
||||
{
|
||||
_fishingPopup = new Popup
|
||||
// Getting data
|
||||
if (!_prototypeManager.Resolve(component.FishingMinigame, out var minigameStyle))
|
||||
return;
|
||||
|
||||
var background = minigameStyle.Background;
|
||||
var floatUI = minigameStyle.Float;
|
||||
var progressbar = minigameStyle.Progressbar;
|
||||
var fishIcon = minigameStyle.FishIcon;
|
||||
|
||||
var fishingPopup = new Popup
|
||||
{
|
||||
CloseOnClick = false,
|
||||
CloseOnEscape = false,
|
||||
MinSize = new Vector2(FishingMinigameSizeX, FishingMinigameSizeY),
|
||||
MaxSize = new Vector2(FishingMinigameSizeX, FishingMinigameSizeY),
|
||||
MinSize = new Vector2(background.Size.X, background.Size.Y),
|
||||
MaxSize = new Vector2(background.Size.X, background.Size.Y),
|
||||
};
|
||||
_userInterfaceManager.ModalRoot.AddChild(_fishingPopup);
|
||||
|
||||
var backgroundTexture = RequestTexture(CP14FishingMinigameElement.Background, component);
|
||||
if (backgroundTexture is null)
|
||||
return;
|
||||
_userInterfaceManager.ModalRoot.AddChild(fishingPopup);
|
||||
|
||||
var backgroundTexture = _resourceCache.GetTexture(background.Texture);
|
||||
var panel = new PanelContainer
|
||||
{
|
||||
PanelOverride = new StyleBoxTexture
|
||||
{
|
||||
Texture = backgroundTexture,
|
||||
},
|
||||
MinSize = new Vector2(background.Size.X, background.Size.Y),
|
||||
MaxSize = new Vector2(background.Size.X, background.Size.Y),
|
||||
};
|
||||
}
|
||||
fishingPopup.AddChild(panel);
|
||||
|
||||
private TextureResource? RequestTexture(CP14FishingMinigameElement element, CP14FishingRodComponent fishingRodComponent)
|
||||
{
|
||||
var minigamePrototype = _prototypeManager.Index(fishingRodComponent.FishingMinigame);
|
||||
|
||||
if (minigamePrototype.Texture is null || !minigamePrototype.Texture.TryGetValue(element, out var data))
|
||||
{
|
||||
Debug.Fail($"Tried to request a fishing minigame element {element} without a texture.");
|
||||
return null;
|
||||
}
|
||||
|
||||
var texture = _resourceCache.GetResource<TextureResource>(data.Texture);
|
||||
return texture;
|
||||
fishingPopup.Open(UIBox2.FromDimensions(new Vector2(0, 0), background.Size));
|
||||
}
|
||||
}
|
||||
|
||||
@@ -4,6 +4,9 @@ using Robust.Shared.Utility;
|
||||
|
||||
namespace Content.Shared._CP14.Fishing;
|
||||
|
||||
/// <summary>
|
||||
/// Prototype of fishing minigame stylesheet.
|
||||
/// </summary>
|
||||
[Prototype("CP14FishingMinigameStyle")]
|
||||
public sealed partial class CP14FishingMinigamePrototype : IPrototype
|
||||
{
|
||||
@@ -11,20 +14,33 @@ public sealed partial class CP14FishingMinigamePrototype : IPrototype
|
||||
public string ID { get; } = default!;
|
||||
|
||||
[DataField(required: true)]
|
||||
public Dictionary<CP14FishingMinigameElement, FishingMinigameElementData>? Texture;
|
||||
public FishingMinigameElementData Background;
|
||||
|
||||
[DataField(required: true)]
|
||||
public FishingMinigameElementData FishIcon;
|
||||
|
||||
[DataField(required: true)]
|
||||
public FishingMinigameElementData Progressbar;
|
||||
|
||||
[DataField(required: true)]
|
||||
public FishingMinigameElementData Float;
|
||||
|
||||
[DataDefinition]
|
||||
public partial struct FishingMinigameElementData
|
||||
{
|
||||
/// <summary>
|
||||
/// Texture path.
|
||||
/// </summary>
|
||||
[DataField(required: true)] public ResPath Texture;
|
||||
[DataField] public Vector2 Size;
|
||||
|
||||
/// <summary>
|
||||
/// Size of a texture.
|
||||
/// </summary>
|
||||
[DataField(required: true)] public Vector2 Size;
|
||||
|
||||
/// <summary>
|
||||
/// Offset from top left corner. Starter position in the bottom.
|
||||
/// </summary>
|
||||
[DataField(required: true)] public Vector2 Offset;
|
||||
}
|
||||
}
|
||||
|
||||
public enum CP14FishingMinigameElement : byte
|
||||
{
|
||||
Background,
|
||||
DefaultFishIcon,
|
||||
Progressbar,
|
||||
Float,
|
||||
}
|
||||
|
||||
@@ -1,3 +1,5 @@
|
||||
using Robust.Shared.Prototypes;
|
||||
|
||||
namespace Content.Shared._CP14.Fishing;
|
||||
|
||||
public abstract class CP14SharedFishingSystem : EntitySystem
|
||||
|
||||
@@ -4,12 +4,9 @@ using Robust.Shared.Prototypes;
|
||||
|
||||
namespace Content.Shared._CP14.Fishing.Components;
|
||||
|
||||
/// <summary>
|
||||
/// This is used for...
|
||||
/// </summary>
|
||||
[RegisterComponent]
|
||||
public sealed partial class CP14FishingPondComponent : Component
|
||||
{
|
||||
[DataField]
|
||||
public ProtoId<EntityTablePrototype> LootTable;
|
||||
public ProtoId<EntityTablePrototype>? LootTable;
|
||||
}
|
||||
|
||||
@@ -71,6 +71,7 @@
|
||||
- type: TileEntityEffect
|
||||
effects:
|
||||
- !type:ExtinguishReaction
|
||||
- type: CP14FishingPond
|
||||
|
||||
- type: entity
|
||||
parent: CP14FloorWaterOptimized
|
||||
|
||||
@@ -1,11 +1,18 @@
|
||||
- type: CP14FishingMinigameStyle
|
||||
id: Default
|
||||
texture:
|
||||
background:
|
||||
- texture: _CP14/Interface/Fishing/Default/background.png
|
||||
defaultFishIcon:
|
||||
- texture: _CP14/Interface/Fishing/Default/fish_icon.png
|
||||
progressbar:
|
||||
- texture: _CP14/Interface/Fishing/Default/progressbar.png
|
||||
float:
|
||||
- texture: _CP14/Interface/Fishing/Default/float.png
|
||||
background:
|
||||
texture: Textures/Interface/Paper/paper_background_default.svg.96dpi.png
|
||||
size: 39, 149
|
||||
offset: 0, 0
|
||||
fishIcon:
|
||||
texture: Textures/_CP14/Interface/Fishing/Default/fish_icon.png
|
||||
size: 11, 9
|
||||
offset: 3, 3
|
||||
progressbar:
|
||||
texture: Textures/_CP14/Interface/Fishing/Default/progressbar.png
|
||||
size: 2, 142
|
||||
offset: 13, 134
|
||||
float:
|
||||
texture: Textures/_CP14/Interface/Fishing/Default/float.png
|
||||
size: 11, 38
|
||||
offset: 13, 105
|
||||
|
||||
|
Before Width: | Height: | Size: 2.5 KiB After Width: | Height: | Size: 2.5 KiB |
|
Before Width: | Height: | Size: 328 B After Width: | Height: | Size: 250 B |
|
Before Width: | Height: | Size: 401 B After Width: | Height: | Size: 291 B |
|
Before Width: | Height: | Size: 244 B After Width: | Height: | Size: 223 B |