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

Фикс александра #936

Closed
wants to merge 18 commits into from
Closed
28 changes: 28 additions & 0 deletions Content.Server/Bible/BibleSystem.cs
Original file line number Diff line number Diff line change
@@ -1,18 +1,21 @@
using Content.Server.Bible.Components;
using Content.Server.Ghost.Roles.Events;
using Content.Server.Popups;
using Content.Server.Saw;
using Content.Shared._Sunrise.Mood;
using Content.Shared.ActionBlocker;
using Content.Shared.Actions;
using Content.Shared.Bible;
using Content.Shared.Damage;
using Content.Shared.Ghost.Roles.Components;
using Content.Shared.IdentityManagement;
using Content.Shared.IdentityManagement.Components;
using Content.Shared.Interaction;
using Content.Shared.Inventory;
using Content.Shared.Mobs;
using Content.Shared.Mobs.Systems;
using Content.Shared.Popups;
using Content.Shared.Prayer;
using Content.Shared.Stunnable;
using Content.Shared.Timing;
using Content.Shared.Vampire.Components;
Expand All @@ -21,13 +24,17 @@
using Robust.Shared.Audio.Systems;
using Robust.Shared.Containers;
using Robust.Shared.Player;
using Robust.Shared.Prototypes;
using Robust.Shared.Random;
using Robust.Shared.Timing;
using System.Linq;

namespace Content.Server.Bible
{
public sealed class BibleSystem : EntitySystem
{
[Dependency] private readonly IPrototypeManager _prototypeManager = default!;
[Dependency] private readonly IEntityManager _entityManager = default!;
[Dependency] private readonly IRobustRandom _random = default!;
[Dependency] private readonly ActionBlockerSystem _blocker = default!;
[Dependency] private readonly DamageableSystem _damageableSystem = default!;
Expand All @@ -39,6 +46,8 @@ public sealed class BibleSystem : EntitySystem
[Dependency] private readonly UseDelaySystem _delay = default!;
[Dependency] private readonly SharedTransformSystem _transform = default!;
[Dependency] private readonly SharedStunSystem _stun = default!;
[Dependency] private readonly EntityLookupSystem _lookUp = default!;
[Dependency] private readonly MetaDataSystem _metaData = default!;

public override void Initialize()
{
Expand Down Expand Up @@ -150,6 +159,25 @@ private void OnAfterInteract(EntityUid uid, BibleComponent component, AfterInter
return;
}

//Sunrise-start

if (TryPrototype((EntityUid) args.Target, out var prototype)
&& (prototype.ID == "MobPig" || (prototype.Parents != null && prototype.Parents.Contains<string>("MobPig")))
&& !HasComp<SawComponent>(args.Target))
{
if (_lookUp.GetEntitiesInRange<IdentityComponent>(Transform(uid).Coordinates, 5).Count >= 5
&& _lookUp.GetEntitiesInRange<PrayableComponent>(Transform(uid).Coordinates, 5).Count >= 2)
{
_entityManager.AddComponents((EntityUid) args.Target, _prototypeManager.Index("MobSaw").Components, false);
_metaData.SetEntityName((EntityUid)args.Target, "свиноматерь");
_popupSystem.PopupEntity(Loc.GetString("bible-saw-transformation"), (EntityUid) args.Target);
_audio.PlayPvs(component.HealSoundPath, (EntityUid) args.Target);
}
return;
}

//Sunrise-end

// This only has a chance to fail if the target is not wearing anything on their head and is not a familiar..
if (!_invSystem.TryGetSlotEntity(args.Target.Value, "head", out var _) && !HasComp<FamiliarComponent>(args.Target.Value))
{
Expand Down
10 changes: 10 additions & 0 deletions Content.Server/Body/Components/StomachComponent.cs
Original file line number Diff line number Diff line change
Expand Up @@ -47,6 +47,16 @@ public sealed partial class StomachComponent : Component
[DataField]
public EntityWhitelist? SpecialDigestible = null;

//Sunrise-start

/// <summary>
/// If true, whitelist from the top will only be used as an addition to the already digestible by default food
/// </summary>
[DataField]
public bool IsDigestibleAddition = false;

//Sunrise-end

/// <summary>
/// Used to track how long each reagent has been in the stomach
/// </summary>
Expand Down
14 changes: 14 additions & 0 deletions Content.Server/FaceCast/FaceCastComponent.cs
Original file line number Diff line number Diff line change
@@ -0,0 +1,14 @@

using Content.Shared.FixedPoint;

namespace Content.Server.FaceCast;

[RegisterComponent]
public sealed partial class FaceCastComponent : Component
{
public TimeSpan? StartCastingTime = null;

public EntityUid? Equiper = null;

public Double TimeToCast = 5;
}
69 changes: 69 additions & 0 deletions Content.Server/FaceCast/FaceCastSystem.cs
Original file line number Diff line number Diff line change
@@ -0,0 +1,69 @@
using Content.Shared.Inventory.Events;
using Robust.Shared.Timing;
using Content.Shared.IdentityManagement.Components;
using Content.Shared.Clothing.Components;
using Content.Shared.Inventory;
using Content.Shared.Nutrition.AnimalHusbandry;

namespace Content.Server.FaceCast;

public sealed class FaceCastSystem : EntitySystem
{
[Dependency] private readonly IGameTiming _timing = default!;
[Dependency] private readonly MetaDataSystem _metaData = default!;
[Dependency] private readonly InventorySystem _inventory = default!;
public override void Initialize()
{
SubscribeLocalEvent<FaceCastComponent, GotEquippedEvent>(OnEquip);
SubscribeLocalEvent<FaceCastComponent, GotUnequippedEvent>(OnUnequip);
}

private void OnEquip(EntityUid ent, FaceCastComponent faceCast, ref GotEquippedEvent args)
{
if (!HasComp<IdentityComponent>(args.Equipee))
return;
faceCast.Equiper = args.Equipee;
if (HasComp<InfantComponent>(args.Equipee))
return;
faceCast.StartCastingTime = _timing.CurTime;
}

private void OnUnequip(EntityUid ent, FaceCastComponent faceCast, ref GotUnequippedEvent args)
{
faceCast.StartCastingTime = null;
faceCast.Equiper = null;
}

public override void Update(float frameTime)
{
base.Update(frameTime);

var query = EntityQueryEnumerator<FaceCastComponent>();
while (query.MoveNext(out var uid, out var faceCast))
{
if (!TryComp<ClothingComponent>(uid, out var cloth))
continue;

if (faceCast.Equiper == null)
continue;

if (!HasComp<InfantComponent>(faceCast.Equiper) && faceCast.StartCastingTime == null)
{
if (Name(uid) != Loc.GetEntityData("ClothingMaskFaceCast").Name)
_metaData.SetEntityName((EntityUid) faceCast.Equiper, Name(uid));
faceCast.StartCastingTime = _timing.CurTime;
continue;
}

if (faceCast.StartCastingTime == null)
continue;

if ((_timing.CurTime - faceCast.StartCastingTime) >= TimeSpan.FromSeconds(faceCast.TimeToCast))
{
_metaData.SetEntityName(uid, Name((EntityUid)faceCast.Equiper));
faceCast.StartCastingTime = _timing.CurTime;
}

}
}
}
20 changes: 18 additions & 2 deletions Content.Server/Nutrition/EntitySystems/AnimalHusbandrySystem.cs
Original file line number Diff line number Diff line change
Expand Up @@ -76,6 +76,9 @@ public bool TryReproduceNearby(EntityUid uid, ReproductiveComponent? component =
if (partners.Count >= component.Capacity)
return false;

if (!component.IsPartnerNeed) //Sunrise
return TryReproduce(uid, uid, component); //Sunrise

foreach (var comp in partners)
{
var partner = comp.Owner;
Expand All @@ -98,13 +101,13 @@ public bool TryReproduce(EntityUid uid, EntityUid partner, ReproductiveComponent
if (!Resolve(uid, ref component))
return false;

if (uid == partner)
if (uid == partner && component.IsPartnerNeed) //Sunrise: component.IsPartnerNeed
return false;

if (!CanReproduce(uid, component))
return false;

if (!IsValidPartner(uid, partner, component))
if (!IsValidPartner(uid, partner, component) && component.IsPartnerNeed) //Sunrise: component.IsPartnerNeed
return false;

// if the partner is valid, yet it fails the random check
Expand Down Expand Up @@ -181,6 +184,8 @@ public void Birth(EntityUid uid, ReproductiveComponent? component = null)
if (!Resolve(uid, ref component))
return;

BirthEvent birthEvent = new BirthEvent(); //Sunrise

// this is kinda wack but it's the only sound associated with most animals
if (TryComp<InteractionPopupComponent>(uid, out var interactionPopup))
_audio.PlayPvs(interactionPopup.InteractSuccessSound, uid);
Expand All @@ -190,6 +195,7 @@ public void Birth(EntityUid uid, ReproductiveComponent? component = null)
foreach (var spawn in spawns)
{
var offspring = Spawn(spawn, xform.Coordinates.Offset(_random.NextVector2(0.3f)));
birthEvent.Spawns.Add(offspring); //Sunrise
_transform.AttachToGridOrMap(offspring);
if (component.MakeOffspringInfant)
{
Expand All @@ -205,6 +211,8 @@ public void Birth(EntityUid uid, ReproductiveComponent? component = null)

component.Gestating = false;
component.GestationEndTime = null;

RaiseLocalEvent(uid, birthEvent); //Sunrise
}

public override void Update(float frameTime)
Expand Down Expand Up @@ -249,3 +257,11 @@ public override void Update(float frameTime)
}
}
}

//Sunrise-start

public sealed class BirthEvent : EntityEventArgs
{
public List<EntityUid> Spawns = new List<EntityUid>();
}
//Sunrise-end
21 changes: 20 additions & 1 deletion Content.Server/Nutrition/EntitySystems/FoodSystem.cs
Original file line number Diff line number Diff line change
Expand Up @@ -335,10 +335,24 @@ public void DeleteAndSpawnTrash(FoodComponent component, EntityUid food, EntityU
RaiseLocalEvent(food, ev);
if (ev.Cancelled)
return;

var dev = new DestructionEventArgs();
RaiseLocalEvent(food, dev);

//Sunrise-start

if (TryComp(food, out InventoryComponent? inventory))
{
foreach (SlotDefinition sl in inventory.Slots)
{
_inventory.TryUnequip(food, sl.Name, out EntityUid? item);
if (!TryComp(item, out TransformComponent? transform))
continue;
_transform.DropNextTo((EntityUid)item, food);
}
}

//Sunrise-end

if (component.Trash.Count == 0)
{
QueueDel(food);
Expand Down Expand Up @@ -433,6 +447,11 @@ private bool IsDigestibleBy(EntityUid food, FoodComponent component, List<Entity
// Check if the food is in the whitelist
if (_whitelistSystem.IsWhitelistPass(ent.Comp1.SpecialDigestible, food))
return true;
//Sunrise-start
// If food is not in whitelist, but whitelist is optinal, go on
if (ent.Comp1.IsDigestibleAddition)
continue;
//Sunrise-end
// They can only eat whitelist food and the food isn't in the whitelist. It's not edible.
return false;
}
Expand Down
14 changes: 14 additions & 0 deletions Content.Server/Saw/SawComponent.cs
Original file line number Diff line number Diff line change
@@ -0,0 +1,14 @@
using Content.Shared.FixedPoint;

namespace Content.Server.Saw;


[RegisterComponent]
public sealed partial class SawComponent : Component
{
[DataField]
public EntityUid? EatenMind = null;

[DataField]
public FixedPoint2 HungerToThresholdModifier = 1.5;
}
85 changes: 85 additions & 0 deletions Content.Server/Saw/SawSystem.cs
Original file line number Diff line number Diff line change
@@ -0,0 +1,85 @@
using Content.Server.Nutrition.Components;
using Content.Shared.IdentityManagement.Components;
using Content.Shared.Nutrition.AnimalHusbandry;
using Content.Server.Mind;
using Robust.Shared.Prototypes;
using Content.Shared.Mind.Components;
using Content.Server.Nutrition.EntitySystems;
using Content.Shared.Mobs.Components;
using Content.Shared.Mobs;
using Content.Shared.FixedPoint;
using Content.Shared.Mobs.Systems;
using Content.Server._Sunrise.Mood;
using Content.Shared.Nutrition.Components;
using Content.Shared.Nutrition;
using Content.Shared.Nutrition.EntitySystems;

namespace Content.Server.Saw;

public sealed class SawSystem : EntitySystem
{
[Dependency] private readonly IEntityManager _entityManager = default!;
[Dependency] private readonly IPrototypeManager _prototypeManager = default!;
[Dependency] private readonly MindSystem _mindSystem = default!;
[Dependency] private readonly MetaDataSystem _metaData = default!;
[Dependency] private readonly MobThresholdSystem _thresholdSystem = default!;
[Dependency] private readonly HungerSystem _hungerSystem = default!;
public override void Initialize()
{
base.Initialize();

SubscribeLocalEvent<FoodComponent, BeforeFullyEatenEvent>(OnBeforeFullyEaten);
SubscribeLocalEvent<SawComponent, ComponentInit>(SawInit);
SubscribeLocalEvent<SawComponent, BirthEvent>(OnBirth);
}

private void OnBeforeFullyEaten(Entity<FoodComponent> food, ref BeforeFullyEatenEvent args)
{
if (!TryComp(args.User, out SawComponent? sawComp) ||
!TryComp(args.User, out ReproductiveComponent? reproductive) ||
!TryComp(food, out MindContainerComponent? mind) ||
!HasComp<IdentityComponent>(food))
return;

EntityUid? foodMind = _mindSystem.GetMind(food);
sawComp.EatenMind = foodMind;

if (_prototypeManager.Index<EntityPrototype>("MobSaw").Components.TryGetComponent("Reproductive", out var defaultReproductive))
reproductive.Capacity = 6;
}

private void SawInit(EntityUid ent, SawComponent saw, ComponentInit args)
{
if (HasComp<ReproductiveComponent>(ent))
RemComp<ReproductiveComponent>(ent);

_entityManager.AddComponents(ent, _prototypeManager.Index("MobSaw").Components, false);
Comp<ReproductiveComponent>(ent).Capacity = 0;
}

private void OnBirth(Entity<SawComponent> saw, ref BirthEvent args)
{
if (TryComp(saw, out ReproductiveComponent? reproductive))
reproductive.Capacity = 0;
EntityUid child = args.Spawns[0];
EntityUid? eatenMind = Comp<SawComponent>(saw).EatenMind;
saw.Comp.EatenMind = null;
if (eatenMind == null)
return;
if (!TryComp<HungerComponent>(saw, out var hungerComp))
return;

if (TryComp<MobThresholdsComponent>(child, out var thresholds))
{
FixedPoint2 thresholdModifier = _hungerSystem.GetHunger(hungerComp) * saw.Comp.HungerToThresholdModifier;

_thresholdSystem.SetMobStateThreshold(child, _thresholdSystem.GetThresholdForState(child, MobState.Critical) + thresholdModifier, MobState.Critical);
_thresholdSystem.SetMobStateThreshold(child, _thresholdSystem.GetThresholdForState(child, MobState.Dead) + thresholdModifier, MobState.Dead);
if (TryComp<MoodComponent>(child, out var mood))
mood.CritThresholdBeforeModify = _thresholdSystem.GetThresholdForState(child, MobState.Critical);
}

_mindSystem.TransferTo((EntityUid) eatenMind, child);
_metaData.SetEntityName(args.Spawns[0], "троттин");
}
}
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
using Content.Shared.Storage;
using Content.Shared.Storage;
using Content.Shared.Whitelist;
using Robust.Shared.Serialization.TypeSerializers.Implementations.Custom;

Expand All @@ -12,6 +12,9 @@ namespace Content.Shared.Nutrition.AnimalHusbandry;
[RegisterComponent, AutoGenerateComponentPause]
public sealed partial class ReproductiveComponent : Component
{
[DataField]
public bool IsPartnerNeed = true; //Sunrise

/// <summary>
/// The next time when breeding will be attempted.
/// </summary>
Expand Down
Original file line number Diff line number Diff line change
@@ -0,0 +1,2 @@
ent-BoxFacecast = коробка лицевых слепков
.desc = Она заполнена лицами.
Loading
Loading