Skip to content

Commit

Permalink
New Plant Trait : Bluespace Slips (#674)
Browse files Browse the repository at this point in the history
# 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
dootythefrooty authored Aug 7, 2024
1 parent 7ef43ac commit f2e6d1a
Show file tree
Hide file tree
Showing 6 changed files with 99 additions and 3 deletions.
31 changes: 31 additions & 0 deletions Content.Server/Botany/Components/TeleportingTraitComponent.cs
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;
}
}
8 changes: 7 additions & 1 deletion Content.Server/Botany/SeedPrototype.cs
Original file line number Diff line number Diff line change
Expand Up @@ -205,6 +205,11 @@ public partial class SeedData
/// </summary>
[DataField("ligneous")] public bool Ligneous;

/// <summary>
/// If true, teleports both fruit and player if slippable.
/// </summary>
[DataField] public bool Teleporting;

// No, I'm not removing these.
// if you re-add these, make sure that they get cloned.
//public PlantSpread Spread { get; set; }
Expand All @@ -215,7 +220,6 @@ public partial class SeedData
//public bool Hematophage { get; set; }
//public bool Thorny { get; set; }
//public bool Stinging { get; set; }
// public bool Teleporting { get; set; }
// public PlantJuicy Juicy { get; set; }

#endregion
Expand Down Expand Up @@ -295,6 +299,7 @@ public SeedData Clone()
Slip = Slip,
Sentient = Sentient,
Ligneous = Ligneous,
Teleporting = Teleporting,

PlantRsi = PlantRsi,
PlantIconState = PlantIconState,
Expand Down Expand Up @@ -358,6 +363,7 @@ public SeedData SpeciesChange(SeedData other)
Slip = Slip,
Sentient = Sentient,
Ligneous = Ligneous,
Teleporting = Teleporting,

PlantRsi = other.PlantRsi,
PlantIconState = other.PlantIconState,
Expand Down
5 changes: 5 additions & 0 deletions Content.Server/Botany/Systems/BotanySystem.Seed.cs
Original file line number Diff line number Diff line change
Expand Up @@ -207,6 +207,11 @@ public IEnumerable<EntityUid> GenerateProduct(SeedData proto, EntityCoordinates
var collisionWake = EnsureComp<CollisionWakeComponent>(entity);
_colWakeSystem.SetEnabled(entity, false, collisionWake);
}
if (proto.Teleporting)
{
var teleporting = EnsureComp<TeleportingTraitComponent>(entity);
TeleportingTraitSystem.SetPotencyRadius(proto.Potency, teleporting);
}
}

return products;
Expand Down
6 changes: 4 additions & 2 deletions Content.Server/Botany/Systems/MutationSystem.cs
Original file line number Diff line number Diff line change
Expand Up @@ -40,7 +40,7 @@ public void MutateSeed(ref SeedData seed, float severity)
}

// Add up everything in the bits column and put the number here.
const int totalbits = 275;
const int totalbits = 285;

// Tolerances (55)
MutateFloat(ref seed.NutrientConsumption , 0.05f, 1.2f, 5, totalbits, severity);
Expand All @@ -66,11 +66,12 @@ public void MutateSeed(ref SeedData seed, float severity)
// Kill the plant (30)
MutateBool(ref seed.Viable , false, 30, totalbits, severity);

// Fun (90)
// Fun (100)
MutateBool(ref seed.Seedless , true , 10, totalbits, severity);
MutateBool(ref seed.Slip , true , 10, totalbits, severity);
MutateBool(ref seed.Sentient , true , 10, totalbits, severity);
MutateBool(ref seed.Ligneous , true , 10, totalbits, severity);
MutateBool(ref seed.Teleporting , true , 10, totalbits, severity);
MutateBool(ref seed.Bioluminescent, true , 10, totalbits, severity);
MutateBool(ref seed.TurnIntoKudzu , true , 10, totalbits, severity);
MutateBool(ref seed.CanScream , true , 10, totalbits, severity);
Expand Down Expand Up @@ -120,6 +121,7 @@ public SeedData Cross(SeedData a, SeedData b)
CrossBool(ref result.Slip, a.Slip);
CrossBool(ref result.Sentient, a.Sentient);
CrossBool(ref result.Ligneous, a.Ligneous);
CrossBool(ref result.Teleporting, a.Teleporting);
CrossBool(ref result.Bioluminescent, a.Bioluminescent);
CrossBool(ref result.TurnIntoKudzu, a.TurnIntoKudzu);
CrossBool(ref result.CanScream, a.CanScream);
Expand Down
51 changes: 51 additions & 0 deletions Content.Server/Botany/Systems/TeleportingTraitSystem.cs
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);
}
}

Original file line number Diff line number Diff line change
@@ -0,0 +1 @@
teleporting-trait-component-slipped = You slip through bluespace!

0 comments on commit f2e6d1a

Please sign in to comment.