@@ -60,21 +60,41 @@ namespace Content.Server.GameObjects.Components.Chemistry
|
|||||||
/// <returns></returns>
|
/// <returns></returns>
|
||||||
bool IInteractUsing.InteractUsing(InteractUsingEventArgs eventArgs)
|
bool IInteractUsing.InteractUsing(InteractUsingEventArgs eventArgs)
|
||||||
{
|
{
|
||||||
//Get target and check if it can be poured into
|
//Get target solution component
|
||||||
if (!Owner.TryGetComponent<SolutionComponent>(out var targetSolution))
|
if (!Owner.TryGetComponent<SolutionComponent>(out var targetSolution))
|
||||||
return false;
|
return false;
|
||||||
if (!targetSolution.CanPourIn)
|
|
||||||
|
//Get attack solution component
|
||||||
|
var attackEntity = eventArgs.Using;
|
||||||
|
if (!attackEntity.TryGetComponent<SolutionComponent>(out var attackSolution))
|
||||||
return false;
|
return false;
|
||||||
|
|
||||||
//Get attack entity and check if it can pour out.
|
// Calculate possibe solution transfer
|
||||||
var attackEntity = eventArgs.Using;
|
if (targetSolution.CanPourIn && attackSolution.CanPourOut)
|
||||||
if (!attackEntity.TryGetComponent<SolutionComponent>(out var attackSolution) || !attackSolution.CanPourOut)
|
{
|
||||||
|
// default logic (beakers and glasses)
|
||||||
|
// transfer solution from object in hand to attacked
|
||||||
|
return TryTransfer(eventArgs, attackSolution, targetSolution);
|
||||||
|
}
|
||||||
|
else if (targetSolution.CanPourOut && attackSolution.CanPourIn)
|
||||||
|
{
|
||||||
|
// storage tanks and sinks logic
|
||||||
|
// drain solution from attacked object to object in hand
|
||||||
|
return TryTransfer(eventArgs, targetSolution, attackSolution);
|
||||||
|
}
|
||||||
|
|
||||||
|
// No transfer possible
|
||||||
return false;
|
return false;
|
||||||
if (!attackEntity.TryGetComponent<PourableComponent>(out var attackPourable))
|
}
|
||||||
|
|
||||||
|
bool TryTransfer(InteractUsingEventArgs eventArgs, SolutionComponent fromSolution, SolutionComponent toSolution)
|
||||||
|
{
|
||||||
|
var fromEntity = fromSolution.Owner;
|
||||||
|
if (!fromEntity.TryGetComponent<PourableComponent>(out var fromPourable))
|
||||||
return false;
|
return false;
|
||||||
|
|
||||||
//Get transfer amount. May be smaller than _transferAmount if not enough room
|
//Get transfer amount. May be smaller than _transferAmount if not enough room
|
||||||
var realTransferAmount = ReagentUnit.Min(attackPourable.TransferAmount, targetSolution.EmptyVolume);
|
var realTransferAmount = ReagentUnit.Min(fromPourable.TransferAmount, toSolution.EmptyVolume);
|
||||||
if (realTransferAmount <= 0) //Special message if container is full
|
if (realTransferAmount <= 0) //Special message if container is full
|
||||||
{
|
{
|
||||||
_notifyManager.PopupMessage(Owner.Transform.GridPosition, eventArgs.User,
|
_notifyManager.PopupMessage(Owner.Transform.GridPosition, eventArgs.User,
|
||||||
@@ -83,8 +103,8 @@ namespace Content.Server.GameObjects.Components.Chemistry
|
|||||||
}
|
}
|
||||||
|
|
||||||
//Move units from attackSolution to targetSolution
|
//Move units from attackSolution to targetSolution
|
||||||
var removedSolution = attackSolution.SplitSolution(realTransferAmount);
|
var removedSolution = fromSolution.SplitSolution(realTransferAmount);
|
||||||
if (!targetSolution.TryAddSolution(removedSolution))
|
if (!toSolution.TryAddSolution(removedSolution))
|
||||||
return false;
|
return false;
|
||||||
|
|
||||||
_notifyManager.PopupMessage(Owner.Transform.GridPosition, eventArgs.User,
|
_notifyManager.PopupMessage(Owner.Transform.GridPosition, eventArgs.User,
|
||||||
|
|||||||
@@ -0,0 +1,20 @@
|
|||||||
|
- type: entity
|
||||||
|
parent: StorageTank
|
||||||
|
id: WeldingFuelTank
|
||||||
|
name: Fueltank
|
||||||
|
description: A storage tank containing welding fuel.
|
||||||
|
components:
|
||||||
|
- type: Sprite
|
||||||
|
texture: Buildings/weldtank.png
|
||||||
|
- type: Icon
|
||||||
|
texture: Buildings/weldtank.png
|
||||||
|
- type: Explosive
|
||||||
|
devastationRange: 1
|
||||||
|
heavyImpactRange: 2
|
||||||
|
lightImpactRange: 4
|
||||||
|
flashRange: 5
|
||||||
|
- type: Solution
|
||||||
|
contents:
|
||||||
|
reagents:
|
||||||
|
- ReagentId: chem.WeldingFuel
|
||||||
|
Quantity: 1500
|
||||||
@@ -0,0 +1,29 @@
|
|||||||
|
- type: entity
|
||||||
|
id: StorageTank
|
||||||
|
name: Storage Tank
|
||||||
|
description: "A liquids storage tank"
|
||||||
|
abstract: true
|
||||||
|
components:
|
||||||
|
- type: Clickable
|
||||||
|
- type: InteractionOutline
|
||||||
|
- type: Collidable
|
||||||
|
shapes:
|
||||||
|
- !type:PhysShapeAabb
|
||||||
|
bounds: "-0.5,-0.5,0.5,0.5"
|
||||||
|
mask: 30
|
||||||
|
layer: 31
|
||||||
|
IsScrapingFloor: true
|
||||||
|
- type: Physics
|
||||||
|
mass: 15
|
||||||
|
Anchored: false
|
||||||
|
- type: Damageable
|
||||||
|
- type: Destructible
|
||||||
|
thresholdvalue: 10
|
||||||
|
- type: Solution
|
||||||
|
maxVol: 1500
|
||||||
|
caps: 2
|
||||||
|
- type: Pourable
|
||||||
|
transferAmount: 100.0
|
||||||
|
placement:
|
||||||
|
snap:
|
||||||
|
- Wall
|
||||||
@@ -1,5 +1,5 @@
|
|||||||
- type: entity
|
- type: entity
|
||||||
parent: ReagentItem
|
parent: StorageTank
|
||||||
id: WaterTank
|
id: WaterTank
|
||||||
name: Water Tank
|
name: Water Tank
|
||||||
suffix: Empty
|
suffix: Empty
|
||||||
@@ -7,34 +7,9 @@
|
|||||||
components:
|
components:
|
||||||
- type: Sprite
|
- type: Sprite
|
||||||
texture: Buildings/watertank.png
|
texture: Buildings/watertank.png
|
||||||
|
|
||||||
- type: Icon
|
- type: Icon
|
||||||
texture: Buildings/watertank.png
|
texture: Buildings/watertank.png
|
||||||
|
|
||||||
- type: Clickable
|
|
||||||
- type: InteractionOutline
|
|
||||||
- type: Collidable
|
|
||||||
layer: 31
|
|
||||||
shape:
|
|
||||||
bounds: "-0.5,-0.25,0.5,0.25"
|
|
||||||
IsScrapingFloor: true
|
|
||||||
- type: Physics
|
|
||||||
mass: 15
|
|
||||||
Anchored: false
|
|
||||||
|
|
||||||
- type: Damageable
|
|
||||||
- type: Destructible
|
|
||||||
thresholdvalue: 10
|
|
||||||
|
|
||||||
- type: Solution
|
|
||||||
maxVol: 1500
|
|
||||||
caps: 3
|
|
||||||
|
|
||||||
|
|
||||||
placement:
|
|
||||||
snap:
|
|
||||||
- Wall
|
|
||||||
|
|
||||||
- type: entity
|
- type: entity
|
||||||
parent: WaterTank
|
parent: WaterTank
|
||||||
id: WaterTankFull
|
id: WaterTankFull
|
||||||
@@ -1,34 +0,0 @@
|
|||||||
- type: entity
|
|
||||||
id: WeldingFuelTank
|
|
||||||
name: Fueltank
|
|
||||||
description: A storage tank containing welding fuel.
|
|
||||||
components:
|
|
||||||
- type: Sprite
|
|
||||||
texture: Buildings/weldtank.png
|
|
||||||
|
|
||||||
- type: Icon
|
|
||||||
texture: Buildings/weldtank.png
|
|
||||||
|
|
||||||
- type: Clickable
|
|
||||||
- type: InteractionOutline
|
|
||||||
- type: Collidable
|
|
||||||
shapes:
|
|
||||||
- !type:PhysShapeAabb
|
|
||||||
bounds: "-0.5,-0.25,0.5,0.25"
|
|
||||||
layer: 15
|
|
||||||
IsScrapingFloor: true
|
|
||||||
- type: Physics
|
|
||||||
mass: 15
|
|
||||||
Anchored: false
|
|
||||||
- type: Damageable
|
|
||||||
- type: Destructible
|
|
||||||
thresholdvalue: 10
|
|
||||||
- type: Explosive
|
|
||||||
devastationRange: 1
|
|
||||||
heavyImpactRange: 2
|
|
||||||
lightImpactRange: 4
|
|
||||||
flashRange: 5
|
|
||||||
|
|
||||||
placement:
|
|
||||||
snap:
|
|
||||||
- Wall
|
|
||||||
Reference in New Issue
Block a user