diff --git a/Content.Server/GameObjects/Components/Damage/DamageOnLandComponent.cs b/Content.Server/GameObjects/Components/Damage/DamageOnLandComponent.cs new file mode 100644 index 0000000000..c5004baa97 --- /dev/null +++ b/Content.Server/GameObjects/Components/Damage/DamageOnLandComponent.cs @@ -0,0 +1,34 @@ +using Content.Shared.Damage; +using Content.Shared.GameObjects.Components.Damage; +using Content.Shared.Interfaces.GameObjects.Components; +using Robust.Shared.GameObjects; +using Robust.Shared.Serialization; + +namespace Content.Server.GameObjects.Components.Damage +{ + [RegisterComponent] + public class DamageOnLandComponent : Component, ILand + { + public override string Name => "DamageOnLand"; + + private DamageType _damageType; + private int _amount; + private bool _ignoreResistances; + + public override void ExposeData(ObjectSerializer serializer) + { + base.ExposeData(serializer); + + serializer.DataField(ref _damageType, "damageType", DamageType.Blunt); + serializer.DataField(ref _amount, "amount", 1); + serializer.DataField(ref _ignoreResistances, "ignoreResistances", false); + } + + public void Land(LandEventArgs eventArgs) + { + if (!Owner.TryGetComponent(out IDamageableComponent damageable)) return; + + damageable.ChangeDamage(_damageType, _amount, _ignoreResistances, eventArgs.User); + } + } +} diff --git a/Content.Server/GameObjects/Components/Damage/DamageOtherOnHitComponent.cs b/Content.Server/GameObjects/Components/Damage/DamageOtherOnHitComponent.cs new file mode 100644 index 0000000000..6722553fce --- /dev/null +++ b/Content.Server/GameObjects/Components/Damage/DamageOtherOnHitComponent.cs @@ -0,0 +1,34 @@ +using Content.Shared.Damage; +using Content.Shared.GameObjects.Components.Damage; +using Content.Shared.Interfaces.GameObjects.Components; +using Robust.Shared.GameObjects; +using Robust.Shared.Serialization; + +namespace Content.Server.GameObjects.Components.Damage +{ + [RegisterComponent] + public class DamageOtherOnHitComponent : Component, IThrowCollide + { + public override string Name => "DamageOtherOnHit"; + + private DamageType _damageType; + private int _amount; + private bool _ignoreResistances; + + public override void ExposeData(ObjectSerializer serializer) + { + base.ExposeData(serializer); + + serializer.DataField(ref _damageType, "damageType", DamageType.Blunt); + serializer.DataField(ref _amount, "amount", 1); + serializer.DataField(ref _ignoreResistances, "ignoreResistances", false); + } + + public void DoHit(ThrowCollideEventArgs eventArgs) + { + if (!eventArgs.Target.TryGetComponent(out IDamageableComponent damageable)) return; + + damageable.ChangeDamage(_damageType, _amount, _ignoreResistances, eventArgs.User); + } + } +} diff --git a/Content.Server/GameObjects/Components/Projectiles/ThrownItemComponent.cs b/Content.Server/GameObjects/Components/Projectiles/ThrownItemComponent.cs index afcac3a7af..a7e0423f97 100644 --- a/Content.Server/GameObjects/Components/Projectiles/ThrownItemComponent.cs +++ b/Content.Server/GameObjects/Components/Projectiles/ThrownItemComponent.cs @@ -29,7 +29,7 @@ namespace Content.Server.GameObjects.Components.Projectiles /// /// User who threw the item. /// - public IEntity User; + public IEntity User { get; set; } void ICollideBehavior.CollideWith(IEntity entity) { diff --git a/Resources/Prototypes/Entities/Objects/Consumable/drinks.yml b/Resources/Prototypes/Entities/Objects/Consumable/drinks.yml index 15a843e3c8..1130d17db7 100644 --- a/Resources/Prototypes/Entities/Objects/Consumable/drinks.yml +++ b/Resources/Prototypes/Entities/Objects/Consumable/drinks.yml @@ -24,6 +24,21 @@ components: - type: Drink isOpen: true + - type: Damageable + - type: Destructible + thresholds: + 5: + acts: [ "Destruction" ] + soundCollection: WindowBreak + spawn: + ShardGlass: + min: 1 + max: 1 + - type: DamageOnLand + amount: 5 + - type: DamageOtherOnHit + amount: 5 + # Transformable container - normal glass - type: entity @@ -33,7 +48,6 @@ components: - type: Sprite sprite: Objects/Consumable/Drinks/glass_clear.rsi - - type: SolutionContainer fillingState: glass maxVol: 50 diff --git a/Resources/Prototypes/Entities/Objects/shards.yml b/Resources/Prototypes/Entities/Objects/shards.yml index b9803cf51b..c5d1d6a1f8 100644 --- a/Resources/Prototypes/Entities/Objects/shards.yml +++ b/Resources/Prototypes/Entities/Objects/shards.yml @@ -18,6 +18,9 @@ damageType: Slash - type: Item sprite: Objects/Materials/Shards/shard.rsi + - type: DamageOtherOnHit + amount: 5 + damageType: Slash - type: entity id: ShardGlass @@ -47,6 +50,9 @@ refineResult: - GlassStack - MetalStack + - type: DamageOtherOnHit + amount: 10 + - type: entity id: ShardGlassPhoron name: phoron glass shard @@ -61,3 +67,5 @@ refineResult: - GlassStack - PhoronStack + - type: DamageOtherOnHit + amount: 15