Skip to content

Commit

Permalink
syndie cache
Browse files Browse the repository at this point in the history
  • Loading branch information
Cheackraze committed Aug 22, 2023
1 parent 16342d1 commit f063aef
Show file tree
Hide file tree
Showing 5 changed files with 5,112 additions and 15 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -23,4 +23,16 @@ public sealed class BluespaceErrorRuleComponent : Component
/// </summary>
[DataField("rewardFactor")]
public float RewardFactor = 0f;

/// <summary>
/// The grid in question, set after starting the event
/// </summary>
[DataField("gridUid")]
public EntityUid? GridUid = null;

/// <summary>
/// How much the grid is appraised at upon entering into existance, set after starting the event
/// </summary>
[DataField("startingValue")]
public double startingValue = 0;
}
25 changes: 14 additions & 11 deletions Content.Server/StationEvents/Events/BluespaceErrorRule.cs
Original file line number Diff line number Diff line change
Expand Up @@ -23,9 +23,8 @@ public sealed class BluespaceErrorRule : StationEventSystem<BluespaceErrorRuleCo
[Dependency] private readonly PricingSystem _pricing = default!;
[Dependency] private readonly CargoSystem _cargo = default!;

private EntityUid _objective = new();

protected override void Started(EntityUid uid, BluespaceErrorRuleComponent component, GameRuleComponent gameRule, GameRuleStartedEvent args)
protected override void Started(EntityUid uid, BluespaceErrorRuleComponent component, GameRuleComponent gameRule,
GameRuleStartedEvent args)
{
base.Started(uid, component, gameRule, args);

Expand All @@ -37,15 +36,18 @@ protected override void Started(EntityUid uid, BluespaceErrorRuleComponent compo

if (!_map.TryLoad(shuttleMap, component.GridPath, out var gridUids, options))
return;
_objective = gridUids[0];
_shuttle.SetIFFColor(_objective, component.Color);
component.GridUid = gridUids[0];
if (component.GridUid is not EntityUid gridUid)
return;
component.startingValue = _pricing.AppraiseGrid(gridUid);
_shuttle.SetIFFColor(gridUid, component.Color);
var offset = _random.NextVector2(1350f, 2200f);
var mapId = GameTicker.DefaultMap;
var coords = new MapCoordinates(offset, mapId);
var location = Spawn(null, coords);
if (TryComp<ShuttleComponent>(_objective, out var shuttle))
if (TryComp<ShuttleComponent>(component.GridUid, out var shuttle))
{
_shuttle.FTLTravel(_objective, shuttle, location, 5.5f, 55f);
_shuttle.FTLTravel(gridUid, shuttle, location, 5.5f, 55f);
}

}
Expand All @@ -54,18 +56,19 @@ protected override void Ended(EntityUid uid, BluespaceErrorRuleComponent compone
{
base.Ended(uid, component, gameRule, args);

if(!EntityManager.TryGetComponent<TransformComponent>(_objective, out var gridTransform))
if(!EntityManager.TryGetComponent<TransformComponent>(component.GridUid, out var gridTransform))
{
Log.Error("bluespace error objective was missing transform component");
return;
}

if (gridTransform.GridUid == null)
if (gridTransform.GridUid is not EntityUid gridUid)
{
Log.Error( "bluespace error has no associated grid?");
return;
}
var gridValue = _pricing.AppraiseGrid(_objective, null);

var gridValue = _pricing.AppraiseGrid(gridUid, null);
foreach (var player in Filter.Empty().AddInGrid(gridTransform.GridUid.Value, EntityManager).Recipients)
{
if (player.AttachedEntity.HasValue)
Expand All @@ -80,7 +83,7 @@ protected override void Ended(EntityUid uid, BluespaceErrorRuleComponent compone
}
}
// Deletion has to happen before grid traversal re-parents players.
Del(_objective);
Del(gridUid);
var query = EntityQuery<StationBankAccountComponent>();
foreach (var account in query)
{
Expand Down
5 changes: 4 additions & 1 deletion Resources/Locale/en-US/_NF/bluespace-events/events.ftl
Original file line number Diff line number Diff line change
@@ -1,2 +1,5 @@
station-event-bluespace-vault-start-announcement = A NanoTrasen autonomous armored vault transport has made an FTL error and will arrive nearby. Your sector will be rewarded for it's safe return.
station-event-bluespace-vault-end-announcement = We have successfully retrieved the vault from your sector and have re-imbursed your nearby Frontier Outpost accordingly.
station-event-bluespace-vault-end-announcement = We have successfully retrieved the vault from your sector and have reimbursed your nearby Frontier Outpost accordingly.
station-event-bluespace-cache-start-announcement = A Syndicate transport has been intercepted from FTL and will be arriving nearby. Guard the armored weapons cache until NanoTrasen can retrieve it.
station-event-bluespace-cache-end-announcement = We have successfully retrieved the Syndicate weapons cache from your sector and have reimbursed your nearby Frontier Outpost accordingly.
Loading

0 comments on commit f063aef

Please sign in to comment.