if (_reflection.TryParseEnumReference(layer.Key, out var @enum))
{
if (!sprite.LayerMapTryGet(@enum, out index, logError: true))
- return;
+ continue;
}
else if (!sprite.LayerMapTryGet(layer.Key, out index))
{
- if (layer.Key is not string strKey || !int.TryParse(strKey, out index))
+ if (layer.Key is not { } strKey || !int.TryParse(strKey, out index))
{
Logger.Error($"Invalid key `{layer.Key}` for entity with random sprite {ToPrettyString(uid)}");
- return;
+ continue;
}
}
-using System.Linq;
using Content.Shared.Decals;
using Content.Shared.Sprite;
using Robust.Shared.GameStates;
if (component.Available.Count == 0)
return;
- var group = _random.Pick(component.Available);
- component.Selected.EnsureCapacity(group.Count);
+ var groups = new List<Dictionary<string, (string, string?)>>();
+ if (component.GetAllGroups)
+ {
+ groups = component.Available;
+ }
+ else
+ {
+ groups.Add(_random.Pick(component.Available));
+ }
+
+ component.Selected.EnsureCapacity(groups.Count);
- foreach (var layer in group)
+ foreach (var group in groups)
{
- Color? color = null;
+ foreach (var layer in group)
+ {
+ Color? color = null;
- if (!string.IsNullOrEmpty(layer.Value.Color))
- color = _random.Pick(_prototype.Index<ColorPalettePrototype>(layer.Value.Color).Colors.Values);
+ if (!string.IsNullOrEmpty(layer.Value.Item2))
+ color = _random.Pick(_prototype.Index<ColorPalettePrototype>(layer.Value.Item2).Colors.Values);
- component.Selected.Add(layer.Key, (layer.Value.State, color));
+ component.Selected.Add(layer.Key, (layer.Value.Item1, color));
+ }
}
Dirty(component);
[RegisterComponent, NetworkedComponent]
public sealed class RandomSpriteComponent : Component
{
+ /// <summary>
+ /// Whether or not all groups from <see cref="Available"/> are used,
+ /// or if only one is picked at random.
+ /// </summary>
+ [DataField("getAllGroups")]
+ public bool GetAllGroups;
+
/// <summary>
/// Available colors based on group, parsed layer enum, state, and color.
/// Stored as a list so we can have groups of random sprites (e.g. tech_base + tech_flare for holoparasite)
ent-FunATV = { ent-CrateFunATV }
.desc = { ent-CrateFunATV.desc }
+ent-FunWaterGuns = { ent-CrateFunWaterGuns }
+ .desc = { ent-CrateFunWaterGuns.desc }
+
ent-FunParty = { ent-CrateFunParty }
.desc = { ent-CrateFunParty.desc }
\ No newline at end of file
ent-CrateFunParty = Party Crate
.desc = An entire party just waiting for you to open it. Includes party favors, party beverages, and even a cake.
+ent-CrateFunWaterGuns = Water Gun Crate
+ .desc = A summer special with a variety of brightly colored water guns. Water not included.
+
ent-CrateFunSyndicateSegway = Syndicate segway crate
.desc = A crate containing a two-wheeler that will help you escape from the security officers. Or not.
category: Fun
group: market
+- type: cargoProduct
+ id: CrateFunWaterGuns
+ icon:
+ sprite: Objects/Weapons/Guns/Pistols/water_pistol.rsi
+ state: display
+ product: CrateFunWaterGuns
+ cost: 750
+ category: Fun
+ group: market
+
- type: cargoProduct
id: FunPlushies
icon:
amount: 4
- id: KnifePlastic
+- type: entity
+ id: CrateFunWaterGuns
+ parent: CratePlastic
+ components:
+ - type: StorageFill
+ contents:
+ - id: WeaponWaterBlaster
+ - id: WeaponWaterPistol
+ amount: 5
+
- type: entity
id: CrateFunSyndicateSegway
parent: CrateLivestock
--- /dev/null
+- type: entity
+ id: WeaponWaterGunBase
+ abstract: true
+ parent: BaseItem
+ components:
+ - type: Sprite
+ sprite: Objects/Weapons/Guns/Pistols/water_pistol.rsi
+ - type: Clothing
+ sprite: Objects/Weapons/Guns/Pistols/water_pistol.rsi
+ slots: BELT
+ - type: Item
+ sprite: Objects/Weapons/Guns/Pistols/water_pistol.rsi
+ size: 10
+ - type: Gun
+ cameraRecoilScalar: 0 #no recoil
+ fireRate: 1
+ selectedMode: SemiAuto
+ availableModes:
+ - SemiAuto
+ soundGunshot:
+ path: /Audio/Weapons/Guns/Gunshots/water_spray.ogg
+ - type: SolutionContainerManager
+ solutions:
+ chamber:
+ maxVol: 50 #5 shots
+ - type: SolutionAmmoProvider
+ solutionId: chamber
+ proto: BulletWaterShot
+ - type: SolutionTransfer
+ transferAmount: 10
+ maxTransferAmount: 50
+ minTransferAmount: 5
+ canChangeTransferAmount: true
+ - type: UserInterface
+ interfaces:
+ - key: enum.TransferAmountUiKey.Key
+ type: TransferAmountBoundUserInterface
+ - type: DrawableSolution
+ solution: chamber
+ - type: RefillableSolution
+ solution: chamber
+ - type: DrainableSolution
+ solution: chamber
+ - type: ExaminableSolution
+ solution: chamber
+ - type: StaticPrice
+ price: 100
+ - type: PhysicalComposition
+ materialComposition:
+ Plastic: 150
+
+- type: entity
+ id: WeaponWaterPistol
+ parent: WeaponWaterGunBase
+ name: water pistol
+ description: The dinkiest of water-based weaponry. You swear the trigger doesn't do anything.
+ components:
+ - type: Sprite
+ sprite: Objects/Weapons/Guns/Pistols/water_pistol.rsi
+ layers:
+ - state: detail
+ - state: icon
+ map: [ "enum.DamageStateVisualLayers.Base" ]
+ - type: RandomSprite
+ available:
+ - enum.DamageStateVisualLayers.Base:
+ icon: Rainbow
+
+- type: entity
+ id: WeaponWaterBlaster
+ parent: WeaponWaterGunBase
+ name: water blaster
+ description: With this bad boy, you'll be the cooleste kid at the summer barbecue.
+ components:
+ - type: Gun
+ cameraRecoilScalar: 0 #no recoil
+ fireRate: 2
+ selectedMode: FullAuto
+ availableModes:
+ - FullAuto
+ soundGunshot:
+ path: /Audio/Weapons/Guns/Gunshots/water_spray.ogg
+ - type: SolutionContainerManager
+ solutions:
+ chamber:
+ maxVol: 100 #10 shots
+ - type: Sprite
+ sprite: Objects/Weapons/Guns/Pistols/soaker.rsi
+ layers:
+ - state: detail1
+ - state: detail2
+ map: ["enum.PowerDeviceVisualLayers.Powered"]
+ - state: icon
+ map: [ "enum.DamageStateVisualLayers.Base" ]
+ - type: Item
+ sprite: Objects/Weapons/Guns/Pistols/soaker.rsi
+ size: 35
+ - type: RandomSprite
+ getAllGroups: true
+ available:
+ - enum.DamageStateVisualLayers.Base:
+ icon: Rainbow
+ - enum.PowerDeviceVisualLayers.Powered:
+ detail2: Sixteen
\ No newline at end of file
fix1:
shape:
!type:PhysShapeAabb
- bounds: "-0.25,-0.25,0.25,0.25"
+ bounds: "-0.10,-0.30,0.10,0.15"
hard: false
mask:
- FullTileMask
--- /dev/null
+{
+ "version": 1,
+ "license": "CC0-1.0",
+ "copyright": "Created by EmoGarbage404 (github) for Space Station 14",
+ "size": {
+ "x": 32,
+ "y": 32
+ },
+ "states": [
+ {
+ "name": "detail1"
+ },
+ {
+ "name": "detail2"
+ },
+ {
+ "name": "icon"
+ },
+ {
+ "name": "inhand-left",
+ "directions": 4
+ },
+ {
+ "name": "inhand-right",
+ "directions": 4
+ }
+ ]
+}
--- /dev/null
+{
+ "version": 1,
+ "license": "CC0-1.0",
+ "copyright": "Created by EmoGarbage404 (github) for Space Station 14",
+ "size": {
+ "x": 32,
+ "y": 32
+ },
+ "states": [
+ {
+ "name": "icon"
+ },
+ {
+ "name": "display"
+ },
+ {
+ "name": "detail"
+ },
+ {
+ "name": "inhand-left",
+ "directions": 4
+ },
+ {
+ "name": "inhand-right",
+ "directions": 4
+ },
+ {
+ "name": "equipped-BELT",
+ "directions": 4
+ }
+ ]
+}