Trade reputation rework + Merchants back + Mining contract (#1347)
* refactor unlocking * fix contract debug crashing * Update dev_map.yml * bugfixes and content rebalance * ore buy contract
This commit is contained in:
@@ -14,7 +14,6 @@ public sealed class CP14TradingPlatformBoundUserInterface(EntityUid owner, Enum
|
||||
|
||||
_window = this.CreateWindow<CP14TradingPlatformWindow>();
|
||||
|
||||
_window.OnUnlock += pos => SendMessage(new CP14TradingPositionUnlockAttempt(pos));
|
||||
_window.OnBuy += pos => SendMessage(new CP14TradingPositionBuyAttempt(pos));
|
||||
}
|
||||
|
||||
|
||||
@@ -35,6 +35,10 @@
|
||||
<Label Name="Name" Access="Public" StyleClasses="LabelHeadingBigger" VAlign="Center"
|
||||
HorizontalExpand="True" HorizontalAlignment="Center" />
|
||||
</BoxContainer>
|
||||
<BoxContainer Orientation="Horizontal" HorizontalExpand="True" HorizontalAlignment="Center">
|
||||
<TextureRect VerticalAlignment="Center" Margin="20 0 5 0" HorizontalAlignment="Left" TextureScale="2, 2" TexturePath="/Textures/_CP14/Interface/Misc/star.png"/>
|
||||
<RichTextLabel Name="UnlockCost" Access="Public" Text="0"/>
|
||||
</BoxContainer>
|
||||
<!-- Description -->
|
||||
<BoxContainer HorizontalExpand="True">
|
||||
<RichTextLabel Name="Description" HorizontalExpand="True" Access="Public" />
|
||||
@@ -47,17 +51,6 @@
|
||||
|
||||
<!-- Buttons -->
|
||||
<BoxContainer Orientation="Vertical" HorizontalExpand="True">
|
||||
|
||||
<BoxContainer Name="UnlockBox" Orientation="Horizontal" HorizontalExpand="True" Visible="True">
|
||||
<Button Name="UnlockButton" Text="{Loc 'cp14-trading-ui-button-unlock'}"
|
||||
ToolTip="{Loc 'cp14-trading-ui-button-unlock-tooltip'}" StyleClasses="OpenRight"
|
||||
HorizontalExpand="True" MinHeight="35" Access="Public"/>
|
||||
<BoxContainer SetWidth="100" MaxWidth="100" Orientation="Horizontal">
|
||||
<TextureRect VerticalAlignment="Center" Margin="20 0 5 0" HorizontalAlignment="Left" TextureScale="2, 2" TexturePath="/Textures/_CP14/Interface/Misc/star.png"/>
|
||||
<RichTextLabel Name="UnlockCost" Access="Public" Text="0"/>
|
||||
</BoxContainer>
|
||||
</BoxContainer>
|
||||
|
||||
<BoxContainer Name="BuyBox" Orientation="Horizontal" HorizontalExpand="True" Visible="True">
|
||||
<Button Name="BuyButton" Text="{Loc 'cp14-trading-ui-button-buy'}"
|
||||
ToolTip="{Loc 'cp14-trading-ui-button-buy-tooltip'}" StyleClasses="OpenRight"
|
||||
|
||||
@@ -6,6 +6,7 @@ using Content.Shared._CP14.Trading;
|
||||
using Content.Shared._CP14.Trading.Components;
|
||||
using Content.Shared._CP14.Trading.Prototypes;
|
||||
using Robust.Client.AutoGenerated;
|
||||
using Robust.Client.Player;
|
||||
using Robust.Client.UserInterface.Controls;
|
||||
using Robust.Client.UserInterface.CustomControls;
|
||||
using Robust.Client.UserInterface.XAML;
|
||||
@@ -25,6 +26,7 @@ public sealed partial class CP14TradingPlatformWindow : DefaultWindow
|
||||
[Dependency] private readonly IPrototypeManager _proto = default!;
|
||||
[Dependency] private readonly IEntityManager _e = default!;
|
||||
[Dependency] private readonly IGameTiming _timing = default!;
|
||||
[Dependency] private readonly IPlayerManager _player = default!;
|
||||
|
||||
private readonly CP14ClientTradingPlatformSystem _tradingSystem;
|
||||
private readonly CP14ClientStationEconomySystem _economySystem;
|
||||
@@ -39,8 +41,6 @@ public sealed partial class CP14TradingPlatformWindow : DefaultWindow
|
||||
|
||||
private ProtoId<CP14TradingFactionPrototype>? _selectedFaction;
|
||||
private CP14TradingPositionPrototype? _selectedPosition;
|
||||
|
||||
public event Action<ProtoId<CP14TradingPositionPrototype>>? OnUnlock;
|
||||
public event Action<ProtoId<CP14TradingPositionPrototype>>? OnBuy;
|
||||
|
||||
private ISawmill Sawmill { get; init; }
|
||||
@@ -75,21 +75,9 @@ public sealed partial class CP14TradingPlatformWindow : DefaultWindow
|
||||
ParallaxBackground.Offset = -offset * 0.25f + new Vector2(1000, 1000); //hardcoding is bad
|
||||
};
|
||||
GraphControl.OnNodeSelected += SelectNode;
|
||||
UnlockButton.OnPressed += UnlockPressed;
|
||||
BuyButton.OnPressed += BuyPressed;
|
||||
}
|
||||
|
||||
private void UnlockPressed(BaseButton.ButtonEventArgs obj)
|
||||
{
|
||||
if (_selectedPosition is null)
|
||||
return;
|
||||
|
||||
OnUnlock?.Invoke(_selectedPosition);
|
||||
|
||||
if (_cachedUser is not null)
|
||||
_audio.PlayGlobal(new SoundCollectionSpecifier("CP14CoinImpact"), _cachedUser.Value);
|
||||
}
|
||||
|
||||
private void BuyPressed(BaseButton.ButtonEventArgs obj)
|
||||
{
|
||||
if (_selectedPosition is null)
|
||||
@@ -133,16 +121,15 @@ public sealed partial class CP14TradingPlatformWindow : DefaultWindow
|
||||
}
|
||||
|
||||
_selectedPosition = node;
|
||||
var unlocked = _cachedUser.Value.Comp.UnlockedPositions;
|
||||
var unlocked = _cachedUser.Value.Comp.Reputation[_selectedPosition.Faction] >= _selectedPosition.ReputationLevel;
|
||||
|
||||
Name.Text = _tradingSystem.GetTradeName(_selectedPosition);
|
||||
Description.Text = _tradingSystem.GetTradeDescription(_selectedPosition);
|
||||
|
||||
LocationView.Texture = _selectedPosition.Icon.Frame0();
|
||||
UnlockButton.Disabled = !_tradingSystem.CanUnlockPosition((_cachedUser.Value.Owner, _cachedUser.Value.Comp), _selectedPosition);
|
||||
BuyButton.Disabled = !unlocked.Contains(_selectedPosition);
|
||||
BuyButton.Disabled = !unlocked;
|
||||
|
||||
UnlockCost.Text = _selectedPosition.UnlockReputationCost.ToString();
|
||||
UnlockCost.Text = _selectedPosition.ReputationLevel.ToString();
|
||||
|
||||
BuyPriceHolder.RemoveAllChildren();
|
||||
BuyPriceHolder.AddChild(new CP14PriceControl(_economySystem.GetPrice(_selectedPosition) ?? 0));
|
||||
@@ -153,24 +140,23 @@ public sealed partial class CP14TradingPlatformWindow : DefaultWindow
|
||||
Name.Text = string.Empty;
|
||||
Description.Text = string.Empty;
|
||||
LocationView.Texture = null;
|
||||
UnlockButton.Disabled = true;
|
||||
}
|
||||
|
||||
private void CacheSkillProto()
|
||||
{
|
||||
_allPositions = _proto.EnumeratePrototypes<CP14TradingPositionPrototype>();
|
||||
_allFactions = _proto.EnumeratePrototypes<CP14TradingFactionPrototype>().OrderBy(tree => Loc.GetString(tree.Name));
|
||||
UpdateGraphControl();
|
||||
}
|
||||
|
||||
public void UpdateState(CP14TradingPlatformUiState state)
|
||||
{
|
||||
_cacheState = state;
|
||||
var ent = _e.GetEntity(state.User);
|
||||
|
||||
if (!_e.TryGetComponent<CP14TradingReputationComponent>(ent, out var repComp))
|
||||
if (!_e.TryGetComponent<CP14TradingReputationComponent>(_player.LocalEntity, out var repComp))
|
||||
return;
|
||||
|
||||
_cachedUser = (ent, repComp);
|
||||
_cachedUser = (_player.LocalEntity.Value, repComp);
|
||||
|
||||
var plat = _e.GetEntity(state.Platform);
|
||||
if (!_e.TryGetComponent<CP14TradingPlatformComponent>(plat, out var platComp))
|
||||
@@ -192,15 +178,10 @@ public sealed partial class CP14TradingPlatformWindow : DefaultWindow
|
||||
if (position.Faction != _selectedFaction)
|
||||
continue;
|
||||
|
||||
var unlocked = _cachedUser.Value.Comp.UnlockedPositions;
|
||||
var gained = unlocked.Contains(position);
|
||||
var active = _tradingSystem.CanUnlockPosition((_cachedUser.Value.Owner, _cachedUser.Value.Comp), position);
|
||||
var node = new CP14NodeTreeElement(position.ID, gained, active, position.UiPosition * 66, position.Icon);
|
||||
var unlocked = _cachedUser.Value.Comp.Reputation[position.Faction] >= position.ReputationLevel;
|
||||
var active = _tradingSystem.CanBuyPosition((_cachedUser.Value.Owner, _cachedUser.Value.Comp), position);
|
||||
var node = new CP14NodeTreeElement(position.ID, unlocked, active, new Vector2(position.ReputationLevel.Float() * 50, position.UiPosition * 50) , position.Icon);
|
||||
nodeTreeElements.Add(node);
|
||||
if (position.Prerequisite != null)
|
||||
{
|
||||
edges.Add((position.Prerequisite, position.ID));
|
||||
}
|
||||
}
|
||||
|
||||
GraphControl.UpdateState(
|
||||
|
||||
Reference in New Issue
Block a user