2023-05-16 00:44:35 +02:00
using Content.Shared.Chemistry.Reagent ;
using Content.Shared.Whitelist ;
using Robust.Shared.Audio ;
using Robust.Shared.Containers ;
using Robust.Shared.GameStates ;
2023-09-08 18:16:05 -07:00
using Robust.Shared.Prototypes ;
2023-05-16 00:44:35 +02:00
2023-09-08 18:16:05 -07:00
namespace Content.Shared.Devour.Components ;
2023-05-16 00:44:35 +02:00
2025-07-15 20:21:18 -04:00
/// <summary>
/// Allows an entity to eat whitelisted entities via an action.
/// Eaten mobs will be stored inside a container and released when the devourer is gibbed.
/// Eating something that fits their food preference will reward the devourer by being injected with a specific reagent.
/// </summary>
[RegisterComponent, NetworkedComponent, AutoGenerateComponentState]
[Access(typeof(DevourSystem))]
2023-08-22 18:14:33 -07:00
public sealed partial class DevourerComponent : Component
2023-05-16 00:44:35 +02:00
{
2025-07-15 20:21:18 -04:00
/// <summary>
/// Action prototype for devouring.
/// </summary>
2025-07-09 06:43:35 -06:00
[DataField]
2025-07-15 20:21:18 -04:00
public EntProtoId DevourAction = "ActionDevour" ;
2023-05-16 00:44:35 +02:00
2025-07-15 20:21:18 -04:00
/// <summary>
/// The spawned action entity for devouring.
/// </summary>
[DataField, AutoNetworkedField]
public EntityUid ? DevourActionEntity ;
2023-05-16 00:44:35 +02:00
2025-07-15 20:21:18 -04:00
/// <summary>
/// The amount of time it takes to devour a mob.
/// <remarks>
[DataField, AutoNetworkedField]
2023-05-16 00:44:35 +02:00
public float DevourTime = 3f ;
/// <summary>
2025-07-15 20:21:18 -04:00
/// The amount of time it takes to devour a structure.
2023-05-16 00:44:35 +02:00
/// <remarks>
/// NOTE: original intended design was to increase this proportionally with damage thresholds, but those proved quite difficult to get consistently. right now it devours the structure at a fixed timer.
/// </remarks>
/// </summary>
2025-07-15 20:21:18 -04:00
[DataField, AutoNetworkedField]
2023-05-16 00:44:35 +02:00
public float StructureDevourTime = 10f ;
2025-07-15 20:21:18 -04:00
/// <summary>
/// The sound to play when finishing devouring something.
/// </summary>
[DataField, AutoNetworkedField]
public SoundSpecifier ? SoundDevour = new SoundPathSpecifier ( "/Audio/Effects/demon_consume.ogg" )
{
Params = AudioParams . Default . WithVolume ( - 3f ) ,
} ;
/// <summary>
/// The sound to play when starting to devour a structure.
/// </summary>
[DataField, AutoNetworkedField]
2023-05-16 00:44:35 +02:00
public SoundSpecifier ? SoundStructureDevour = new SoundPathSpecifier ( "/Audio/Machines/airlock_creaking.ogg" )
{
Params = AudioParams . Default . WithVolume ( - 3f ) ,
} ;
2025-07-15 20:21:18 -04:00
/// <summary>
/// The container to store the eaten entities in.
/// </summary>
[ViewVariables]
public static string StomachContainerId = "stomach" ;
2023-05-16 00:44:35 +02:00
/// <summary>
/// Where the entities go when it devours them, empties when it is butchered.
/// </summary>
2025-07-15 20:21:18 -04:00
[ViewVariables]
2023-05-16 00:44:35 +02:00
public Container Stomach = default ! ;
2025-07-09 06:43:35 -06:00
/// <summary>
/// Determines what things the devourer can consume.
/// </summary>
2025-07-15 20:21:18 -04:00
[DataField, AutoNetworkedField]
2023-05-16 00:44:35 +02:00
public EntityWhitelist ? Whitelist = new ( )
{
Components = new [ ]
{
"MobState" ,
}
} ;
2025-07-09 06:43:35 -06:00
/// <summary>
/// Determines what things end up in the dragon's stomach if they eat it.
/// If it isn't in the whitelist, it's deleted.
/// </summary>
2025-07-15 20:21:18 -04:00
[DataField, AutoNetworkedField]
2025-07-09 06:43:35 -06:00
public EntityWhitelist ? StomachStorageWhitelist ;
/// <summary>
2025-07-15 20:21:18 -04:00
/// Determine's the dragon's food preference. If the eaten thing matches,
/// it is rewarded with the reward chemical. If null, all food is fine.
2025-07-09 06:43:35 -06:00
/// </summary>
2025-07-15 20:21:18 -04:00
[DataField, AutoNetworkedField]
2025-07-09 06:43:35 -06:00
public EntityWhitelist ? FoodPreferenceWhitelist ;
2023-05-16 00:44:35 +02:00
/// <summary>
2025-07-15 20:21:18 -04:00
/// The chemical ID injected upon devouring.
2023-05-16 00:44:35 +02:00
/// </summary>
2025-07-15 20:21:18 -04:00
[DataField, AutoNetworkedField]
public ProtoId < ReagentPrototype > Chemical = "Ichor" ;
2023-05-16 00:44:35 +02:00
/// <summary>
2025-07-15 20:21:18 -04:00
/// The amount of solution injected per devour.
2023-05-16 00:44:35 +02:00
/// </summary>
2025-07-15 20:21:18 -04:00
[DataField, AutoNetworkedField]
2023-05-16 00:44:35 +02:00
public float HealRate = 15f ;
}