Skip to content

Commit

Permalink
Merge pull request Simple-Station#106 from Fansana/Suacy_Sauces
Browse files Browse the repository at this point in the history
Fixed Cum/Milk Generation
  • Loading branch information
FoxxoTrystan authored Aug 15, 2024
2 parents e52c717 + 5b40e99 commit f97a135
Show file tree
Hide file tree
Showing 4 changed files with 70 additions and 58 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -12,10 +12,10 @@ namespace Content.Server.FloofStation.Traits;
[RegisterComponent, Access(typeof(LewdTraitSystem))]
public sealed partial class CumProducerComponent : Component
{
[DataField("solutionname"), ViewVariables(VVAccess.ReadWrite)]
public string SolutionName;
[DataField("solutionname")]
public string SolutionName = "penis";

[DataField, ViewVariables(VVAccess.ReadWrite)]
[DataField]
public ProtoId<ReagentPrototype> ReagentId = "Cum";

[DataField]
Expand All @@ -24,14 +24,14 @@ public sealed partial class CumProducerComponent : Component
[DataField]
public Entity<SolutionComponent>? Solution = null;

[DataField, ViewVariables(VVAccess.ReadOnly)]
public FixedPoint2 QuantityPerUpdate = 25;
[DataField]
public FixedPoint2 QuantityPerUpdate = 5;

[DataField]
public float HungerUsage = 10f;

[DataField]
public TimeSpan GrowthDelay = TimeSpan.FromMinutes(1);
public TimeSpan GrowthDelay = TimeSpan.FromSeconds(10);

[DataField(customTypeSerializer: typeof(TimeOffsetSerializer))]
public TimeSpan NextGrowth = TimeSpan.FromSeconds(0);
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -12,26 +12,26 @@ namespace Content.Server.FloofStation.Traits;
[RegisterComponent, Access(typeof(LewdTraitSystem))]
public sealed partial class MilkProducerComponent : Component
{
[DataField("solutionname"), ViewVariables(VVAccess.ReadWrite)]
public string SolutionName;
[DataField("solutionname")]
public string SolutionName = "breasts";

[DataField, ViewVariables(VVAccess.ReadWrite)]
[DataField]
public ProtoId<ReagentPrototype> ReagentId = "Milk";

[DataField]
public FixedPoint2 MaxVolume = FixedPoint2.New(25);
public FixedPoint2 MaxVolume = FixedPoint2.New(50);

[DataField]
public Entity<SolutionComponent>? Solution = null;

[DataField, ViewVariables(VVAccess.ReadOnly)]
public FixedPoint2 QuantityPerUpdate = 25;
[DataField]
public FixedPoint2 QuantityPerUpdate = 5;

[DataField]
public float HungerUsage = 10f;

[DataField]
public TimeSpan GrowthDelay = TimeSpan.FromMinutes(1);
public TimeSpan GrowthDelay = TimeSpan.FromSeconds(10);

[DataField(customTypeSerializer: typeof(TimeOffsetSerializer))]
public TimeSpan NextGrowth = TimeSpan.FromSeconds(0);
Expand Down
94 changes: 53 additions & 41 deletions Content.Server/FloofStation/Traits/LewdTraitSystem.cs
Original file line number Diff line number Diff line change
Expand Up @@ -268,61 +268,73 @@ private void AttemptMilk(Entity<MilkProducerComponent> lewd, EntityUid userUid,
public override void Update(float frameTime)
{
base.Update(frameTime);

var queryCum = EntityQueryEnumerator<CumProducerComponent>(); //SquirtProducerComponent -unused ,
var queryMilk = EntityQueryEnumerator<MilkProducerComponent>();
var now = _timing.CurTime;
var query = AllEntityQuery<CumProducerComponent, MilkProducerComponent>(); //SquirtProducerComponent -unused

while (query.MoveNext(out var uid, out var containerCum, out var containerMilk)) // out var containerSquirt -unused
while (queryCum.MoveNext(out var uid, out var containerCum))
{
if (now < containerCum.NextGrowth)
continue;

containerCum.NextGrowth = now + containerCum.GrowthDelay;

if (_mobState.IsDead(uid))
continue;

if (!(now < containerCum.NextGrowth))
if (EntityManager.TryGetComponent(uid, out HungerComponent? hunger))
{
containerCum.NextGrowth = now + containerCum.GrowthDelay;

// Actually there is food digestion so no problem with instant reagent generation "OnFeed"
if (EntityManager.TryGetComponent(uid, out HungerComponent? hunger))
{
// Is there enough nutrition to produce reagent?
if (!(_hunger.GetHungerThreshold(hunger) < HungerThreshold.Okay))
_hunger.ModifyHunger(uid, -containerCum.HungerUsage, hunger);
}

if (_solutionContainer.ResolveSolution(uid, containerCum.SolutionName, ref containerCum.Solution))
_solutionContainer.TryAddReagent(containerCum.Solution.Value, containerCum.ReagentId, containerCum.QuantityPerUpdate, out _);
if (_hunger.GetHungerThreshold(hunger) < HungerThreshold.Okay)
continue;

_hunger.ModifyHunger(uid, -containerCum.HungerUsage, hunger);
}

if (!(now < containerMilk.NextGrowth))
{
containerMilk.NextGrowth = now + containerMilk.GrowthDelay;
if (!_solutionContainer.ResolveSolution(uid, containerCum.SolutionName, ref containerCum.Solution))
continue;

_solutionContainer.TryAddReagent(containerCum.Solution.Value, containerCum.ReagentId, containerCum.QuantityPerUpdate, out _);
}

while (queryMilk.MoveNext(out var uid, out var containerMilk))
{
if (now < containerMilk.NextGrowth)
continue;

containerMilk.NextGrowth = now + containerMilk.GrowthDelay;

if (_mobState.IsDead(uid))
continue;

if (EntityManager.TryGetComponent(uid, out HungerComponent? hunger))
{
if (!(_hunger.GetHungerThreshold(hunger) < HungerThreshold.Okay))
_hunger.ModifyHunger(uid, -containerMilk.HungerUsage, hunger);
}
if (EntityManager.TryGetComponent(uid, out HungerComponent? hunger))
{
if (_hunger.GetHungerThreshold(hunger) < HungerThreshold.Okay)
continue;

if (_solutionContainer.ResolveSolution(uid, containerMilk.SolutionName, ref containerMilk.Solution))
_solutionContainer.TryAddReagent(containerMilk.Solution.Value, containerMilk.ReagentId, containerMilk.QuantityPerUpdate, out _);
_hunger.ModifyHunger(uid, -containerMilk.HungerUsage, hunger);
}

//if (!(now < containerSquirt.NextGrowth)) //Unused-Trait is WIP
//{
// containerSquirt.NextGrowth = now + containerSquirt.GrowthDelay;

//
// if (EntityManager.TryGetComponent(uid, out HungerComponent? hunger))
// {
//
// if (!(_hunger.GetHungerThreshold(hunger) < HungerThreshold.Okay))
// _hunger.ModifyHunger(uid, -containerSquirt.HungerUsage, hunger);
// }

// if (_solutionContainer.ResolveSolution(uid, containerSquirt.SolutionName, ref containerSquirt.Solution))
// _solutionContainer.TryAddReagent(containerSquirt.Solution.Value, containerSquirt.ReagentId, containerSquirt.QuantityPerUpdate, out _);
//}
if (!_solutionContainer.ResolveSolution(uid, containerMilk.SolutionName, ref containerMilk.Solution))
continue;

_solutionContainer.TryAddReagent(containerMilk.Solution.Value, containerMilk.ReagentId, containerMilk.QuantityPerUpdate, out _);
}

//if (!(now < containerSquirt.NextGrowth)) //Unused-Trait is WIP
//{
// containerSquirt.NextGrowth = now + containerSquirt.GrowthDelay;

//
// if (EntityManager.TryGetComponent(uid, out HungerComponent? hunger))
// {
//
// if (!(_hunger.GetHungerThreshold(hunger) < HungerThreshold.Okay))
// _hunger.ModifyHunger(uid, -containerSquirt.HungerUsage, hunger);
// }

// if (_solutionContainer.ResolveSolution(uid, containerSquirt.SolutionName, ref containerSquirt.Solution))
// _solutionContainer.TryAddReagent(containerSquirt.Solution.Value, containerSquirt.ReagentId, containerSquirt.QuantityPerUpdate, out _);
//}
}
#endregion
}
Original file line number Diff line number Diff line change
Expand Up @@ -13,10 +13,10 @@
- type: SolutionContainerManager
solutions:
penis:
maxVol: 250
maxVol: 25
reagents:
- ReagentId: Cum
Quantity: 30
Quantity: 25

- type: trait
id: MilkProducer
Expand All @@ -33,10 +33,10 @@
- type: SolutionContainerManager
solutions:
breasts:
maxVol: 250
maxVol: 50
reagents:
- ReagentId: Milk
Quantity: 30
Quantity: 50

# WIP - Needs a Reagent
# - type: trait
Expand Down

0 comments on commit f97a135

Please sign in to comment.