]> git.smokeofanarchy.ru Git - space-station-14.git/commitdiff
Water gun cargo crate (#16172)
authorNemanja <98561806+EmoGarbage404@users.noreply.github.com>
Sun, 7 May 2023 03:14:54 +0000 (23:14 -0400)
committerGitHub <noreply@github.com>
Sun, 7 May 2023 03:14:54 +0000 (13:14 +1000)
22 files changed:
Content.Client/Sprite/RandomSpriteSystem.cs
Content.Server/Sprite/RandomSpriteSystem.cs
Content.Shared/Sprite/RandomSpriteComponent.cs
Resources/Locale/en-US/prototypes/catalog/cargo/cargo-fun.ftl
Resources/Locale/en-US/prototypes/catalog/fills/crates/fun-crates.ftl
Resources/Prototypes/Catalog/Cargo/cargo_fun.yml
Resources/Prototypes/Catalog/Fills/Crates/fun.yml
Resources/Prototypes/Entities/Objects/Weapons/Guns/Basic/watergun.yml [new file with mode: 0644]
Resources/Prototypes/Entities/Objects/Weapons/Guns/Projectiles/projectiles.yml
Resources/Textures/Objects/Weapons/Guns/Pistols/soaker.rsi/detail1.png [new file with mode: 0644]
Resources/Textures/Objects/Weapons/Guns/Pistols/soaker.rsi/detail2.png [new file with mode: 0644]
Resources/Textures/Objects/Weapons/Guns/Pistols/soaker.rsi/icon.png [new file with mode: 0644]
Resources/Textures/Objects/Weapons/Guns/Pistols/soaker.rsi/inhand-left.png [new file with mode: 0644]
Resources/Textures/Objects/Weapons/Guns/Pistols/soaker.rsi/inhand-right.png [new file with mode: 0644]
Resources/Textures/Objects/Weapons/Guns/Pistols/soaker.rsi/meta.json [new file with mode: 0644]
Resources/Textures/Objects/Weapons/Guns/Pistols/water_pistol.rsi/detail.png [new file with mode: 0644]
Resources/Textures/Objects/Weapons/Guns/Pistols/water_pistol.rsi/display.png [new file with mode: 0644]
Resources/Textures/Objects/Weapons/Guns/Pistols/water_pistol.rsi/equipped-BELT.png [new file with mode: 0644]
Resources/Textures/Objects/Weapons/Guns/Pistols/water_pistol.rsi/icon.png [new file with mode: 0644]
Resources/Textures/Objects/Weapons/Guns/Pistols/water_pistol.rsi/inhand-left.png [new file with mode: 0644]
Resources/Textures/Objects/Weapons/Guns/Pistols/water_pistol.rsi/inhand-right.png [new file with mode: 0644]
Resources/Textures/Objects/Weapons/Guns/Pistols/water_pistol.rsi/meta.json [new file with mode: 0644]

index 30c0f8622ec8542be5e5215fe7f38fe0c975d17e..04f6681136c2705b5de4c2d0bd5e9e6bf419c91d 100644 (file)
@@ -45,14 +45,14 @@ public sealed class RandomSpriteSystem : SharedRandomSpriteSystem
             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;
                 }
             }
 
index 78ac6952585483781bcfe6713af52096ea506563..035f7c69034bebd7d8609c64380633bc290ccf35 100644 (file)
@@ -1,4 +1,3 @@
-using System.Linq;
 using Content.Shared.Decals;
 using Content.Shared.Sprite;
 using Robust.Shared.GameStates;
@@ -27,17 +26,29 @@ public sealed class RandomSpriteSystem: SharedRandomSpriteSystem
         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);
index d511b2b123fd5dfe312b895ff9bdbf426df1d03f..568ab6101c3c9ce3950d3bd7e6af98d0f8af47bb 100644 (file)
@@ -5,6 +5,13 @@ namespace Content.Shared.Sprite;
 [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)
index 48014ce0efc6fdad641e5b8bd905041ffdd371a2..d4c1d9ddf6b44a1fdf9d6e23a6d129590c86f945 100644 (file)
@@ -16,5 +16,8 @@ ent-FunBoardGames = { ent-CrateFunBoardGames }
 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
index 5eb24599c2119f20eb3a3ca68bc38c54ea08a28d..a79058b40af4ab7cea53d286783f8ebd9f1a5791 100644 (file)
@@ -37,6 +37,9 @@ ent-CrateFunLightImplants = Light Implants
 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.
 
index 97422e1a410cd94d0b97b79ca1aa3b9ea04ed70f..7d414334e84d7f1b41b0074a4197bbcf206b2ff1 100644 (file)
   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:
index 0c05dbe582414318f717d7d2391a1c11d09ebffb..d1d9c89cd1233fd2828f899456e0dd7f0c997638 100644 (file)
         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
diff --git a/Resources/Prototypes/Entities/Objects/Weapons/Guns/Basic/watergun.yml b/Resources/Prototypes/Entities/Objects/Weapons/Guns/Basic/watergun.yml
new file mode 100644 (file)
index 0000000..a2a25b5
--- /dev/null
@@ -0,0 +1,104 @@
+- 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
index 82b9c0f9b3dd796d3bda7776f5762b4683e5d4ed..642b4f8d0bd9eae288aa88ac8af5d765dc5de383 100644 (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
diff --git a/Resources/Textures/Objects/Weapons/Guns/Pistols/soaker.rsi/detail1.png b/Resources/Textures/Objects/Weapons/Guns/Pistols/soaker.rsi/detail1.png
new file mode 100644 (file)
index 0000000..ed001bb
Binary files /dev/null and b/Resources/Textures/Objects/Weapons/Guns/Pistols/soaker.rsi/detail1.png differ
diff --git a/Resources/Textures/Objects/Weapons/Guns/Pistols/soaker.rsi/detail2.png b/Resources/Textures/Objects/Weapons/Guns/Pistols/soaker.rsi/detail2.png
new file mode 100644 (file)
index 0000000..dc436f3
Binary files /dev/null and b/Resources/Textures/Objects/Weapons/Guns/Pistols/soaker.rsi/detail2.png differ
diff --git a/Resources/Textures/Objects/Weapons/Guns/Pistols/soaker.rsi/icon.png b/Resources/Textures/Objects/Weapons/Guns/Pistols/soaker.rsi/icon.png
new file mode 100644 (file)
index 0000000..99f79d1
Binary files /dev/null and b/Resources/Textures/Objects/Weapons/Guns/Pistols/soaker.rsi/icon.png differ
diff --git a/Resources/Textures/Objects/Weapons/Guns/Pistols/soaker.rsi/inhand-left.png b/Resources/Textures/Objects/Weapons/Guns/Pistols/soaker.rsi/inhand-left.png
new file mode 100644 (file)
index 0000000..d1d2748
Binary files /dev/null and b/Resources/Textures/Objects/Weapons/Guns/Pistols/soaker.rsi/inhand-left.png differ
diff --git a/Resources/Textures/Objects/Weapons/Guns/Pistols/soaker.rsi/inhand-right.png b/Resources/Textures/Objects/Weapons/Guns/Pistols/soaker.rsi/inhand-right.png
new file mode 100644 (file)
index 0000000..9102333
Binary files /dev/null and b/Resources/Textures/Objects/Weapons/Guns/Pistols/soaker.rsi/inhand-right.png differ
diff --git a/Resources/Textures/Objects/Weapons/Guns/Pistols/soaker.rsi/meta.json b/Resources/Textures/Objects/Weapons/Guns/Pistols/soaker.rsi/meta.json
new file mode 100644 (file)
index 0000000..8652914
--- /dev/null
@@ -0,0 +1,28 @@
+{
+  "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
+    }
+  ]
+}
diff --git a/Resources/Textures/Objects/Weapons/Guns/Pistols/water_pistol.rsi/detail.png b/Resources/Textures/Objects/Weapons/Guns/Pistols/water_pistol.rsi/detail.png
new file mode 100644 (file)
index 0000000..dd3be00
Binary files /dev/null and b/Resources/Textures/Objects/Weapons/Guns/Pistols/water_pistol.rsi/detail.png differ
diff --git a/Resources/Textures/Objects/Weapons/Guns/Pistols/water_pistol.rsi/display.png b/Resources/Textures/Objects/Weapons/Guns/Pistols/water_pistol.rsi/display.png
new file mode 100644 (file)
index 0000000..34b9b66
Binary files /dev/null and b/Resources/Textures/Objects/Weapons/Guns/Pistols/water_pistol.rsi/display.png differ
diff --git a/Resources/Textures/Objects/Weapons/Guns/Pistols/water_pistol.rsi/equipped-BELT.png b/Resources/Textures/Objects/Weapons/Guns/Pistols/water_pistol.rsi/equipped-BELT.png
new file mode 100644 (file)
index 0000000..34c982e
Binary files /dev/null and b/Resources/Textures/Objects/Weapons/Guns/Pistols/water_pistol.rsi/equipped-BELT.png differ
diff --git a/Resources/Textures/Objects/Weapons/Guns/Pistols/water_pistol.rsi/icon.png b/Resources/Textures/Objects/Weapons/Guns/Pistols/water_pistol.rsi/icon.png
new file mode 100644 (file)
index 0000000..ad794d6
Binary files /dev/null and b/Resources/Textures/Objects/Weapons/Guns/Pistols/water_pistol.rsi/icon.png differ
diff --git a/Resources/Textures/Objects/Weapons/Guns/Pistols/water_pistol.rsi/inhand-left.png b/Resources/Textures/Objects/Weapons/Guns/Pistols/water_pistol.rsi/inhand-left.png
new file mode 100644 (file)
index 0000000..9a9200b
Binary files /dev/null and b/Resources/Textures/Objects/Weapons/Guns/Pistols/water_pistol.rsi/inhand-left.png differ
diff --git a/Resources/Textures/Objects/Weapons/Guns/Pistols/water_pistol.rsi/inhand-right.png b/Resources/Textures/Objects/Weapons/Guns/Pistols/water_pistol.rsi/inhand-right.png
new file mode 100644 (file)
index 0000000..13eed59
Binary files /dev/null and b/Resources/Textures/Objects/Weapons/Guns/Pistols/water_pistol.rsi/inhand-right.png differ
diff --git a/Resources/Textures/Objects/Weapons/Guns/Pistols/water_pistol.rsi/meta.json b/Resources/Textures/Objects/Weapons/Guns/Pistols/water_pistol.rsi/meta.json
new file mode 100644 (file)
index 0000000..d6261bf
--- /dev/null
@@ -0,0 +1,32 @@
+{
+  "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
+    }
+  ]
+}