Skip to content
This repository has been archived by the owner on Nov 1, 2024. It is now read-only.

Commit

Permalink
Мерджконфликты
Browse files Browse the repository at this point in the history
  • Loading branch information
Vonsant committed Jun 14, 2024
2 parents 85961b6 + 40eac27 commit 3ca5f41
Show file tree
Hide file tree
Showing 235 changed files with 3,092 additions and 201 deletions.
38 changes: 35 additions & 3 deletions Content.Server/Bible/BibleSystem.cs
Original file line number Diff line number Diff line change
@@ -1,10 +1,13 @@
using Content.Server.Bible.Components;
using Content.Server.Chemistry.EntitySystems;
using Content.Server.Ghost.Roles.Components;
using Content.Server.Ghost.Roles.Events;
using Content.Server.Popups;
using Content.Shared.ActionBlocker;
using Content.Shared.Actions;
using Content.Shared.Bible;
using Content.Shared.Chemistry.Components;
using Content.Shared.Chemistry.Reaction;
using Content.Shared.Damage;
using Content.Shared.IdentityManagement;
using Content.Shared.Interaction;
Expand Down Expand Up @@ -38,7 +41,8 @@ public override void Initialize()
{
base.Initialize();

SubscribeLocalEvent<BibleComponent, AfterInteractEvent>(OnAfterInteract);
SubscribeLocalEvent<BibleComponent, MixingAttemptEvent>(OnMixingAttempt); // Frontier: restrict solution blessing to bible users
SubscribeLocalEvent<BibleComponent, AfterInteractEvent>(OnAfterInteract, before: [typeof(ReactionMixerSystem)]); // Frontier: add before parameter
SubscribeLocalEvent<SummonableComponent, GetVerbsEvent<AlternativeVerb>>(AddSummonVerb);
SubscribeLocalEvent<SummonableComponent, GetItemActionsEvent>(GetSummonAction);
SubscribeLocalEvent<SummonableComponent, SummonActionEvent>(OnSummon);
Expand Down Expand Up @@ -91,6 +95,19 @@ public override void Update(float frameTime)
}
}

// Frontier: only bible users can bless water/blood
private void OnMixingAttempt(EntityUid uid, BibleComponent component, ref MixingAttemptEvent args)
{
// Block water/blood blessing attempts by non-bible users
if (component.BlockMix)
{
_popupSystem.PopupEntity(Loc.GetString("bible-bless-solution-failed"), component.LastInteractingUser, component.LastInteractingUser, PopupType.Small);
args.Cancelled = true;
return;
}
}
// End Frontier

private void OnAfterInteract(EntityUid uid, BibleComponent component, AfterInteractEvent args)
{
if (!args.CanReach)
Expand All @@ -99,12 +116,24 @@ private void OnAfterInteract(EntityUid uid, BibleComponent component, AfterInter
if (!TryComp(uid, out UseDelayComponent? useDelay) || _delay.IsDelayed((uid, useDelay)))
return;

if (args.Target == null || args.Target == args.User || !_mobStateSystem.IsAlive(args.Target.Value))
// Frontier: only bible users can bless water/blood
if (args.Target == null)
{
return;
}

if (!HasComp<BibleUserComponent>(args.User))
// In case the user is trying to mix something, store who's using it and whether or not they're a bible user.
component.LastInteractingUser = args.User;
var hasBibleUserComponent = HasComp<BibleUserComponent>(args.User);
component.BlockMix = !hasBibleUserComponent;

if (args.Target == args.User || !_mobStateSystem.IsAlive(args.Target.Value))
{
return;
}
// End Frontier

if (!hasBibleUserComponent) // Frontier: cache bible component lookup
{
_popupSystem.PopupEntity(Loc.GetString("bible-sizzle"), args.User, args.User);

Expand Down Expand Up @@ -226,7 +255,10 @@ private void AttemptSummon(Entity<SummonableComponent> ent, EntityUid user, Tran
if (component.AlreadySummoned || component.SpecialItemPrototype == null)
return;
if (component.RequiresBibleUser && !HasComp<BibleUserComponent>(user))
{
_popupSystem.PopupEntity(Loc.GetString("bible-summon-request-failed"), user, user, PopupType.Small); // Frontier: better summon feedback
return;
}
if (!Resolve(user, ref position))
return;
if (component.Deleted || Deleted(uid))
Expand Down
15 changes: 15 additions & 0 deletions Content.Server/Bible/Components/BibleComponent.cs
Original file line number Diff line number Diff line change
Expand Up @@ -41,5 +41,20 @@ public sealed partial class BibleComponent : Component

[DataField("locPrefix")]
public string LocPrefix = "bible";

// Frontier: prevent non-bible users from blessing water/blood.

/// <summary>
/// Whether or not a mixing attempt from this bible should be blocked.
/// </summary>
[ViewVariables]
public bool BlockMix = false;

/// <summary>
/// The last user that interacted using the bible.
/// </summary>
[ViewVariables]
public EntityUid LastInteractingUser;
//End Frontier
}
}
Original file line number Diff line number Diff line change
Expand Up @@ -4,5 +4,11 @@ namespace Content.Server.Abilities.Oni
public sealed partial class HeldByOniComponent : Component
{
public EntityUid Holder = default!;

// Frontier: wield accuracy fix
public double minAngleAdded = 0.0;
public double maxAngleAdded = 0.0;
public double angleIncreaseAdded = 0.0;
// End Frontier
}
}
40 changes: 32 additions & 8 deletions Content.Server/Nyanotrasen/Abilities/Oni/OniSystem.cs
Original file line number Diff line number Diff line change
Expand Up @@ -4,12 +4,16 @@
using Content.Shared.Weapons.Melee.Events;
using Content.Shared.Weapons.Ranged.Components;
using Robust.Shared.Containers;
using Content.Shared.Weapons.Ranged.Systems;

namespace Content.Server.Abilities.Oni
{
public sealed class OniSystem : EntitySystem
{
[Dependency] private readonly ToolSystem _toolSystem = default!;
[Dependency] private readonly SharedGunSystem _gunSystem = default!;

private const double GunInaccuracyFactor = 17.0; // Frontier (20x<18x -> 10% buff)

public override void Initialize()
{
Expand All @@ -28,21 +32,41 @@ private void OnEntInserted(EntityUid uid, OniComponent component, EntInsertedInt

if (TryComp<GunComponent>(args.Entity, out var gun))
{
gun.MinAngle *= 20f;
gun.AngleIncrease *= 20f;
gun.MaxAngle *= 20f;
// Frontier: adjust penalty for wielded malus
if (TryComp<GunWieldBonusComponent>(args.Entity, out var bonus))
{
//GunWieldBonus values are stored as negative.
heldComp.minAngleAdded = (gun.MinAngle + bonus.MinAngle) * GunInaccuracyFactor;
heldComp.angleIncreaseAdded = (gun.AngleIncrease + bonus.AngleIncrease) * GunInaccuracyFactor;
heldComp.maxAngleAdded = (gun.MaxAngle + bonus.MaxAngle) * GunInaccuracyFactor;
}
else
{
heldComp.minAngleAdded = gun.MinAngle * GunInaccuracyFactor;
heldComp.angleIncreaseAdded = gun.AngleIncrease * GunInaccuracyFactor;
heldComp.maxAngleAdded = gun.MaxAngle * GunInaccuracyFactor;
}

gun.MinAngle += heldComp.minAngleAdded;
gun.AngleIncrease += heldComp.angleIncreaseAdded;
gun.MaxAngle += heldComp.maxAngleAdded;
_gunSystem.RefreshModifiers(args.Entity); // Make sure values propagate to modified values (this also dirties the gun for us)
// End Frontier
}
}

private void OnEntRemoved(EntityUid uid, OniComponent component, EntRemovedFromContainerMessage args)
{

if (TryComp<GunComponent>(args.Entity, out var gun))
// Frontier: angle manipulation stored in HeldByOniComponent
if (TryComp<GunComponent>(args.Entity, out var gun) &&
TryComp<HeldByOniComponent>(args.Entity, out var heldComp))
{
gun.MinAngle /= 20f;
gun.AngleIncrease /= 20f;
gun.MaxAngle /= 20f;
gun.MinAngle -= heldComp.minAngleAdded;
gun.AngleIncrease -= heldComp.angleIncreaseAdded;
gun.MaxAngle -= heldComp.maxAngleAdded;
_gunSystem.RefreshModifiers(args.Entity); // Make sure values propagate to modified values (this also dirties the gun for us)
}
// End Frontier

RemComp<HeldByOniComponent>(args.Entity);
}
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -7,13 +7,13 @@ namespace Content.Server.StationEvents.Components;
public sealed partial class BluespaceErrorRuleComponent : Component
{
/// <summary>
/// Path to the grid that gets bluspaced in
/// List of paths to the grids that can be bluespaced in.
/// </summary>
[DataField("gridPath")]
public string GridPath = "";
[DataField("gridPaths")]
public List<string> GridPaths = new();

/// <summary>
/// The color of your thing. the name should be set by the mapper when mapping.
/// The color of your thing. The name should be set by the mapper when mapping.
/// </summary>
[DataField("color")]
public Color Color = new Color(225, 15, 155);
Expand All @@ -31,7 +31,7 @@ public sealed partial class BluespaceErrorRuleComponent : Component
public EntityUid? GridUid = null;

/// <summary>
/// How much the grid is appraised at upon entering into existance, set after starting the event
/// How much the grid is appraised at upon entering into existence, set after starting the event
/// </summary>
[DataField("startingValue")]
public double startingValue = 0;
Expand Down
19 changes: 10 additions & 9 deletions Content.Server/StationEvents/Events/BluespaceErrorRule.cs
Original file line number Diff line number Diff line change
Expand Up @@ -31,47 +31,50 @@ public sealed class BluespaceErrorRule : StationEventSystem<BluespaceErrorRuleCo

private List<(Entity<TransformComponent> Entity, EntityUid MapUid, Vector2 LocalPosition)> _playerMobs = new();

protected override void Started(EntityUid uid, BluespaceErrorRuleComponent component, GameRuleComponent gameRule,
GameRuleStartedEvent args)
protected override void Started(EntityUid uid, BluespaceErrorRuleComponent component, GameRuleComponent gameRule, GameRuleStartedEvent args)
{
base.Started(uid, component, gameRule, args);

// Select a random grid path
var selectedGridPath = _random.Pick(component.GridPaths);
var shuttleMap = _mapManager.CreateMap();
var options = new MapLoadOptions
{
LoadMap = true,
};

if (!_map.TryLoad(shuttleMap, component.GridPath, out var gridUids, options))
if (!_map.TryLoad(shuttleMap, selectedGridPath, out var gridUids, options))
return;

component.GridUid = gridUids[0];
if (component.GridUid is not EntityUid gridUid)
return;

component.startingValue = _pricing.AppraiseGrid(gridUid);
_shuttle.SetIFFColor(gridUid, component.Color);
var offset = _random.NextVector2(1350f, 2200f);
var mapId = GameTicker.DefaultMap;
var mapUid = _mapManager.GetMapEntityId(mapId);

if (TryComp<ShuttleComponent>(component.GridUid, out var shuttle))
{
_shuttle.FTLToCoordinates(gridUid, shuttle, new EntityCoordinates(mapUid, offset), 0f, 0f, 30f);
}

}

protected override void Ended(EntityUid uid, BluespaceErrorRuleComponent component, GameRuleComponent gameRule, GameRuleEndedEvent args)
{
base.Ended(uid, component, gameRule, args);

if(!EntityManager.TryGetComponent<TransformComponent>(component.GridUid, out var gridTransform))
if (!EntityManager.TryGetComponent<TransformComponent>(component.GridUid, out var gridTransform))
{
Log.Error("bluespace error objective was missing transform component");
return;
}

if (gridTransform.GridUid is not EntityUid gridUid)
{
Log.Error( "bluespace error has no associated grid?");
Log.Error("bluespace error has no associated grid?");
return;
}

Expand All @@ -98,12 +101,10 @@ protected override void Ended(EntityUid uid, BluespaceErrorRuleComponent compone
_transform.SetCoordinates(mob.Entity.Owner, new EntityCoordinates(mob.MapUid, mob.LocalPosition));
}


var query = EntityQuery<StationBankAccountComponent>();
foreach (var account in query)
{
_cargo.DeductFunds(account, (int) -(gridValue * component.RewardFactor));
_cargo.DeductFunds(account, (int)-(gridValue * component.RewardFactor));
}
}
}

38 changes: 38 additions & 0 deletions Content.Server/_NF/Implants/BibleUserImplantSystem.cs
Original file line number Diff line number Diff line change
@@ -0,0 +1,38 @@
using Content.Shared.Implants;
using Content.Shared.Implants.Components;
using Content.Server.Bible.Components;
using Robust.Shared.Containers;

namespace Content.Server.Implants;

public sealed class BibleUserImplantSystem : EntitySystem
{

public override void Initialize()
{
base.Initialize();

SubscribeLocalEvent<BibleUserImplantComponent, ImplantImplantedEvent>(OnInsert);
// We need to remove the BibleUserComponent from the owner before the implant
// is removed, so we need to execute before the SubdermalImplantSystem.
SubscribeLocalEvent<BibleUserImplantComponent, EntGotRemovedFromContainerMessage>(OnRemove, before: new[] { typeof(SubdermalImplantSystem) });
}

private void OnInsert(EntityUid uid, BibleUserImplantComponent component, ImplantImplantedEvent args)
{
if (!args.Implanted.HasValue)
return;

var bibleUserComp = EnsureComp<BibleUserComponent>(args.Implanted.Value);
Dirty(args.Implanted.Value, bibleUserComp);
}

// Currently permanent, but should support removal if/when a viable solution is found.
private void OnRemove(EntityUid uid, BibleUserImplantComponent component, EntGotRemovedFromContainerMessage args)
{
if (!TryComp<SubdermalImplantComponent>(uid, out var implanted) || implanted.ImplantedEntity == null)
return;

RemComp<BibleUserComponent>(implanted.ImplantedEntity.Value);
}
}
Original file line number Diff line number Diff line change
@@ -0,0 +1,10 @@
namespace Content.Server._NF.Security.Components;

/// <summary>
/// This is used for the contraband appraisal gun, which checks the contraband turn-in value in FUCs of any object it appraises.
/// </summary>
[RegisterComponent]
public sealed partial class ContrabandPriceGunComponent : Component
{

}
67 changes: 67 additions & 0 deletions Content.Server/_NF/Security/ContrabandPriceGunSystem.cs
Original file line number Diff line number Diff line change
@@ -0,0 +1,67 @@
using Content.Server.Popups;
using Content.Shared._NF.Contraband.Components;
using Content.Server._NF.Security.Components;
using Content.Shared.IdentityManagement;
using Content.Shared.Interaction;
using Content.Shared.Timing;
using Content.Shared.Verbs;

namespace Content.Server._NF.Security.Systems;

/// <summary>
/// This system handles contraband appraisal messages and will inform a user of how much an item is worth for trade-in in FUCs.
/// </summary>
public sealed class ContrabandPriceGunSystem : EntitySystem
{
[Dependency] private readonly UseDelaySystem _useDelay = default!;
[Dependency] private readonly PopupSystem _popupSystem = default!;

/// <inheritdoc/>
public override void Initialize()
{
SubscribeLocalEvent<ContrabandPriceGunComponent, AfterInteractEvent>(OnAfterInteract);
SubscribeLocalEvent<ContrabandPriceGunComponent, GetVerbsEvent<UtilityVerb>>(OnUtilityVerb);
}

private void OnUtilityVerb(EntityUid uid, ContrabandPriceGunComponent component, GetVerbsEvent<UtilityVerb> args)
{
if (!args.CanAccess || !args.CanInteract || args.Using == null)
return;

if (!TryComp(uid, out UseDelayComponent? useDelay) || _useDelay.IsDelayed((uid, useDelay)))
return;

if (!TryComp<ContrabandComponent>(args.Target, out var contraband))
return;

var verb = new UtilityVerb()
{
Act = () =>
{
_popupSystem.PopupEntity(Loc.GetString("contraband-price-gun-pricing-result", ("object", Identity.Entity(args.Target, EntityManager)), ("price", contraband.Value)), args.User, args.User);
_useDelay.TryResetDelay((uid, useDelay));
},
Text = Loc.GetString("contraband-price-gun-verb-text"),
Message = Loc.GetString("contraband-price-gun-verb-message", ("object", Identity.Entity(args.Target, EntityManager)))
};

args.Verbs.Add(verb);
}

private void OnAfterInteract(EntityUid uid, ContrabandPriceGunComponent component, AfterInteractEvent args)
{
if (!args.CanReach || args.Target == null || args.Handled)
return;

if (!TryComp(uid, out UseDelayComponent? useDelay) || _useDelay.IsDelayed((uid, useDelay)))
return;

if (TryComp<ContrabandComponent>(args.Target, out var contraband))
_popupSystem.PopupEntity(Loc.GetString("contraband-price-gun-pricing-result", ("object", Identity.Entity(args.Target.Value, EntityManager)), ("price", contraband.Value)), args.User, args.User);
else
_popupSystem.PopupEntity(Loc.GetString("contraband-price-gun-pricing-result-none", ("object", Identity.Entity(args.Target.Value, EntityManager))), args.User, args.User);

_useDelay.TryResetDelay((uid, useDelay));
args.Handled = true;
}
}
Loading

0 comments on commit 3ca5f41

Please sign in to comment.