diff --git a/Content.Server/GameObjects/Components/RandomToolColorComponent.cs b/Content.Server/GameObjects/Components/RandomToolColorComponent.cs new file mode 100644 index 0000000000..ff761ea4bd --- /dev/null +++ b/Content.Server/GameObjects/Components/RandomToolColorComponent.cs @@ -0,0 +1,59 @@ +using System.Collections.Generic; +using Robust.Server.GameObjects; +using Robust.Server.Interfaces.GameObjects; +using Robust.Shared.GameObjects; +using Robust.Shared.Interfaces.Random; +using Robust.Shared.IoC; +using Robust.Shared.Maths; +using Robust.Shared.Random; +using Robust.Shared.Serialization; + +namespace Content.Server.GameObjects.Components +{ + [RegisterComponent] + public class RandomToolColorComponent : Component, IMapInit + { + public override string Name => "RandomToolColor"; + + private string _selectedColor; + private string _baseState; + private Dictionary _colors; + + public override void ExposeData(ObjectSerializer serializer) + { + base.ExposeData(serializer); + + serializer.DataField(ref _selectedColor, "selected", null); + serializer.DataField(ref _baseState, "state", "error"); + serializer.DataFieldCached(ref _colors, "colors", new Dictionary()); + } + + void IMapInit.MapInit() + { + if (_colors == null) + { + return; + } + + var random = IoCManager.Resolve(); + _selectedColor = random.Pick(_colors.Keys); + UpdateColor(); + } + + protected override void Startup() + { + base.Startup(); + + UpdateColor(); + } + + private void UpdateColor() + { + if (Owner.TryGetComponent(out SpriteComponent spriteComponent) && _colors != null && _selectedColor != null) + { + spriteComponent.LayerSetState(0, _baseState); + spriteComponent.LayerSetColor(0, _colors[_selectedColor]); + } + } + } +} diff --git a/Resources/Prototypes/Entities/Items/tools.yml b/Resources/Prototypes/Entities/Items/tools.yml index 78726f8f28..c013821ffe 100644 --- a/Resources/Prototypes/Entities/Items/tools.yml +++ b/Resources/Prototypes/Entities/Items/tools.yml @@ -6,11 +6,25 @@ components: - type: Wirecutter - type: Sprite - texture: Objects/Tools/wirecutter.png + sprite: Objects/Tools/wirecutters.rsi + layers: + - state: cutters-map + - state: cutters-cutty-thingy - type: Icon - texture: Objects/Tools/wirecutter.png + sprite: Objects/Tools/wirecutters.rsi + state: cutters-map - type: ItemCooldown - type: MeleeWeapon + - type: RandomToolColor + state: cutters + colors: + blue: "#1861d5" + red: "#951710" + pink: "#d5188d" + brown: "#a05212" + green: "#0e7f1b" + cyan: "#18a2d5" + yellow: "#d58c18" - type: entity name: Screwdriver @@ -21,17 +35,30 @@ - type: Screwdriver - type: Sprite sprite: Objects/Tools/screwdriver.rsi - state: screwdriver + layers: + - state: screwdriver-map + - state: screwdriver-screwybits - type: Icon sprite: Objects/Tools/screwdriver.rsi - state: screwdriver + state: screwdriver-map - type: Item sprite: Objects/Tools/screwdriver.rsi - type: ItemCooldown - type: MeleeWeapon + - type: RandomToolColor + state: screwdriver + colors: + blue: "#1861d5" + red: "#ff0000" + pink: "#d5188d" + brown: "#a05212" + green: "#0e7f1b" + cyan: "#18a2d5" + yellow: "#ffa500" + - type: entity name: Welding Tool diff --git a/Resources/Textures/Objects/Tools/screwdriver.rsi/meta.json b/Resources/Textures/Objects/Tools/screwdriver.rsi/meta.json index 8cc3c98bcc..3d7726dd8b 100644 --- a/Resources/Textures/Objects/Tools/screwdriver.rsi/meta.json +++ b/Resources/Textures/Objects/Tools/screwdriver.rsi/meta.json @@ -1 +1 @@ -{"version": 1, "size": {"x": 32, "y": 32}, "states": [{"name": "inhand-left", "directions": 4, "delays": [[1.0], [1.0], [1.0], [1.0]]}, {"name": "inhand-right", "directions": 4, "delays": [[1.0], [1.0], [1.0], [1.0]]}, {"name": "screwdriver", "directions": 1, "delays": [[1.0]]}]} \ No newline at end of file +{"version": 1, "size": {"x": 32, "y": 32}, "states": [{"name": "inhand-left", "directions": 4, "delays": [[1.0], [1.0], [1.0], [1.0]]}, {"name": "inhand-right", "directions": 4, "delays": [[1.0], [1.0], [1.0], [1.0]]}, {"name": "screwdriver", "directions": 1, "delays": [[1.0]]}, {"name": "screwdriver-map", "directions": 1, "delays": [[1.0]]}, {"name": "screwdriver-screwybits", "directions": 1, "delays": [[1.0]]}]} \ No newline at end of file diff --git a/Resources/Textures/Objects/Tools/screwdriver.rsi/screwdriver-map.png b/Resources/Textures/Objects/Tools/screwdriver.rsi/screwdriver-map.png new file mode 100644 index 0000000000..442f14902e Binary files /dev/null and b/Resources/Textures/Objects/Tools/screwdriver.rsi/screwdriver-map.png differ diff --git a/Resources/Textures/Objects/Tools/screwdriver.rsi/screwdriver-screwybits.png b/Resources/Textures/Objects/Tools/screwdriver.rsi/screwdriver-screwybits.png new file mode 100644 index 0000000000..f71f681402 Binary files /dev/null and b/Resources/Textures/Objects/Tools/screwdriver.rsi/screwdriver-screwybits.png differ diff --git a/Resources/Textures/Objects/Tools/screwdriver.rsi/screwdriver.png b/Resources/Textures/Objects/Tools/screwdriver.rsi/screwdriver.png index b200e826b6..d0366ed70f 100644 Binary files a/Resources/Textures/Objects/Tools/screwdriver.rsi/screwdriver.png and b/Resources/Textures/Objects/Tools/screwdriver.rsi/screwdriver.png differ diff --git a/Resources/Textures/Objects/Tools/wirecutter.png b/Resources/Textures/Objects/Tools/wirecutter.png deleted file mode 100644 index 08280e16b2..0000000000 Binary files a/Resources/Textures/Objects/Tools/wirecutter.png and /dev/null differ diff --git a/Resources/Textures/Objects/Tools/wirecutters.rsi/cutters-cutty-thingy.png b/Resources/Textures/Objects/Tools/wirecutters.rsi/cutters-cutty-thingy.png new file mode 100644 index 0000000000..0c96e5d41a Binary files /dev/null and b/Resources/Textures/Objects/Tools/wirecutters.rsi/cutters-cutty-thingy.png differ diff --git a/Resources/Textures/Objects/Tools/wirecutters.rsi/cutters-map.png b/Resources/Textures/Objects/Tools/wirecutters.rsi/cutters-map.png new file mode 100644 index 0000000000..48faa078cf Binary files /dev/null and b/Resources/Textures/Objects/Tools/wirecutters.rsi/cutters-map.png differ diff --git a/Resources/Textures/Objects/Tools/wirecutters.rsi/cutters.png b/Resources/Textures/Objects/Tools/wirecutters.rsi/cutters.png new file mode 100644 index 0000000000..ca7018e746 Binary files /dev/null and b/Resources/Textures/Objects/Tools/wirecutters.rsi/cutters.png differ diff --git a/Resources/Textures/Objects/Tools/wirecutters.rsi/inhand-left.png b/Resources/Textures/Objects/Tools/wirecutters.rsi/inhand-left.png new file mode 100644 index 0000000000..84a0445707 Binary files /dev/null and b/Resources/Textures/Objects/Tools/wirecutters.rsi/inhand-left.png differ diff --git a/Resources/Textures/Objects/Tools/wirecutters.rsi/inhand-right.png b/Resources/Textures/Objects/Tools/wirecutters.rsi/inhand-right.png new file mode 100644 index 0000000000..c1c689e5b9 Binary files /dev/null and b/Resources/Textures/Objects/Tools/wirecutters.rsi/inhand-right.png differ diff --git a/Resources/Textures/Objects/Tools/wirecutters.rsi/meta.json b/Resources/Textures/Objects/Tools/wirecutters.rsi/meta.json new file mode 100644 index 0000000000..3845160791 --- /dev/null +++ b/Resources/Textures/Objects/Tools/wirecutters.rsi/meta.json @@ -0,0 +1 @@ +{"version":1,"size":{"x":32,"y":32},"states":[{"name":"cutters","directions":1,"delays":[[1.0]]},{"name":"cutters-cutty-thingy","directions":1,"delays":[[1.0]]},{"name":"cutters-map","directions":1,"delays":[[1.0]]},{"name":"inhand-left","directions":4,"delays":[[1.0],[1.0],[1.0],[1.0]]},{"name":"inhand-right","directions":4,"delays":[[1.0],[1.0],[1.0],[1.0]]}]} \ No newline at end of file