From 1cb1bd5a8f6c6329fe80b82cc46bfa734234a120 Mon Sep 17 00:00:00 2001 From: Pieter-Jan Briers Date: Sat, 23 May 2020 02:14:11 +0200 Subject: [PATCH] Randomize wirecutter and screwdriver colors. --- .../Components/RandomToolColorComponent.cs | 59 ++++++++++++++++++ Resources/Prototypes/Entities/Items/tools.yml | 35 +++++++++-- .../Objects/Tools/screwdriver.rsi/meta.json | 2 +- .../Tools/screwdriver.rsi/screwdriver-map.png | Bin 0 -> 178 bytes .../screwdriver-screwybits.png | Bin 0 -> 133 bytes .../Tools/screwdriver.rsi/screwdriver.png | Bin 177 -> 151 bytes .../Textures/Objects/Tools/wirecutter.png | Bin 216 -> 0 bytes .../wirecutters.rsi/cutters-cutty-thingy.png | Bin 0 -> 172 bytes .../Tools/wirecutters.rsi/cutters-map.png | Bin 0 -> 213 bytes .../Objects/Tools/wirecutters.rsi/cutters.png | Bin 0 -> 156 bytes .../Tools/wirecutters.rsi/inhand-left.png | Bin 0 -> 197 bytes .../Tools/wirecutters.rsi/inhand-right.png | Bin 0 -> 190 bytes .../Objects/Tools/wirecutters.rsi/meta.json | 1 + 13 files changed, 92 insertions(+), 5 deletions(-) create mode 100644 Content.Server/GameObjects/Components/RandomToolColorComponent.cs create mode 100644 Resources/Textures/Objects/Tools/screwdriver.rsi/screwdriver-map.png create mode 100644 Resources/Textures/Objects/Tools/screwdriver.rsi/screwdriver-screwybits.png delete mode 100644 Resources/Textures/Objects/Tools/wirecutter.png create mode 100644 Resources/Textures/Objects/Tools/wirecutters.rsi/cutters-cutty-thingy.png create mode 100644 Resources/Textures/Objects/Tools/wirecutters.rsi/cutters-map.png create mode 100644 Resources/Textures/Objects/Tools/wirecutters.rsi/cutters.png create mode 100644 Resources/Textures/Objects/Tools/wirecutters.rsi/inhand-left.png create mode 100644 Resources/Textures/Objects/Tools/wirecutters.rsi/inhand-right.png create mode 100644 Resources/Textures/Objects/Tools/wirecutters.rsi/meta.json 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 0000000000000000000000000000000000000000..442f14902e0763e88c49c6d06341bee42d2f819f GIT binary patch literal 178 zcmeAS@N?(olHy`uVBq!ia0vp^3LwnF3?v&v(vJfvtpJ}8S0K%6TFPhDAYk7m;MgY; zv_&**pLpCkcX#)wsHlR1g38Lu&d$#DtJmymzjX+xnz1CvFPOpM*^M+H$IR2kF+}5h za)JbFGqVAgCMTDa0oMW6CExGe-Mcs74x`=zscB+TQc`kPE?O2}V_c(UaAtu714E28 W-<<2ZlRSVXFnGH9xvXsRWf+G`njxgN@xNAgUltx literal 0 HcmV?d00001 diff --git a/Resources/Textures/Objects/Tools/screwdriver.rsi/screwdriver.png b/Resources/Textures/Objects/Tools/screwdriver.rsi/screwdriver.png index b200e826b6dc1045ad794375bba1eb2fc43caabf..d0366ed70f9e81d1bdd4c6131d2d44330f4fb1ba 100644 GIT binary patch delta 122 zcmdnUIGu5VO0h(MPlzi614BlFz(Kw%+Ai>(qY`~?-$t7jLb%51D=bKX@`;LaJh^UN=j0%A~QHitw a9)?s6){3h!iyeU)89ZJ6T-G@yGywqVH!Q3G delta 149 zcmV;G0BZl20kHv)B!4PUOjJexfd3LYa1}#;d3kxStE?Dd)fY;P6jrPpS*Q*cI7dfE zT3T9gaBzuna**Z&RwXEQL=GcY{jX8oli z|5Q;HC}V1BdXke(Mn*TP zUajKfmJo9Y^(fSh*jn@S%*;8Q2F4Ai!WqxbY`ZGPQ+@$xg`KBzZnW<`J0O$6)78&q Iol`;+0L?H%FaQ7m 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 0000000000000000000000000000000000000000..0c96e5d41a7d8cb24a572d4ac18b6da6a4920f3f GIT binary patch literal 172 zcmeAS@N?(olHy`uVBq!ia0vp^3LwnF3?v&v(vJfvp#Yx{S0D`pl9G}#GBVoQ+NP$a zNAl%0fkKQWL4Lsu4$p3+0XZI?E{-7@=aUm8SVNe4nie%RH8Bna*S0D`pl9G}#GBVoQ+NP$a z^$ZNN85mA-vOVHveX1z?OGVz6Mcf^zh_NKdFPOpM*^M+HC*IS=F+}5ha)Jcw5~gn@ z0uDka?yxeoHZ5vuYGP7oJaz8exw7QsWMOe}arX%f(UFmnhMOBVY6mp9GAx{|s&V8% z<3Yw%i&~BzJbLx!jTw;)X>0*Ixi82#ui2KcqnV9?;YfwtI|U&_C6MbpUHx3vIVCg! E0H*6dKL7v# literal 0 HcmV?d00001 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 0000000000000000000000000000000000000000..ca7018e7462fcf3765951bdba51a60115dab40ff GIT binary patch literal 156 zcmeAS@N?(olHy`uVBq!ia0vp^3LwnF3?v&v(vJfv(Ey(iS0G(qUq5Nmq$Nw196EI9 z_!@pW9sSR7@~1LIYEMT36q+lfP;{LFDoN!OT(&_ zD_06`5_5BPbrs#y))cZrkvm~VVh($ literal 0 HcmV?d00001 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 0000000000000000000000000000000000000000..84a04457079c8ea81297898e6a76a4120074f372 GIT binary patch literal 197 zcmeAS@N?(olHy`uVBq!ia0vp^4j|0J3?w7mbKU|ep#Yx{S0F7TBcrXYZE9-zR8jVq zihTLq$P++O#*!evUp56Tj6Vfc0WD+jboFyt=akR{00ccY*8l(j literal 0 HcmV?d00001 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 0000000000000000000000000000000000000000..c1c689e5b90ff19cf2570d796a09bd287cfa4972 GIT binary patch literal 190 zcmeAS@N?(olHy`uVBq!ia0vp^4j|0J3?w7mbKU|ep#Yx{S0F7TBcrXYZE9-zR8jVq zihTLq$P++O#*!evU