Skip to content

Commit

Permalink
Expedition ReWind (#588)
Browse files Browse the repository at this point in the history
* Revert "Expeditions rework (#18960)"

This reverts commit 036b9ef

* it builds

* re implement reward spawning
  • Loading branch information
Cheackraze authored Nov 17, 2023
1 parent 5037ad4 commit 45f77dd
Show file tree
Hide file tree
Showing 40 changed files with 1,044 additions and 689 deletions.
69 changes: 56 additions & 13 deletions Content.Client/Salvage/UI/SalvageExpeditionWindow.xaml.cs
Original file line number Diff line number Diff line change
Expand Up @@ -4,7 +4,6 @@
using Content.Client.UserInterface.Controls;
using Content.Shared.CCVar;
using Content.Shared.Parallax.Biomes;
using Content.Shared.Procedural;
using Content.Shared.Salvage;
using Content.Shared.Salvage.Expeditions;
using Content.Shared.Salvage.Expeditions.Modifiers;
Expand Down Expand Up @@ -54,10 +53,8 @@ public void UpdateState(SalvageExpeditionConsoleState state)
for (var i = 0; i < state.Missions.Count; i++)
{
var missionParams = state.Missions[i];
var difficultyId = "Moderate";
var difficultyProto = _prototype.Index<SalvageDifficultyPrototype>(difficultyId);
// TODO: Selectable difficulty soon.
var mission = _salvage.GetMission(difficultyProto, missionParams.Seed);
var config = missionParams.MissionType;
var mission = _salvage.GetMission(missionParams.MissionType, missionParams.Difficulty, missionParams.Seed);

// Mission title
var missionStripe = new StripeBack()
Expand All @@ -67,7 +64,7 @@ public void UpdateState(SalvageExpeditionConsoleState state)

missionStripe.AddChild(new Label()
{
Text = Loc.GetString($"salvage-expedition-type"),
Text = Loc.GetString($"salvage-expedition-type-{config.ToString()}"),
HorizontalAlignment = HAlignment.Center,
Margin = new Thickness(0f, 5f, 0f, 5f),
});
Expand All @@ -84,25 +81,48 @@ public void UpdateState(SalvageExpeditionConsoleState state)
Text = Loc.GetString("salvage-expedition-window-difficulty")
});

var difficultyColor = difficultyProto.Color;
Color difficultyColor;

switch (missionParams.Difficulty)
{
case DifficultyRating.Minimal:
difficultyColor = Color.FromHex("#52B4E996");
break;
case DifficultyRating.Minor:
difficultyColor = Color.FromHex("#9FED5896");
break;
case DifficultyRating.Moderate:
difficultyColor = Color.FromHex("#EFB34196");
break;
case DifficultyRating.Hazardous:
difficultyColor = Color.FromHex("#DE3A3A96");
break;
case DifficultyRating.Extreme:
difficultyColor = Color.FromHex("#D381C996");
break;
default:
throw new ArgumentOutOfRangeException();
}

lBox.AddChild(new Label
{
Text = Loc.GetString("salvage-expedition-difficulty-Moderate"),
Text = Loc.GetString($"salvage-expedition-difficulty-{missionParams.Difficulty.ToString()}"),
FontColorOverride = difficultyColor,
HorizontalAlignment = HAlignment.Left,
Margin = new Thickness(0f, 0f, 0f, 5f),
});

// Details
var details = _salvage.GetMissionDescription(mission);

lBox.AddChild(new Label
{
Text = Loc.GetString("salvage-expedition-difficulty-players"),
HorizontalAlignment = HAlignment.Left,
Text = Loc.GetString("salvage-expedition-window-details")
});

lBox.AddChild(new Label
{
Text = difficultyProto.RecommendedPlayers.ToString(),
Text = details,
FontColorOverride = StyleNano.NanoGold,
HorizontalAlignment = HAlignment.Left,
Margin = new Thickness(0f, 0f, 0f, 5f),
Expand Down Expand Up @@ -148,7 +168,7 @@ public void UpdateState(SalvageExpeditionConsoleState state)

lBox.AddChild(new Label
{
Text = Loc.GetString(_prototype.Index<SalvageBiomeModPrototype>(biome).ID),
Text = Loc.GetString(_prototype.Index<SalvageBiomeMod>(biome).ID),
FontColorOverride = StyleNano.NanoGold,
HorizontalAlignment = HAlignment.Left,
Margin = new Thickness(0f, 0f, 0f, 5f),
Expand All @@ -170,6 +190,29 @@ public void UpdateState(SalvageExpeditionConsoleState state)
Margin = new Thickness(0f, 0f, 0f, 5f),
});

lBox.AddChild(new Label()
{
Text = Loc.GetString("salvage-expedition-window-rewards")
});

var rewards = new Dictionary<string, int>();
foreach (var reward in mission.Rewards)
{
var name = _prototype.Index<EntityPrototype>(reward).Name;
var count = rewards.GetOrNew(name);
count++;
rewards[name] = count;
}

// there will always be 3 or more rewards so no need for 0 check
lBox.AddChild(new Label()
{
Text = string.Join("\n", rewards.Select(o => "- " + o.Key + (o.Value > 1 ? $" x {o.Value}" : ""))).TrimEnd(),
FontColorOverride = StyleNano.ConcerningOrangeFore,
HorizontalAlignment = HAlignment.Left,
Margin = new Thickness(0f, 0f, 0f, 5f)
});

// Claim
var claimButton = new Button()
{
Expand Down Expand Up @@ -246,7 +289,7 @@ protected override void FrameUpdate(FrameEventArgs args)
else
{
var cooldown = _cooldown
? TimeSpan.FromSeconds(_cfgManager.GetCVar(CCVars.SalvageExpeditionCooldown))
? TimeSpan.FromSeconds(_cfgManager.GetCVar(CCVars.SalvageExpeditionFailedCooldown))
: TimeSpan.FromSeconds(_cfgManager.GetCVar(CCVars.SalvageExpeditionCooldown));

NextOfferBar.Value = 1f - (float) (remaining / cooldown);
Expand Down
9 changes: 6 additions & 3 deletions Content.Server/Procedural/DungeonJob.PostGen.cs
Original file line number Diff line number Diff line change
Expand Up @@ -83,14 +83,17 @@ private async Task PostGen(AutoCablingPostGen gen, Dungeon dungeon, EntityUid gr
var lastDirection = new Dictionary<Vector2i, Direction>();
costSoFar[start] = 0f;
lastDirection[start] = Direction.Invalid;
var tagQuery = _entManager.GetEntityQuery<TagComponent>();

// TODO:
// Pick a random node to start
// Then, dijkstra out from it. Add like +10 if it's a wall or smth
// When we hit another cable then mark it as found and iterate cameFrom and add to the thingie.
while (remaining.Count > 0)
{
if (frontier.Count == 0)
{
var newStart = remaining.First();
frontier.Enqueue(newStart, 0f);
lastDirection[newStart] = Direction.Invalid;
frontier.Enqueue(remaining.First(), 0f);
}

var node = frontier.Dequeue();
Expand Down
Original file line number Diff line number Diff line change
@@ -0,0 +1,16 @@
using Content.Shared.Salvage;

namespace Content.Server.Salvage.Expeditions.Structure;

/// <summary>
/// Tracks expedition data for <see cref="SalvageMissionType.Elimination"/>
/// </summary>
[RegisterComponent, Access(typeof(SalvageSystem), typeof(SpawnSalvageMissionJob))]
public sealed partial class SalvageEliminationExpeditionComponent : Component
{
/// <summary>
/// List of mobs that need to be killed for the mission to be complete.
/// </summary>
[DataField("megafauna")]
public List<EntityUid> Megafauna = new();
}
12 changes: 12 additions & 0 deletions Content.Server/Salvage/Expeditions/SalvageExpeditionComponent.cs
Original file line number Diff line number Diff line change
Expand Up @@ -49,4 +49,16 @@ public sealed partial class SalvageExpeditionComponent : SharedSalvageExpedition
{
Params = AudioParams.Default.WithVolume(-5),
};

/// <summary>
/// The difficulty this mission had or, in the future, was selected.
/// </summary>
[ViewVariables(VVAccess.ReadWrite), DataField("difficulty")]
public DifficultyRating Difficulty;

/// <summary>
/// List of items to order on mission completion
/// </summary>
[ViewVariables(VVAccess.ReadWrite), DataField("rewards", customTypeSerializer: typeof(PrototypeIdListSerializer<EntityPrototype>))]
public List<string> Rewards = default!;
}
Original file line number Diff line number Diff line change
@@ -0,0 +1,16 @@
using Content.Shared.Salvage;

namespace Content.Server.Salvage.Expeditions;

/// <summary>
/// Tracks expedition data for <see cref="SalvageMissionType.Mining"/>
/// </summary>
[RegisterComponent, Access(typeof(SalvageSystem))]
public sealed partial class SalvageMiningExpeditionComponent : Component
{
/// <summary>
/// Entities that were present on the shuttle and match the loot tax.
/// </summary>
[DataField("exemptEntities")]
public List<EntityUid> ExemptEntities = new();
}
Original file line number Diff line number Diff line change
@@ -0,0 +1,13 @@
using Content.Shared.Salvage;

namespace Content.Server.Salvage.Expeditions.Structure;

/// <summary>
/// Tracks expedition data for <see cref="SalvageMissionType.Structure"/>
/// </summary>
[RegisterComponent, Access(typeof(SalvageSystem), typeof(SpawnSalvageMissionJob))]
public sealed partial class SalvageStructureExpeditionComponent : Component
{
[DataField("structures")]
public List<EntityUid> Structures = new();
}
9 changes: 5 additions & 4 deletions Content.Server/Salvage/SalvageSystem.ExpeditionConsole.cs
Original file line number Diff line number Diff line change
@@ -1,6 +1,7 @@
using Content.Server.Station.Components;
using Content.Shared.Popups;
using Content.Shared.Procedural;
using Content.Shared.Salvage;
using Content.Shared.Salvage.Expeditions;
using Robust.Shared.Map.Components;
using Robust.Shared.Physics.Components;
Expand Down Expand Up @@ -45,17 +46,17 @@ private void OnSalvageClaimMessage(EntityUid uid, SalvageExpeditionConsoleCompon

PlayDenySound(uid, component);
_popupSystem.PopupEntity(Loc.GetString("shuttle-ftl-proximity"), uid, PopupType.MediumCaution);
UpdateConsoles((station.Value, data));
UpdateConsoles(data);
return;
}
// end of Frontier proximity check

SpawnMission(missionparams, station.Value);

data.ActiveMission = args.Index;
var mission = GetMission(_prototypeManager.Index<SalvageDifficultyPrototype>(missionparams.Difficulty), missionparams.Seed);
var mission = GetMission(missionparams.MissionType, missionparams.Difficulty, missionparams.Seed);
data.NextOffer = _timing.CurTime + mission.Duration + TimeSpan.FromSeconds(1);
UpdateConsoles((station.Value, data));
UpdateConsoles(data);
}

private void OnSalvageConsoleInit(Entity<SalvageExpeditionConsoleComponent> console, ref ComponentInit args)
Expand All @@ -68,7 +69,7 @@ private void OnSalvageConsoleParent(Entity<SalvageExpeditionConsoleComponent> co
UpdateConsole(console);
}

private void UpdateConsoles(Entity<SalvageExpeditionDataComponent> component)
private void UpdateConsoles(SalvageExpeditionDataComponent component)
{
var state = GetState(component);

Expand Down
Loading

0 comments on commit 45f77dd

Please sign in to comment.