Salvage dungeons (#14520)
This commit is contained in:
@@ -109,6 +109,7 @@ namespace Content.Client.Entry
|
||||
_prototypeManager.RegisterIgnore("metabolizerType");
|
||||
_prototypeManager.RegisterIgnore("metabolismGroup");
|
||||
_prototypeManager.RegisterIgnore("salvageMap");
|
||||
_prototypeManager.RegisterIgnore("salvageFaction");
|
||||
_prototypeManager.RegisterIgnore("gamePreset");
|
||||
_prototypeManager.RegisterIgnore("gameRule");
|
||||
_prototypeManager.RegisterIgnore("worldSpell");
|
||||
|
||||
@@ -29,6 +29,9 @@ namespace Content.Client.IconSmoothing
|
||||
[ViewVariables(VVAccess.ReadWrite), DataField("base")]
|
||||
public string StateBase { get; } = string.Empty;
|
||||
|
||||
[DataField("shader", customTypeSerializer:typeof(PrototypeIdSerializer<ShaderPrototype>))]
|
||||
public string? Shader;
|
||||
|
||||
/// <summary>
|
||||
/// Mode that controls how the icon should be selected.
|
||||
/// </summary>
|
||||
|
||||
@@ -55,6 +55,14 @@ namespace Content.Client.IconSmoothing
|
||||
sprite.LayerSetDirOffset(CornerLayers.NW, DirectionOffset.Flip);
|
||||
sprite.LayerMapSet(CornerLayers.SW, sprite.AddLayerState(state0));
|
||||
sprite.LayerSetDirOffset(CornerLayers.SW, DirectionOffset.Clockwise);
|
||||
|
||||
if (component.Shader != null)
|
||||
{
|
||||
sprite.LayerSetShader(CornerLayers.SE, component.Shader);
|
||||
sprite.LayerSetShader(CornerLayers.NE, component.Shader);
|
||||
sprite.LayerSetShader(CornerLayers.NW, component.Shader);
|
||||
sprite.LayerSetShader(CornerLayers.SW, component.Shader);
|
||||
}
|
||||
}
|
||||
|
||||
private void OnShutdown(EntityUid uid, IconSmoothComponent component, ComponentShutdown args)
|
||||
|
||||
@@ -74,8 +74,6 @@ namespace Content.Client.Lobby.UI
|
||||
AddChild(vBox);
|
||||
|
||||
UpdateUI();
|
||||
|
||||
_preferencesManager.OnServerDataLoaded += UpdateUI;
|
||||
}
|
||||
|
||||
public Button CharacterSetupButton { get; }
|
||||
@@ -128,7 +126,7 @@ namespace Content.Client.Lobby.UI
|
||||
_viewBox.AddChild(viewWest);
|
||||
_viewBox.AddChild(viewEast);
|
||||
_summaryLabel.Text = selectedCharacter.Summary;
|
||||
EntitySystem.Get<HumanoidAppearanceSystem>().LoadProfile(_previewDummy.Value, selectedCharacter);
|
||||
_entityManager.System<HumanoidAppearanceSystem>().LoadProfile(_previewDummy.Value, selectedCharacter);
|
||||
GiveDummyJobClothes(_previewDummy.Value, selectedCharacter);
|
||||
}
|
||||
}
|
||||
|
||||
@@ -235,7 +235,7 @@ namespace Content.Client.Parallax
|
||||
for (var x = 0; x < bitmap.Width; x++)
|
||||
{
|
||||
// Do noise calculations.
|
||||
var noiseVal = MathF.Min(1, MathF.Max(0, (noise.GetNoiseTiled(x, y) + 1) / 2));
|
||||
var noiseVal = MathF.Min(1, MathF.Max(0, (noise.GetNoise(x, y) + 1) / 2));
|
||||
|
||||
// Threshold
|
||||
noiseVal = MathF.Max(0, noiseVal - Threshold);
|
||||
@@ -462,7 +462,7 @@ namespace Content.Client.Parallax
|
||||
var y = random.Next(0, buffer.Height);
|
||||
|
||||
// Grab noise at this point.
|
||||
var noiseVal = MathF.Min(1, MathF.Max(0, (noise.GetNoiseTiled(x, y) + 1) / 2));
|
||||
var noiseVal = MathF.Min(1, MathF.Max(0, (noise.GetNoise(x, y) + 1) / 2));
|
||||
// Threshold
|
||||
noiseVal = MathF.Max(0, noiseVal - MaskThreshold);
|
||||
noiseVal *= threshVal;
|
||||
|
||||
8
Content.Client/Salvage/SalvageSystem.cs
Normal file
8
Content.Client/Salvage/SalvageSystem.cs
Normal file
@@ -0,0 +1,8 @@
|
||||
using Content.Shared.Salvage;
|
||||
|
||||
namespace Content.Client.Salvage;
|
||||
|
||||
public sealed class SalvageSystem : SharedSalvageSystem
|
||||
{
|
||||
|
||||
}
|
||||
@@ -0,0 +1,47 @@
|
||||
using Content.Shared.Salvage;
|
||||
using JetBrains.Annotations;
|
||||
using Robust.Client.GameObjects;
|
||||
|
||||
namespace Content.Client.Salvage.UI;
|
||||
|
||||
[UsedImplicitly]
|
||||
public sealed class SalvageExpeditionConsoleBoundUserInterface : BoundUserInterface
|
||||
{
|
||||
private SalvageExpeditionWindow? _window;
|
||||
|
||||
public SalvageExpeditionConsoleBoundUserInterface(ClientUserInterfaceComponent owner, Enum uiKey) : base(owner, uiKey)
|
||||
{
|
||||
}
|
||||
|
||||
protected override void Open()
|
||||
{
|
||||
base.Open();
|
||||
_window = new SalvageExpeditionWindow();
|
||||
_window.ClaimMission += index =>
|
||||
{
|
||||
SendMessage(new ClaimSalvageMessage()
|
||||
{
|
||||
Index = index,
|
||||
});
|
||||
};
|
||||
_window.OnClose += Close;
|
||||
_window?.OpenCenteredLeft();
|
||||
}
|
||||
|
||||
protected override void Dispose(bool disposing)
|
||||
{
|
||||
base.Dispose(disposing);
|
||||
_window?.Dispose();
|
||||
_window = null;
|
||||
}
|
||||
|
||||
protected override void UpdateState(BoundUserInterfaceState state)
|
||||
{
|
||||
base.UpdateState(state);
|
||||
|
||||
if (state is not SalvageExpeditionConsoleState current)
|
||||
return;
|
||||
|
||||
_window?.UpdateState(current);
|
||||
}
|
||||
}
|
||||
23
Content.Client/Salvage/UI/SalvageExpeditionWindow.xaml
Normal file
23
Content.Client/Salvage/UI/SalvageExpeditionWindow.xaml
Normal file
@@ -0,0 +1,23 @@
|
||||
<controls:FancyWindow xmlns="https://spacestation14.io"
|
||||
xmlns:controls="clr-namespace:Content.Client.UserInterface.Controls"
|
||||
Title="{Loc 'Salvage expeditions'}"
|
||||
MinSize="800 360">
|
||||
<BoxContainer Orientation="Vertical">
|
||||
<BoxContainer Orientation="Horizontal">
|
||||
<Label Name="NextOfferLabel"
|
||||
Text="Next offer:"
|
||||
Margin="5"></Label>
|
||||
<ProgressBar Name="NextOfferBar"
|
||||
HorizontalExpand="True"
|
||||
MinValue="0"
|
||||
MaxValue="1"
|
||||
SetHeight="25"/>
|
||||
<Label Name="NextOfferText" Text="0.00"
|
||||
Margin="5"/>
|
||||
</BoxContainer>
|
||||
<controls:HLine Color="#404040" Thickness="2" Margin="0 5 0 5"/>
|
||||
<BoxContainer Name="Container"
|
||||
Orientation="Horizontal"
|
||||
Margin="5 0 5 0"/>
|
||||
</BoxContainer>
|
||||
</controls:FancyWindow>
|
||||
334
Content.Client/Salvage/UI/SalvageExpeditionWindow.xaml.cs
Normal file
334
Content.Client/Salvage/UI/SalvageExpeditionWindow.xaml.cs
Normal file
@@ -0,0 +1,334 @@
|
||||
using Content.Client.Computer;
|
||||
using Content.Client.Stylesheets;
|
||||
using Content.Client.UserInterface.Controls;
|
||||
using Content.Shared.Parallax.Biomes;
|
||||
using Content.Shared.Procedural;
|
||||
using Content.Shared.Procedural.Loot;
|
||||
using Content.Shared.Procedural.Rewards;
|
||||
using Content.Shared.Random;
|
||||
using Content.Shared.Random.Helpers;
|
||||
using Content.Shared.Salvage;
|
||||
using Content.Shared.Salvage.Expeditions;
|
||||
using Content.Shared.Salvage.Expeditions.Structure;
|
||||
using Content.Shared.Shuttles.BUIStates;
|
||||
using Robust.Client.AutoGenerated;
|
||||
using Robust.Client.Graphics;
|
||||
using Robust.Client.UserInterface;
|
||||
using Robust.Client.UserInterface.Controls;
|
||||
using Robust.Client.UserInterface.XAML;
|
||||
using Robust.Shared.Prototypes;
|
||||
using Robust.Shared.Timing;
|
||||
|
||||
namespace Content.Client.Salvage.UI;
|
||||
|
||||
[GenerateTypedNameReferences]
|
||||
public sealed partial class SalvageExpeditionWindow : FancyWindow,
|
||||
IComputerWindow<EmergencyConsoleBoundUserInterfaceState>
|
||||
{
|
||||
private readonly IGameTiming _timing;
|
||||
private readonly IPrototypeManager _prototype;
|
||||
private readonly SharedSalvageSystem _salvage;
|
||||
|
||||
public event Action<ushort>? ClaimMission;
|
||||
private bool _claimed;
|
||||
private TimeSpan _nextOffer;
|
||||
|
||||
public SalvageExpeditionWindow()
|
||||
{
|
||||
RobustXamlLoader.Load(this);
|
||||
_timing = IoCManager.Resolve<IGameTiming>();
|
||||
_prototype = IoCManager.Resolve<IPrototypeManager>();
|
||||
_salvage = IoCManager.Resolve<IEntityManager>().EntitySysManager.GetEntitySystem<SharedSalvageSystem>();
|
||||
}
|
||||
|
||||
public void UpdateState(SalvageExpeditionConsoleState state)
|
||||
{
|
||||
_claimed = state.Claimed;
|
||||
_nextOffer = state.NextOffer;
|
||||
Container.DisposeAllChildren();
|
||||
|
||||
for (var i = 0; i < state.Missions.Count; i++)
|
||||
{
|
||||
// TODO: Make this XAML
|
||||
var mission = state.Missions[i];
|
||||
var config = _prototype.Index<SalvageExpeditionPrototype>(mission.Config);
|
||||
var dungeonConfig = _prototype.Index<DungeonConfigPrototype>(config.DungeonConfigPrototype);
|
||||
var faction = SharedSalvageSystem.GetFaction(config.Factions, mission.Seed);
|
||||
var factionConfig = _prototype.Index<SalvageFactionPrototype>(faction);
|
||||
|
||||
// If we ever need this on server then move it
|
||||
var missionDesc = string.Empty;
|
||||
var missionDetails = string.Empty;
|
||||
|
||||
switch (config.Mission)
|
||||
{
|
||||
case SalvageStructure structure:
|
||||
var structureConfig = (SalvageStructureFaction) factionConfig.Configs[mission.Config];
|
||||
missionDesc = "Demolition";
|
||||
// TODO:
|
||||
missionDetails = $"Destroy {SharedSalvageSystem.GetStructureCount(structure, mission.Seed)} {_prototype.Index<EntityPrototype>(structureConfig.Spawn).Name} structures.";
|
||||
break;
|
||||
default:
|
||||
throw new NotImplementedException();
|
||||
}
|
||||
|
||||
// Mission
|
||||
var missionStripe = new StripeBack()
|
||||
{
|
||||
Margin = new Thickness(0f, -5f, 0f, 0f)
|
||||
};
|
||||
|
||||
missionStripe.AddChild(new Label()
|
||||
{
|
||||
Text = missionDesc,
|
||||
HorizontalAlignment = HAlignment.Center,
|
||||
Margin = new Thickness(0f, 5f, 0f, 5f),
|
||||
});
|
||||
|
||||
var lBox = new BoxContainer()
|
||||
{
|
||||
Orientation = BoxContainer.LayoutOrientation.Vertical
|
||||
};
|
||||
|
||||
// Difficulty
|
||||
// Details
|
||||
lBox.AddChild(new Label()
|
||||
{
|
||||
Text = $"Difficulty:"
|
||||
});
|
||||
|
||||
var difficultyColor = StyleNano.NanoGold;
|
||||
|
||||
switch (config.DifficultyRating)
|
||||
{
|
||||
case DifficultyRating.None:
|
||||
difficultyColor = StyleNano.ButtonColorDefault;
|
||||
break;
|
||||
case DifficultyRating.Minor:
|
||||
difficultyColor = StyleNano.GoodGreenFore;
|
||||
break;
|
||||
case DifficultyRating.Moderate:
|
||||
difficultyColor = StyleNano.ConcerningOrangeFore;
|
||||
break;
|
||||
default:
|
||||
throw new ArgumentOutOfRangeException();
|
||||
}
|
||||
|
||||
lBox.AddChild(new Label
|
||||
{
|
||||
Text = config.DifficultyRating.ToString(),
|
||||
FontColorOverride = difficultyColor,
|
||||
HorizontalAlignment = HAlignment.Left,
|
||||
Margin = new Thickness(0f, 0f, 0f, 5f),
|
||||
});
|
||||
|
||||
// Details
|
||||
lBox.AddChild(new Label
|
||||
{
|
||||
Text = $"Details:"
|
||||
});
|
||||
|
||||
lBox.AddChild(new Label
|
||||
{
|
||||
Text = missionDetails,
|
||||
FontColorOverride = StyleNano.NanoGold,
|
||||
HorizontalAlignment = HAlignment.Left,
|
||||
Margin = new Thickness(0f, 0f, 0f, 5f),
|
||||
});
|
||||
|
||||
// Details
|
||||
lBox.AddChild(new Label
|
||||
{
|
||||
Text = $"Hostiles:"
|
||||
});
|
||||
|
||||
lBox.AddChild(new Label
|
||||
{
|
||||
Text = faction,
|
||||
FontColorOverride = StyleNano.NanoGold,
|
||||
HorizontalAlignment = HAlignment.Left,
|
||||
Margin = new Thickness(0f, 0f, 0f, 5f),
|
||||
});
|
||||
|
||||
// Duration
|
||||
lBox.AddChild(new Label
|
||||
{
|
||||
Text = $"Duration:"
|
||||
});
|
||||
|
||||
lBox.AddChild(new Label
|
||||
{
|
||||
Text = mission.Duration.ToString(),
|
||||
FontColorOverride = StyleNano.NanoGold,
|
||||
HorizontalAlignment = HAlignment.Left,
|
||||
Margin = new Thickness(0f, 0f, 0f, 5f),
|
||||
});
|
||||
|
||||
// Biome
|
||||
lBox.AddChild(new Label
|
||||
{
|
||||
Text = "Biome:"
|
||||
});
|
||||
|
||||
lBox.AddChild(new Label
|
||||
{
|
||||
Text = _prototype.Index<BiomePrototype>(config.Biome).Description,
|
||||
FontColorOverride = StyleNano.NanoGold,
|
||||
HorizontalAlignment = HAlignment.Left,
|
||||
Margin = new Thickness(0f, 0f, 0f, 5f),
|
||||
});
|
||||
|
||||
// Environment
|
||||
lBox.AddChild(new Label
|
||||
{
|
||||
Text = "Environment:"
|
||||
});
|
||||
|
||||
lBox.AddChild(new Label
|
||||
{
|
||||
Text = config.Description,
|
||||
FontColorOverride = StyleNano.NanoGold,
|
||||
HorizontalAlignment = HAlignment.Left,
|
||||
Margin = new Thickness(0f, 0f, 0f, 5f),
|
||||
});
|
||||
|
||||
// Modifiers
|
||||
// TODO
|
||||
|
||||
// Rewards
|
||||
lBox.AddChild(new Label()
|
||||
{
|
||||
Text = $"Reward:"
|
||||
});
|
||||
|
||||
var salvageReward = SharedSalvageSystem.GetReward(_prototype.Index<WeightedRandomPrototype>(config.Reward), mission.Seed, _prototype);
|
||||
var difficulty = config.DifficultyRating;
|
||||
var rewardDesc = string.Empty;
|
||||
|
||||
switch (salvageReward)
|
||||
{
|
||||
case BankReward bank:
|
||||
rewardDesc = $"Bank payment of {(int) (bank.Amount * SharedSalvageSystem.GetDifficultyModifier(difficulty))}";
|
||||
break;
|
||||
default:
|
||||
throw new ArgumentOutOfRangeException();
|
||||
}
|
||||
|
||||
lBox.AddChild(new Label()
|
||||
{
|
||||
Text = rewardDesc,
|
||||
FontColorOverride = StyleNano.GoodGreenFore,
|
||||
HorizontalAlignment = HAlignment.Left,
|
||||
Margin = new Thickness(0f, 0f, 0f, 5f),
|
||||
});
|
||||
|
||||
|
||||
lBox.AddChild(new Label()
|
||||
{
|
||||
Text = $"Materials:"
|
||||
});
|
||||
|
||||
if (config.Loots.Count == 0)
|
||||
{
|
||||
lBox.AddChild(new Label()
|
||||
{
|
||||
Text = "N/A",
|
||||
FontColorOverride = StyleNano.ConcerningOrangeFore,
|
||||
HorizontalAlignment = HAlignment.Left,
|
||||
Margin = new Thickness(0f, 0f, 0f, 5f),
|
||||
});
|
||||
}
|
||||
else
|
||||
{
|
||||
foreach (var lootProto in SharedSalvageSystem.GetLoot(config.Loots, mission.Seed, _prototype))
|
||||
{
|
||||
lBox.AddChild(new Label()
|
||||
{
|
||||
Text = lootProto.Description,
|
||||
FontColorOverride = StyleNano.ConcerningOrangeFore,
|
||||
HorizontalAlignment = HAlignment.Left,
|
||||
Margin = new Thickness(0f, 0f, 0f, 5f),
|
||||
});
|
||||
}
|
||||
}
|
||||
|
||||
// Claim
|
||||
var claimButton = new Button()
|
||||
{
|
||||
HorizontalExpand = true,
|
||||
Pressed = state.ActiveMission == mission.Index,
|
||||
ToggleMode = true,
|
||||
Disabled = state.Claimed,
|
||||
};
|
||||
|
||||
claimButton.Label.Margin = new Thickness(0f, 5f);
|
||||
|
||||
claimButton.OnPressed += args =>
|
||||
{
|
||||
ClaimMission?.Invoke(mission.Index);
|
||||
};
|
||||
|
||||
if (state.ActiveMission == mission.Index)
|
||||
{
|
||||
claimButton.Text = "Claimed";
|
||||
claimButton.AddStyleClass(StyleBase.ButtonCaution);
|
||||
}
|
||||
else
|
||||
{
|
||||
claimButton.Text = "Claim";
|
||||
}
|
||||
|
||||
// TODO: Fix this copypaste bullshit
|
||||
|
||||
var box = new PanelContainer()
|
||||
{
|
||||
PanelOverride = new StyleBoxFlat(new Color(30, 30, 34)),
|
||||
HorizontalExpand = true,
|
||||
Margin = new Thickness(5f, 0f),
|
||||
Children =
|
||||
{
|
||||
new BoxContainer()
|
||||
{
|
||||
Orientation = BoxContainer.LayoutOrientation.Vertical,
|
||||
Children =
|
||||
{
|
||||
missionStripe,
|
||||
lBox,
|
||||
claimButton,
|
||||
},
|
||||
Margin = new Thickness(5f, 5f)
|
||||
}
|
||||
}
|
||||
};
|
||||
|
||||
LayoutContainer.SetAnchorPreset(box, LayoutContainer.LayoutPreset.Wide);
|
||||
|
||||
Container.AddChild(box);
|
||||
}
|
||||
}
|
||||
|
||||
protected override void FrameUpdate(FrameEventArgs args)
|
||||
{
|
||||
base.FrameUpdate(args);
|
||||
|
||||
if (_claimed)
|
||||
{
|
||||
NextOfferBar.Value = 0f;
|
||||
NextOfferText.Text = "N/A";
|
||||
return;
|
||||
}
|
||||
|
||||
var remaining = _nextOffer - _timing.CurTime;
|
||||
|
||||
if (remaining < TimeSpan.Zero)
|
||||
{
|
||||
NextOfferBar.Value = 1f;
|
||||
NextOfferText.Text = "00:00";
|
||||
}
|
||||
else
|
||||
{
|
||||
NextOfferBar.Value = 1f - (float) (remaining / SharedSalvageSystem.MissionCooldown);
|
||||
NextOfferText.Text = $"{remaining.Minutes:00}:{remaining.Seconds:00}";
|
||||
}
|
||||
}
|
||||
}
|
||||
Reference in New Issue
Block a user