31
Content.Shared/Delivery/DeliveryFragileComponent.cs
Normal file
31
Content.Shared/Delivery/DeliveryFragileComponent.cs
Normal file
@@ -0,0 +1,31 @@
|
|||||||
|
using Robust.Shared.GameStates;
|
||||||
|
|
||||||
|
namespace Content.Shared.Delivery;
|
||||||
|
|
||||||
|
/// <summary>
|
||||||
|
/// Component given to deliveries.
|
||||||
|
/// Allows the delivery to be broken.
|
||||||
|
/// If intact, applies a small multiplier, otherwise substracts it.
|
||||||
|
/// </summary>
|
||||||
|
[RegisterComponent, NetworkedComponent, AutoGenerateComponentState]
|
||||||
|
[Access(typeof(DeliveryModifierSystem))]
|
||||||
|
public sealed partial class DeliveryFragileComponent : Component
|
||||||
|
{
|
||||||
|
/// <summary>
|
||||||
|
/// Multiplier to use when the delivery is intact.
|
||||||
|
/// </summary>
|
||||||
|
[DataField]
|
||||||
|
public float IntactMultiplierOffset = 0.15f;
|
||||||
|
|
||||||
|
/// <summary>
|
||||||
|
/// Multiplier to use when the delivery is broken.
|
||||||
|
/// </summary>
|
||||||
|
[DataField]
|
||||||
|
public float BrokenMultiplierOffset = -0.33f;
|
||||||
|
|
||||||
|
/// <summary>
|
||||||
|
/// Whether this priority has already been broken or not.
|
||||||
|
/// </summary>
|
||||||
|
[DataField, AutoNetworkedField]
|
||||||
|
public bool Broken;
|
||||||
|
}
|
||||||
@@ -1,5 +1,5 @@
|
|||||||
|
using Content.Shared.Destructible;
|
||||||
using Content.Shared.Examine;
|
using Content.Shared.Examine;
|
||||||
using Content.Shared.GameTicking;
|
|
||||||
using Content.Shared.NameModifier.EntitySystems;
|
using Content.Shared.NameModifier.EntitySystems;
|
||||||
using Robust.Shared.Random;
|
using Robust.Shared.Random;
|
||||||
using Robust.Shared.Serialization;
|
using Robust.Shared.Serialization;
|
||||||
@@ -27,6 +27,11 @@ public sealed partial class DeliveryModifierSystem : EntitySystem
|
|||||||
SubscribeLocalEvent<DeliveryPriorityComponent, MapInitEvent>(OnPriorityMapInit);
|
SubscribeLocalEvent<DeliveryPriorityComponent, MapInitEvent>(OnPriorityMapInit);
|
||||||
SubscribeLocalEvent<DeliveryPriorityComponent, ExaminedEvent>(OnPriorityExamine);
|
SubscribeLocalEvent<DeliveryPriorityComponent, ExaminedEvent>(OnPriorityExamine);
|
||||||
SubscribeLocalEvent<DeliveryPriorityComponent, GetDeliveryMultiplierEvent>(OnGetPriorityMultiplier);
|
SubscribeLocalEvent<DeliveryPriorityComponent, GetDeliveryMultiplierEvent>(OnGetPriorityMultiplier);
|
||||||
|
|
||||||
|
SubscribeLocalEvent<DeliveryFragileComponent, MapInitEvent>(OnFragileMapInit);
|
||||||
|
SubscribeLocalEvent<DeliveryFragileComponent, BreakageEventArgs>(OnFragileBreakage);
|
||||||
|
SubscribeLocalEvent<DeliveryFragileComponent, ExaminedEvent>(OnFragileExamine);
|
||||||
|
SubscribeLocalEvent<DeliveryFragileComponent, GetDeliveryMultiplierEvent>(OnGetFragileMultiplier);
|
||||||
}
|
}
|
||||||
|
|
||||||
#region Random
|
#region Random
|
||||||
@@ -70,6 +75,38 @@ public sealed partial class DeliveryModifierSystem : EntitySystem
|
|||||||
}
|
}
|
||||||
#endregion
|
#endregion
|
||||||
|
|
||||||
|
#region Fragile
|
||||||
|
private void OnFragileMapInit(Entity<DeliveryFragileComponent> ent, ref MapInitEvent args)
|
||||||
|
{
|
||||||
|
_delivery.UpdateBrokenVisuals(ent, true);
|
||||||
|
}
|
||||||
|
|
||||||
|
private void OnFragileBreakage(Entity<DeliveryFragileComponent> ent, ref BreakageEventArgs args)
|
||||||
|
{
|
||||||
|
ent.Comp.Broken = true;
|
||||||
|
_delivery.UpdateBrokenVisuals(ent, true);
|
||||||
|
Dirty(ent);
|
||||||
|
}
|
||||||
|
|
||||||
|
private void OnFragileExamine(Entity<DeliveryFragileComponent> ent, ref ExaminedEvent args)
|
||||||
|
{
|
||||||
|
var trueName = _nameModifier.GetBaseName(ent.Owner);
|
||||||
|
|
||||||
|
if (ent.Comp.Broken)
|
||||||
|
args.PushMarkup(Loc.GetString("delivery-fragile-broken-examine", ("type", trueName)));
|
||||||
|
else
|
||||||
|
args.PushMarkup(Loc.GetString("delivery-fragile-examine", ("type", trueName)));
|
||||||
|
}
|
||||||
|
|
||||||
|
private void OnGetFragileMultiplier(Entity<DeliveryFragileComponent> ent, ref GetDeliveryMultiplierEvent args)
|
||||||
|
{
|
||||||
|
if (ent.Comp.Broken)
|
||||||
|
args.AdditiveMultiplier += ent.Comp.BrokenMultiplierOffset;
|
||||||
|
else
|
||||||
|
args.AdditiveMultiplier += ent.Comp.IntactMultiplierOffset;
|
||||||
|
}
|
||||||
|
#endregion
|
||||||
|
|
||||||
#region Update Loops
|
#region Update Loops
|
||||||
public override void Update(float frameTime)
|
public override void Update(float frameTime)
|
||||||
{
|
{
|
||||||
|
|||||||
@@ -12,13 +12,13 @@ namespace Content.Shared.Delivery;
|
|||||||
public sealed partial class DeliveryPriorityComponent : Component
|
public sealed partial class DeliveryPriorityComponent : Component
|
||||||
{
|
{
|
||||||
/// <summary>
|
/// <summary>
|
||||||
/// The highest the random multiplier can go.
|
/// The multiplier to apply when delivered in time.
|
||||||
/// </summary>
|
/// </summary>
|
||||||
[DataField]
|
[DataField]
|
||||||
public float InTimeMultiplierOffset = 0.2f;
|
public float InTimeMultiplierOffset = 0.2f;
|
||||||
|
|
||||||
/// <summary>
|
/// <summary>
|
||||||
/// The lowest the random multiplier can go.
|
/// The multiplier to apply when delivered late.
|
||||||
/// </summary>
|
/// </summary>
|
||||||
[DataField]
|
[DataField]
|
||||||
public float ExpiredMultiplierOffset = -0.1f;
|
public float ExpiredMultiplierOffset = -0.1f;
|
||||||
|
|||||||
@@ -231,6 +231,7 @@ public abstract class SharedDeliverySystem : EntitySystem
|
|||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
#region Visual Updates
|
||||||
// TODO: generic updateVisuals from component data
|
// TODO: generic updateVisuals from component data
|
||||||
private void UpdateAntiTamperVisuals(EntityUid uid, bool isLocked)
|
private void UpdateAntiTamperVisuals(EntityUid uid, bool isLocked)
|
||||||
{
|
{
|
||||||
@@ -252,10 +253,17 @@ public abstract class SharedDeliverySystem : EntitySystem
|
|||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
public void UpdateBrokenVisuals(Entity<DeliveryFragileComponent> ent, bool isFragile)
|
||||||
|
{
|
||||||
|
_appearance.SetData(ent, DeliveryVisuals.IsBroken, ent.Comp.Broken);
|
||||||
|
_appearance.SetData(ent, DeliveryVisuals.IsFragile, isFragile);
|
||||||
|
}
|
||||||
|
|
||||||
protected void UpdateDeliverySpawnerVisuals(EntityUid uid, int contents)
|
protected void UpdateDeliverySpawnerVisuals(EntityUid uid, int contents)
|
||||||
{
|
{
|
||||||
_appearance.SetData(uid, DeliverySpawnerVisuals.Contents, contents > 0);
|
_appearance.SetData(uid, DeliverySpawnerVisuals.Contents, contents > 0);
|
||||||
}
|
}
|
||||||
|
#endregion
|
||||||
|
|
||||||
/// <summary>
|
/// <summary>
|
||||||
/// Gathers the total multiplier for a delivery.
|
/// Gathers the total multiplier for a delivery.
|
||||||
|
|||||||
@@ -25,3 +25,6 @@ delivery-teleporter-empty-verb = Take mail
|
|||||||
# modifiers
|
# modifiers
|
||||||
delivery-priority-examine = This is a [color=orange]priority {$type}[/color]. You have [color=orange]{$time}[/color] left to deliver it to get a bonus.
|
delivery-priority-examine = This is a [color=orange]priority {$type}[/color]. You have [color=orange]{$time}[/color] left to deliver it to get a bonus.
|
||||||
delivery-priority-expired-examine = This is a [color=orange]priority {$type}[/color]. It seems you ran out of time.
|
delivery-priority-expired-examine = This is a [color=orange]priority {$type}[/color]. It seems you ran out of time.
|
||||||
|
|
||||||
|
delivery-fragile-examine = This is a [color=red]fragile {$type}[/color]. Deliver it intact for a bonus.
|
||||||
|
delivery-fragile-broken-examine = This is a [color=red]fragile {$type}[/color]. It looks badly damaged.
|
||||||
|
|||||||
@@ -137,6 +137,8 @@
|
|||||||
children:
|
children:
|
||||||
- id: DeliveryModifierPriority
|
- id: DeliveryModifierPriority
|
||||||
prob: 0.25
|
prob: 0.25
|
||||||
|
- id: DeliveryModifierFragile
|
||||||
|
prob: 0.25
|
||||||
|
|
||||||
- type: entity
|
- type: entity
|
||||||
id: DeliveryModifierPriority
|
id: DeliveryModifierPriority
|
||||||
@@ -144,3 +146,34 @@
|
|||||||
categories: [ HideSpawnMenu ]
|
categories: [ HideSpawnMenu ]
|
||||||
components:
|
components:
|
||||||
- type: DeliveryPriority
|
- type: DeliveryPriority
|
||||||
|
|
||||||
|
- type: entity
|
||||||
|
id: DeliveryModifierFragile
|
||||||
|
description: Components to add when a delivery is rolled as fragile.
|
||||||
|
categories: [ HideSpawnMenu ]
|
||||||
|
components:
|
||||||
|
- type: DeliveryFragile
|
||||||
|
- type: Damageable
|
||||||
|
damageContainer: Inorganic
|
||||||
|
- type: DamageOnHighSpeedImpact
|
||||||
|
minimumSpeed: 0.1
|
||||||
|
damage:
|
||||||
|
types:
|
||||||
|
Blunt: 1
|
||||||
|
soundHit:
|
||||||
|
collection: WeakHit
|
||||||
|
- type: DamageOnLand
|
||||||
|
damage:
|
||||||
|
types:
|
||||||
|
Blunt: 1
|
||||||
|
- type: Destructible
|
||||||
|
thresholds:
|
||||||
|
- trigger:
|
||||||
|
!type:DamageTrigger
|
||||||
|
damage: 1
|
||||||
|
behaviors:
|
||||||
|
- !type:PlaySoundBehavior
|
||||||
|
sound:
|
||||||
|
collection: DeliveryOpenSounds
|
||||||
|
- !type:DoActsBehavior
|
||||||
|
acts: [ "Breakage" ]
|
||||||
|
|||||||
Reference in New Issue
Block a user