Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Water balloons :3 :3 #33935

Open
wants to merge 8 commits into
base: master
Choose a base branch
from
Open
Show file tree
Hide file tree
Changes from 3 commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
18 changes: 18 additions & 0 deletions Content.Shared/WaterBalloon/WaterBalloonComponent.cs
Original file line number Diff line number Diff line change
@@ -0,0 +1,18 @@
using Content.Shared.Chemistry.Components;
using Content.Shared.FixedPoint;
Thinbug0 marked this conversation as resolved.
Show resolved Hide resolved

namespace Content.Shared.WaterBalloon;

[RegisterComponent]
public sealed partial class WaterBalloonComponent : Component
{
[DataField]
public FixedPoint2 MaxVolume = 10;
Thinbug0 marked this conversation as resolved.
Show resolved Hide resolved

[DataField]
public bool Filled = false;
Thinbug0 marked this conversation as resolved.
Show resolved Hide resolved

[DataField]
public string FilledPrototype = "FilledWaterBalloon";

Thinbug0 marked this conversation as resolved.
Show resolved Hide resolved
}
64 changes: 64 additions & 0 deletions Content.Shared/WaterBalloon/WaterBalloonSystem.cs
Original file line number Diff line number Diff line change
@@ -0,0 +1,64 @@
using Content.Shared.Chemistry.Components;
using Content.Shared.Chemistry.EntitySystems;
using Content.Shared.Sprite;
Thinbug0 marked this conversation as resolved.
Show resolved Hide resolved
using Robust.Shared.Network;
using Robust.Shared.Timing;
using Robust.Shared.Containers;

namespace Content.Shared.WaterBalloon;

public sealed class WaterBalloonSystem : EntitySystem
{
[Dependency] private readonly SharedSolutionContainerSystem _solutions = default!;
[Dependency] private readonly IGameTiming _gameTiming = default!;
[Dependency] private readonly INetManager _net = default!;
[Dependency] private readonly SharedContainerSystem _containerSystem = default!;

public override void Initialize()
{
SubscribeLocalEvent<WaterBalloonComponent, SolutionContainerChangedEvent>(CheckIfFull);
}

/// <summary>
/// Checks if the balloon has reached its MaxVolume value
/// </summary>
private void CheckIfFull(Entity<WaterBalloonComponent> ent, ref SolutionContainerChangedEvent args)
{
if (_gameTiming.IsFirstTimePredicted) //prevents bad prediction shenanigans
{
if (ent.Comp.MaxVolume == args.Solution.Volume)
{
if (args.Solution.Name == null)
return;

Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

spare line

TieBalloon(ent, args.Solution, args.Solution.Name); //send the entity solution and its name
}
}
Thinbug0 marked this conversation as resolved.
Show resolved Hide resolved
}

/// <summary>
/// Ties the balloon (deletes the entity and spawns a new one with the same solution and color)
/// </summary>
private void TieBalloon(Entity<WaterBalloonComponent> ent, Solution balloonSolution, string solutionName)
{
//keeps the balloon ghost away
if (!_net.IsServer)
return;

//drop empty balloon in the floor if its inside a container
if (_containerSystem.IsEntityInContainer(ent))
{
_containerSystem.TryRemoveFromContainer(ent);
}

var coords = Transform(ent).Coordinates;
EntityUid spawnedBalloon = EntityManager.SpawnEntity(ent.Comp.FilledPrototype, coords);

//fill the new balloon with the "empty" balloon solution
if (!_solutions.TryGetSolution(spawnedBalloon, solutionName, out var balloonContainer))
return;
_solutions.TryAddSolution(balloonContainer.Value, balloonSolution);

EntityManager.QueueDeleteEntity(ent);
}
}
10 changes: 10 additions & 0 deletions Resources/Prototypes/Catalog/Cargo/cargo_fun.yml
Original file line number Diff line number Diff line change
Expand Up @@ -88,6 +88,16 @@
category: cargoproduct-category-name-fun
group: market

- type: cargoProduct
id: FunWaterBalloons
icon:
sprite: Objects/Fun/water_balloons.rsi
state: water_balloon_cargo_icon
product: CrateWaterBalloons
cost: 500
category: cargoproduct-category-name-fun
group: market

- type: cargoProduct
id: FunPlushies
icon:
Expand Down
11 changes: 11 additions & 0 deletions Resources/Prototypes/Catalog/Fills/Crates/fun.yml
Original file line number Diff line number Diff line change
Expand Up @@ -277,6 +277,17 @@
- id: WeaponWaterPistol
amount: 4

- type: entity
id: CrateWaterBalloons
parent: CratePlastic
name: water balloons crate
description: Bring forth the splashing war with these silly balloons!
components:
- type: StorageFill
contents:
- id: BoxWaterBalloon
amount: 2
Thinbug0 marked this conversation as resolved.
Show resolved Hide resolved

- type: entity
id: CrateFunBoxing
parent: CrateGenericSteel
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -219,6 +219,7 @@
- id: PowerCellMedium
- id: PowerCellSmall
- id: Soap
- id: EmptyWaterBalloon
- id: Wirecutter
- id: Screwdriver
- id: Wrench
Expand Down Expand Up @@ -260,6 +261,7 @@
- id: ToolboxMechanicalFilled
- id: ClothingBeltUtility
- id: ToolboxArtisticFilled
- id: BoxWaterBalloon
- id: GeigerCounter
- id: trayScanner
- id: HandheldGPSBasic
Expand Down
106 changes: 106 additions & 0 deletions Resources/Prototypes/Entities/Objects/Fun/water_balloons.yml
Original file line number Diff line number Diff line change
@@ -0,0 +1,106 @@
- type: entity
parent: BaseItem
id: EmptyWaterBalloon
name: empty water balloon
description: Fill it up to reveal it's true color!
components:
- type: Sprite
sprite: Objects/Fun/water_balloons.rsi
layers:
- state: icon
- type: WaterBalloon
- type: Item
size: Tiny
- type: SolutionContainerManager
solutions:
balloon:
maxVol: 10
- type: DrawableSolution
solution: balloon
- type: RefillableSolution
solution: balloon
- type: DrainableSolution
solution: balloon
- type: ExaminableSolution
solution: balloon
- type: Spillable
solution: balloon

- type: entity
parent: BaseItem
id: FilledWaterBalloon
suffix: DO NOT SPAWN
name: water balloon
description: Ready to splash your enemies!
components:
- type: Sprite
sprite: Objects/Fun/water_balloons.rsi
layers:
- state: icon_inflated_fill-1
map: ["enum.SolutionContainerLayers.Fill"]
- state: icon_inflated
map: [ "spriteMap" ]
Thinbug0 marked this conversation as resolved.
Show resolved Hide resolved
- type: RandomSprite
available:
- spriteMap:
icon_inflated: Balloons
Thinbug0 marked this conversation as resolved.
Show resolved Hide resolved
- type: Item
size: Normal
- type: SolutionContainerManager
solutions:
balloon:
maxVol: 10
- type: ExaminableSolution
solution: balloon
- type: Spillable
solution: balloon
- type: Appearance
- type: SolutionContainerVisuals
maxFillLevels: 1
fillBaseName: icon_inflated_fill-
solutionName: balloon
- type: DamageOnLand
damage:
types:
Blunt: 5
- type: Damageable
damageContainer: Inorganic
- type: Destructible
thresholds:
- trigger:
!type:DamageTrigger
damage: 5
behaviors:
- !type:SpillBehavior
solution: balloon
- !type:PlaySoundBehavior
sound:
path: /Audio/Effects/Fluids/splash.ogg
- !type:DoActsBehavior
acts: [ "Destruction" ]

- type: entity
parent: BaseAmmoProvider
id: BoxWaterBalloon
suffix: Box
name: water balloons dispenser
description: Dispenses 25 colorful water balloons, Donk.Co is not responsible for any injuries.
components:
- type: Sprite
sprite: Objects/Fun/water_balloons.rsi
layers:
- state: water_balloon_box
Thinbug0 marked this conversation as resolved.
Show resolved Hide resolved
- type: Item
size: Normal
inhandVisuals:
left:
- state: water-balloon-box-inhand-left
right:
- state: water-balloon-box-inhand-right
Comment on lines +95 to +99
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

use heldPrefix

Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

im not sure what that is so ill figure it out later :33

Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

you can search for heldPrefix in repo and see how it's realized

- type: BallisticAmmoProvider
whitelist:
components:
- WaterBalloon
proto: EmptyWaterBalloon
capacity: 25

11 changes: 11 additions & 0 deletions Resources/Prototypes/Palettes/balloons.yml
Original file line number Diff line number Diff line change
@@ -0,0 +1,11 @@
- type: palette
id: Balloons
name: Balloons
colors:
red: "#fd538d"
pink: "#ff16ca"
green: "#66fd53"
cyanish: "#45ff80"
yellow: "#fff65b"
orange: "#ff16ca"
blue: "#500bfb"
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
34 changes: 34 additions & 0 deletions Resources/Textures/Objects/Fun/water_balloons.rsi/meta.json
Original file line number Diff line number Diff line change
@@ -0,0 +1,34 @@
{
"version": 1,
"license": "CC0-1.0",
"copyright": "Made by Thinbug for ss14 :33",
"size": {
"x": 32,
"y": 32
},
"states": [
{
"name": "icon"
},
{
"name": "icon_inflated"
},
{
"name": "icon_inflated_fill-1"
},
{
"name": "water_balloon_box"
},
{
"name": "water-balloon-box-inhand-left",
"directions": 4
},
{
"name": "water-balloon-box-inhand-right",
"directions": 4
},
{
"name": "water_balloon_cargo_icon"
}
]
}
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Loading