Skip to content

Commit

Permalink
Whitelist, MachinePart compilation fixes
Browse files Browse the repository at this point in the history
  • Loading branch information
whatston3 committed Jun 18, 2024
1 parent d7d13b7 commit 3da9cb4
Show file tree
Hide file tree
Showing 6 changed files with 64 additions and 3 deletions.
26 changes: 26 additions & 0 deletions Content.Shared/Construction/Components/MachinePartComponent.cs
Original file line number Diff line number Diff line change
@@ -0,0 +1,26 @@
// FRONTIER MERGE: restored this from frontier's master to get things to compile

using Content.Shared.Construction.Prototypes;
using Robust.Shared.GameStates;
using Robust.Shared.Serialization.TypeSerializers.Implementations.Custom.Prototype;

namespace Content.Shared.Construction.Components
{
[RegisterComponent, NetworkedComponent]
public sealed partial class MachinePartComponent : Component
{
[DataField("part", required: true, customTypeSerializer: typeof(PrototypeIdSerializer<MachinePartPrototype>))]
public string PartType { get; private set; } = default!;

[ViewVariables(VVAccess.ReadWrite)]
[DataField("rating")]
public int Rating { get; private set; } = 1;

/// <summary>
/// This number is used in tests to ensure that you can't use high quality machines for arbitrage. In
/// principle there is nothing wrong with using higher quality parts, but you have to be careful to not
/// allow them to be put into a lathe or something like that.
/// </summary>
public const int MaxRating = 4;
}
}
1 change: 1 addition & 0 deletions Content.Shared/Construction/MachinePartSystem.cs
Original file line number Diff line number Diff line change
@@ -1,5 +1,6 @@
using System.Linq;
using Content.Shared.Construction.Components;
using Content.Shared.Construction.Prototypes; // FRONTIER MERGE
using Content.Shared.Examine;
using Content.Shared.Lathe;
using Content.Shared.Materials;
Expand Down
29 changes: 29 additions & 0 deletions Content.Shared/Construction/Prototypes/MachinePartPrototype.cs
Original file line number Diff line number Diff line change
@@ -0,0 +1,29 @@
// FRONTIER MERGE: restored this from frontier's master to get things to compile
using Robust.Shared.Prototypes;
using Robust.Shared.Serialization.TypeSerializers.Implementations.Custom.Prototype;

namespace Content.Shared.Construction.Prototypes;

/// <summary>
/// This is a prototype for categorizing
/// different types of machine parts.
/// </summary>
[Prototype("machinePart")]
public sealed partial class MachinePartPrototype : IPrototype
{
/// <inheritdoc/>
[IdDataField]
public string ID { get; private set; } = default!;

/// <summary>
/// A human-readable name for the machine part type.
/// </summary>
[DataField("name")]
public string Name = string.Empty;

/// <summary>
/// A stock part entity based on the machine part.
/// </summary>
[DataField("stockPartPrototype", customTypeSerializer: typeof(PrototypeIdSerializer<EntityPrototype>), required: true)]
public string StockPartPrototype = string.Empty;
}
2 changes: 2 additions & 0 deletions Content.Shared/Lathe/LatheComponent.cs
Original file line number Diff line number Diff line change
Expand Up @@ -59,6 +59,8 @@ public sealed partial class LatheComponent : Component
/// </summary>
[DataField, ViewVariables(VVAccess.ReadWrite), AutoNetworkedField]
public float MaterialUseMultiplier = 1;

public const float DefaultPartRatingMaterialUseMultiplier = 0.85f; //FRONTIER MERGE: added this back in
#endregion

//Frontier Upgrade Code Restore
Expand Down
5 changes: 4 additions & 1 deletion Content.Shared/Weapons/Melee/MeleeThrowOnHitSystem.cs
Original file line number Diff line number Diff line change
Expand Up @@ -2,6 +2,7 @@
using Content.Shared.Construction.Components;
using Content.Shared.Weapons.Melee.Components;
using Content.Shared.Weapons.Melee.Events;
using Content.Shared.Whitelist;
using Robust.Shared.Physics;
using Robust.Shared.Physics.Components;
using Robust.Shared.Physics.Events;
Expand All @@ -18,6 +19,7 @@ public sealed class MeleeThrowOnHitSystem : EntitySystem
[Dependency] private readonly IGameTiming _timing = default!;
[Dependency] private readonly SharedTransformSystem _transform = default!;
[Dependency] private readonly SharedPhysicsSystem _physics = default!;
[Dependency] private readonly EntityWhitelistSystem _whitelist = default!; // Frontier MERGE

/// <inheritdoc/>
public override void Initialize()
Expand Down Expand Up @@ -49,7 +51,8 @@ private void OnMeleeHit(Entity<MeleeThrowOnHitComponent> ent, ref MeleeHitEvent
{
if (comp.Whitelist != null) // Frontier
{
if (comp.Whitelist.IsValid(hit, EntityManager) == true)
if (_whitelist.IsWhitelistPass(comp.Whitelist, hit)) // Frontier MERGE
//if (comp.Whitelist.IsValid(hit, EntityManager) == true) // Frontier MERGE: commented out
_transform.Unanchor(hit, Transform(hit));
}
else // Frontier
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -154,8 +154,8 @@ void SimulateInsertAmmo(EntityUid ammo, EntityUid ammoProvider, EntityCoordinate
if (ent == null)
continue;

if (ballisticTarget is not null && ballisticTarget.Whitelist?.IsValid(ent.Value) != true ||
revolverTarget is not null && revolverTarget.Whitelist?.IsValid(ent.Value) != true)
if (ballisticTarget is not null && _whitelistSystem.IsWhitelistFailOrNull(ballisticTarget.Whitelist, ent.Value) != true ||
revolverTarget is not null && _whitelistSystem.IsWhitelistFailOrNull(revolverTarget.Whitelist, ent.Value) != true)
{
Popup(
Loc.GetString("gun-ballistic-transfer-invalid",
Expand Down

0 comments on commit 3da9cb4

Please sign in to comment.