ChemicalInjectionProjectileComponent (#2657)
Co-authored-by: py01 <pyronetics01@gmail.com>
This commit is contained in:
@@ -217,6 +217,7 @@
|
||||
"ConveyorAssembly",
|
||||
"TwoWayLever",
|
||||
"FirelockElectronics",
|
||||
"ChemicalInjectionProjectile",
|
||||
"Machine",
|
||||
"MachinePart",
|
||||
"MachineFrame",
|
||||
|
||||
@@ -0,0 +1,55 @@
|
||||
using Content.Server.GameObjects.Components.Body.Circulatory;
|
||||
using Content.Server.GameObjects.Components.Chemistry;
|
||||
using Content.Shared.Chemistry;
|
||||
using Robust.Shared.GameObjects;
|
||||
using Robust.Shared.GameObjects.Components;
|
||||
using Robust.Shared.Interfaces.GameObjects;
|
||||
using Robust.Shared.Serialization;
|
||||
using Robust.Shared.ViewVariables;
|
||||
using System;
|
||||
|
||||
namespace Content.Server.GameObjects.Components.Projectiles
|
||||
{
|
||||
[RegisterComponent]
|
||||
public class ChemicalInjectionProjectileComponent : Component, ICollideBehavior
|
||||
{
|
||||
public override string Name => "ChemicalInjectionProjectile";
|
||||
|
||||
[ViewVariables]
|
||||
private SolutionContainerComponent _solutionContainer;
|
||||
|
||||
[ViewVariables(VVAccess.ReadWrite)]
|
||||
public ReagentUnit TransferAmount { get; set; }
|
||||
|
||||
[ViewVariables(VVAccess.ReadWrite)]
|
||||
public float TransferEfficiency { get => _transferEfficiency; set => _transferEfficiency = Math.Clamp(value, 0, 1); }
|
||||
private float _transferEfficiency;
|
||||
|
||||
public override void ExposeData(ObjectSerializer serializer)
|
||||
{
|
||||
base.ExposeData(serializer);
|
||||
serializer.DataField(this, x => x.TransferAmount, "transferAmount", ReagentUnit.New(1));
|
||||
serializer.DataField(ref _transferEfficiency, "transferEfficiency", 1f);
|
||||
}
|
||||
|
||||
public override void Initialize()
|
||||
{
|
||||
base.Initialize();
|
||||
_solutionContainer = Owner.EnsureComponent<SolutionContainerComponent>();
|
||||
}
|
||||
|
||||
void ICollideBehavior.CollideWith(IEntity entity)
|
||||
{
|
||||
if (!entity.TryGetComponent<BloodstreamComponent>(out var bloodstream))
|
||||
return;
|
||||
|
||||
var solution = _solutionContainer.Solution;
|
||||
var solRemoved = solution.SplitSolution(TransferAmount);
|
||||
var solRemovedVol = solRemoved.TotalVolume;
|
||||
|
||||
var solToInject = solRemoved.SplitSolution(solRemovedVol * TransferEfficiency);
|
||||
|
||||
bloodstream.TryTransferSolution(solToInject);
|
||||
}
|
||||
}
|
||||
}
|
||||
@@ -1,4 +1,4 @@
|
||||
- type: entity
|
||||
- type: entity
|
||||
id: ShellShotgunBase
|
||||
name: shell (.50)
|
||||
parent: BaseItem
|
||||
@@ -87,3 +87,15 @@
|
||||
- type: Ammo
|
||||
projectile: PelletShotgun
|
||||
projectilesFired: 6
|
||||
|
||||
- type: entity
|
||||
id: ShellTranquilizer
|
||||
name: shell (.50 tranquilizer)
|
||||
parent: ShellShotgunBase
|
||||
components:
|
||||
- type: Sprite
|
||||
sprite: Objects/Weapons/Guns/Ammunition/Casings/shotgun_shell_practice.rsi
|
||||
- type: Ammo
|
||||
projectile: PelletShotgunTranquilizer
|
||||
projectilesFired: 1
|
||||
ammoSpread: 0
|
||||
|
||||
@@ -1,4 +1,4 @@
|
||||
- type: entity
|
||||
- type: entity
|
||||
id: PelletShotgunSlug
|
||||
name: pellet (.50 slug)
|
||||
abstract: true
|
||||
@@ -76,3 +76,24 @@
|
||||
- type: Projectile
|
||||
damages:
|
||||
Blunt: 1
|
||||
|
||||
- type: entity
|
||||
id: PelletShotgunTranquilizer
|
||||
name: pellet (.50 tranquilizer)
|
||||
abstract: true
|
||||
parent: BulletBasePractice
|
||||
components:
|
||||
- type: Sprite
|
||||
sprite: Objects/Weapons/Guns/Projectiles/buckshot.rsi
|
||||
state: base
|
||||
- type: Projectile
|
||||
damages:
|
||||
Blunt: 1
|
||||
- type: SolutionContainer
|
||||
maxVol: 10
|
||||
contents:
|
||||
reagents:
|
||||
- ReagentId: chem.H2O
|
||||
Quantity: 10
|
||||
caps: RemoveFrom
|
||||
- type: ChemicalInjectionProjectile
|
||||
|
||||
Reference in New Issue
Block a user