Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

New Plant Trait : Bluespace Slips #674

Merged
merged 6 commits into from
Aug 7, 2024
Merged
Show file tree
Hide file tree
Changes from 3 commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
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.
///
dootythefrooty marked this conversation as resolved.
Show resolved Hide resolved
dootythefrooty marked this conversation as resolved.
Show resolved Hide resolved
[DataField("produceTeleportRadius")]
dootythefrooty marked this conversation as resolved.
Show resolved Hide resolved
public float ProduceTeleportRadius;

///<summary>
/// How much to divide the potency.
///
dootythefrooty marked this conversation as resolved.
Show resolved Hide resolved
dootythefrooty marked this conversation as resolved.
Show resolved Hide resolved
[DataField("potencyDivide")]
dootythefrooty marked this conversation as resolved.
Show resolved Hide resolved
public float PotencyDivide = 10f;

///<summary>
/// Potency of fruit.
///
dootythefrooty marked this conversation as resolved.
Show resolved Hide resolved
dootythefrooty marked this conversation as resolved.
Show resolved Hide resolved
[DataField("potency")]
dootythefrooty marked this conversation as resolved.
Show resolved Hide resolved
public float Potency;

///<summary>
/// Chance of deletion.
///
dootythefrooty marked this conversation as resolved.
Show resolved Hide resolved
dootythefrooty marked this conversation as resolved.
Show resolved Hide resolved
[DataField("deletionChance")]
dootythefrooty marked this conversation as resolved.
Show resolved Hide resolved
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("teleporting")] public bool Teleporting;
dootythefrooty marked this conversation as resolved.
Show resolved Hide resolved

// 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
62 changes: 62 additions & 0 deletions Content.Server/Botany/Systems/TeleportingTraitSystem.cs
Original file line number Diff line number Diff line change
@@ -0,0 +1,62 @@
using System.Numerics;
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 xform = Transform(uid);
var mapPos = _xform.GetWorldPosition(xform);
var radius = comp.ProduceTeleportRadius;
var gridBounds = new Box2(mapPos - new Vector2(radius, radius), mapPos + new Vector2(radius, radius));
var randomX = _random.NextFloat(gridBounds.Left, gridBounds.Right);
var randomY = _random.NextFloat(gridBounds.Bottom, gridBounds.Top);
//probably a better way to do this, but i have no clue at all
var otherRandomX = _random.NextFloat(gridBounds.Left, gridBounds.Right);
var otherRandomY = _random.NextFloat(gridBounds.Bottom, gridBounds.Top);
var producePos = new Vector2(randomX, randomY);
var otherPos = new Vector2(otherRandomX, otherRandomY);
_xform.SetWorldPosition(uid, producePos);
_popup.PopupEntity(Loc.GetString("teleporting-trait-component-slipped"), args.Slipped, args.Slipped, PopupType.SmallCaution);
_xform.SetWorldPosition(args.Slipped, otherPos);
dootythefrooty marked this conversation as resolved.
Show resolved Hide resolved
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;
QueueDel(uid);
Solution vanishSolution = new();
vanishSolution.AddReagent("Slime", comp.Potency / 2);
_puddle.TrySpillAt(uid, vanishSolution, out _);
dootythefrooty marked this conversation as resolved.
Show resolved Hide resolved
}
}

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