Skip to content

Commit

Permalink
Bluespace lockers update (#13469)
Browse files Browse the repository at this point in the history
  • Loading branch information
Chief-Engineer authored and Elijahrane committed Jan 18, 2023
1 parent 6cdd0a9 commit bf8dce6
Show file tree
Hide file tree
Showing 6 changed files with 168 additions and 44 deletions.
11 changes: 6 additions & 5 deletions Content.Server/StationEvents/Events/BluespaceLocker.cs
Original file line number Diff line number Diff line change
Expand Up @@ -2,6 +2,7 @@
using Content.Server.Resist;
using Content.Server.Station.Components;
using Content.Server.Storage.Components;
using Content.Server.Storage.EntitySystems;
using Content.Shared.Access.Components;
using Content.Shared.Coordinates;
using Robust.Shared.Random;
Expand All @@ -11,6 +12,7 @@ namespace Content.Server.StationEvents.Events;
public sealed class BluespaceLockerLink : StationEventSystem
{
[Dependency] private readonly IRobustRandom _robustRandom = default!;
[Dependency] private readonly BluespaceLockerSystem _bluespaceLocker = default!;

public override string Prototype => "BluespaceLockerLink";

Expand All @@ -30,18 +32,17 @@ public override void Started()
!HasComp<StationMemberComponent>(potentialLink.ToCoordinates().GetGridUid(EntityManager)))
continue;

using var compInitializeHandle = EntityManager.AddComponentUninitialized<BluespaceLockerComponent>(potentialLink);
var comp = compInitializeHandle.Comp;
var comp = AddComp<BluespaceLockerComponent>(potentialLink);

comp.PickLinksFromSameMap = true;
comp.MinBluespaceLinks = 1;
comp.BluespaceEffectOnInit = true;
comp.BehaviorProperties.BluespaceEffectOnTeleportSource = true;
comp.AutoLinksBidirectional = true;
comp.AutoLinksUseProperties = true;
comp.AutoLinkProperties.BluespaceEffectOnInit = true;
comp.AutoLinkProperties.BluespaceEffectOnTeleportSource = true;

compInitializeHandle.Dispose();
_bluespaceLocker.GetTarget(potentialLink, comp);
_bluespaceLocker.BluespaceEffect(potentialLink, comp, comp, true);

Sawmill.Info($"Converted {ToPrettyString(potentialLink)} to bluespace locker");

Expand Down
53 changes: 47 additions & 6 deletions Content.Server/Storage/Components/BluespaceLockerComponent.cs
Original file line number Diff line number Diff line change
Expand Up @@ -57,12 +57,6 @@ public sealed class BluespaceLockerComponent : Component

public CancellationTokenSource? CancelToken;

/// <summary>
/// Determines if bluespace effect is show on component init
/// </summary>
[DataField("bluespaceEffectOnInit")]
public bool BluespaceEffectOnInit;

/// <summary>
/// Determines if links automatically added get the source locker set as a target
/// </summary>
Expand All @@ -75,8 +69,12 @@ public sealed class BluespaceLockerComponent : Component
[DataField("autoLinksUseProperties"), ViewVariables(VVAccess.ReadWrite)]
public bool AutoLinksUseProperties;

[DataField("usesSinceLinkClear"), ViewVariables(VVAccess.ReadWrite)]
public int UsesSinceLinkClear;

[DataField("bluespaceEffectMinInterval"), ViewVariables(VVAccess.ReadOnly)]
public uint BluespaceEffectNextTime { get; set; }

/// <summary>
/// Determines properties of automatically created links
/// </summary>
Expand Down Expand Up @@ -111,12 +109,30 @@ public record BluespaceLockerBehaviorProperties
[DataField("transportSentient"), ViewVariables(VVAccess.ReadWrite)]
public bool TransportSentient { get; set; } = true;

/// <summary>
/// Determines if the the locker will act on opens.
/// </summary>
[DataField("actOnOpen"), ViewVariables(VVAccess.ReadWrite)]
public bool ActOnOpen { get; set; } = true;

/// <summary>
/// Determines if the the locker will act on closes.
/// </summary>
[DataField("actOnClose"), ViewVariables(VVAccess.ReadWrite)]
public bool ActOnClose { get; set; } = true;

/// <summary>
/// Delay to wait after closing before transporting
/// </summary>
[DataField("delay"), ViewVariables(VVAccess.ReadWrite)]
public float Delay { get; set; }

/// <summary>
/// Determines if bluespace effect is show on component init
/// </summary>
[DataField("bluespaceEffectOnInit"), ViewVariables(VVAccess.ReadWrite)]
public bool BluespaceEffectOnInit;

/// <summary>
/// Defines prototype to spawn for bluespace effect
/// </summary>
Expand All @@ -135,12 +151,25 @@ public record BluespaceLockerBehaviorProperties
[DataField("bluespaceEffectOnTeleportTarget"), ViewVariables(VVAccess.ReadWrite)]
public bool BluespaceEffectOnTeleportTarget { get; set; }

/// <summary>
/// Determines the minimum interval between bluespace effects
/// </summary>
/// <seealso cref="BluespaceEffectPrototype"/>
[DataField("bluespaceEffectMinInterval"), ViewVariables(VVAccess.ReadWrite)]
public double BluespaceEffectMinInterval { get; set; } = 2;

/// <summary>
/// Uses left before the locker is destroyed. -1 indicates infinite
/// </summary>
[DataField("destroyAfterUses"), ViewVariables(VVAccess.ReadWrite)]
public int DestroyAfterUses { get; set; } = -1;

/// <summary>
/// Minimum number of entities that must be transported to count a use for <see cref="DestroyAfterUses"/>
/// </summary>
[DataField("destroyAfterUsesMinItemsToCountUse"), ViewVariables(VVAccess.ReadWrite)]
public int DestroyAfterUsesMinItemsToCountUse { get; set; }

/// <summary>
/// How to destroy the locker after it runs out of uses
/// </summary>
Expand All @@ -152,6 +181,18 @@ public record BluespaceLockerBehaviorProperties
/// </summary>
[DataField("clearLinksEvery"), ViewVariables(VVAccess.ReadWrite)]
public int ClearLinksEvery { get; set; } = -1;

/// <summary>
/// Determines if cleared links have their component removed
/// </summary>
[DataField("clearLinksDebluespaces"), ViewVariables(VVAccess.ReadWrite)]
public bool ClearLinksDebluespaces { get; set; }

/// <summary>
/// Links will not be valid if they're not bidirectional
/// </summary>
[DataField("invalidateOneWayLinks"), ViewVariables(VVAccess.ReadWrite)]
public bool InvalidateOneWayLinks { get; set; }
}

[Flags]
Expand Down
Loading

0 comments on commit bf8dce6

Please sign in to comment.