-
Notifications
You must be signed in to change notification settings - Fork 146
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
New Plant Trait : Bluespace Slips (#674)
# Description Adds a new trait which plants can mutate to have. It teleports both the slippee and the produce to a random location within a radius determined by how potent the produce is. Inert unless the plant also has the slippery trait. ~~Probably very stinky code considering this is my first time dealing with c#.~~ --- <details><summary><h1>Media</h1></summary> <p> https://github.com/user-attachments/assets/cd22756d-ea5e-4a30-8043-c991549c9019 </p> </details> --- # Changelog :cl: - add: Added Bluespace Slips, a plant trait that teleports you randomly if you slip.
- Loading branch information
1 parent
7ef43ac
commit f2e6d1a
Showing
6 changed files
with
99 additions
and
3 deletions.
There are no files selected for viewing
31 changes: 31 additions & 0 deletions
31
Content.Server/Botany/Components/TeleportingTraitComponent.cs
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,31 @@ | ||
namespace Content.Server.Botany | ||
{ | ||
[RegisterComponent] | ||
|
||
public sealed partial class TeleportingTraitComponent : Component | ||
{ | ||
/// <summary> | ||
/// Teleportation radius of produce. | ||
/// </summary> | ||
[DataField] | ||
public float ProduceTeleportRadius; | ||
|
||
/// <summary> | ||
/// How much to divide the potency. | ||
/// </summary> | ||
[DataField] | ||
public float PotencyDivide = 10f; | ||
|
||
/// <summary> | ||
/// Potency of fruit. | ||
/// </summary> | ||
[DataField] | ||
public float Potency; | ||
|
||
/// <summary> | ||
/// Chance of deletion. | ||
/// </summary> | ||
[DataField] | ||
public float DeletionChance = .5f; | ||
} | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,51 @@ | ||
using Robust.Shared.Random; | ||
using Content.Shared.Slippery; | ||
using Content.Server.Fluids.EntitySystems; | ||
using Content.Shared.Chemistry.Components; | ||
using Content.Shared.Popups; | ||
|
||
namespace Content.Server.Botany.Systems; | ||
|
||
public sealed class TeleportingTraitSystem : EntitySystem | ||
{ | ||
[Dependency] private readonly SharedTransformSystem _xform = default!; | ||
[Dependency] private readonly IRobustRandom _random = default!; | ||
[Dependency] private readonly SharedPopupSystem _popup = default!; | ||
[Dependency] private readonly PuddleSystem _puddle = default!; | ||
|
||
public override void Initialize() | ||
{ | ||
base.Initialize(); | ||
|
||
SubscribeLocalEvent<TeleportingTraitComponent, SlipEvent>(Teleport); | ||
} | ||
|
||
// sets the potency and the radius | ||
public static void SetPotencyRadius(float seedPotency, TeleportingTraitComponent comp) | ||
{ | ||
comp.Potency = seedPotency; | ||
comp.ProduceTeleportRadius = comp.Potency / comp.PotencyDivide; | ||
} | ||
|
||
// teleports both the produce and the foolish fool who slipped on it to a random postion limited by the radius | ||
private void Teleport(EntityUid uid, TeleportingTraitComponent comp, ref SlipEvent args) | ||
{ | ||
var coordinates = Transform(uid).Coordinates; | ||
_xform.SetCoordinates(uid, coordinates.Offset(_random.NextVector2(comp.ProduceTeleportRadius))); | ||
_popup.PopupEntity(Loc.GetString("teleporting-trait-component-slipped"), args.Slipped, args.Slipped, PopupType.SmallCaution); | ||
_xform.SetCoordinates(args.Slipped, coordinates.Offset(_random.NextVector2(comp.ProduceTeleportRadius))); | ||
VanishProbablity(uid, comp); | ||
} | ||
|
||
// chance of being deleted and then spawnin the goop | ||
private void VanishProbablity(EntityUid uid, TeleportingTraitComponent comp) | ||
{ | ||
if (!_random.Prob(comp.DeletionChance)) | ||
return; | ||
Solution vanishSolution = new(); | ||
vanishSolution.AddReagent("Slime", comp.Potency / 2); | ||
_puddle.TrySpillAt(uid, vanishSolution, out _); | ||
QueueDel(uid); | ||
} | ||
} | ||
|
1 change: 1 addition & 0 deletions
1
Resources/Locale/en-US/botany/components/teleporting-trait-component.ftl
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1 @@ | ||
teleporting-trait-component-slipped = You slip through bluespace! |