Randomize wirecutter and screwdriver colors.

This commit is contained in:
Pieter-Jan Briers
2020-05-23 02:14:11 +02:00
parent ee47f72508
commit 1cb1bd5a8f
13 changed files with 92 additions and 5 deletions

View File

@@ -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<string, Color> _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<string, Color>());
}
void IMapInit.MapInit()
{
if (_colors == null)
{
return;
}
var random = IoCManager.Resolve<IRobustRandom>();
_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]);
}
}
}
}

View File

@@ -6,11 +6,25 @@
components: components:
- type: Wirecutter - type: Wirecutter
- type: Sprite - type: Sprite
texture: Objects/Tools/wirecutter.png sprite: Objects/Tools/wirecutters.rsi
layers:
- state: cutters-map
- state: cutters-cutty-thingy
- type: Icon - type: Icon
texture: Objects/Tools/wirecutter.png sprite: Objects/Tools/wirecutters.rsi
state: cutters-map
- type: ItemCooldown - type: ItemCooldown
- type: MeleeWeapon - type: MeleeWeapon
- type: RandomToolColor
state: cutters
colors:
blue: "#1861d5"
red: "#951710"
pink: "#d5188d"
brown: "#a05212"
green: "#0e7f1b"
cyan: "#18a2d5"
yellow: "#d58c18"
- type: entity - type: entity
name: Screwdriver name: Screwdriver
@@ -21,17 +35,30 @@
- type: Screwdriver - type: Screwdriver
- type: Sprite - type: Sprite
sprite: Objects/Tools/screwdriver.rsi sprite: Objects/Tools/screwdriver.rsi
state: screwdriver layers:
- state: screwdriver-map
- state: screwdriver-screwybits
- type: Icon - type: Icon
sprite: Objects/Tools/screwdriver.rsi sprite: Objects/Tools/screwdriver.rsi
state: screwdriver state: screwdriver-map
- type: Item - type: Item
sprite: Objects/Tools/screwdriver.rsi sprite: Objects/Tools/screwdriver.rsi
- type: ItemCooldown - type: ItemCooldown
- type: MeleeWeapon - type: MeleeWeapon
- type: RandomToolColor
state: screwdriver
colors:
blue: "#1861d5"
red: "#ff0000"
pink: "#d5188d"
brown: "#a05212"
green: "#0e7f1b"
cyan: "#18a2d5"
yellow: "#ffa500"
- type: entity - type: entity
name: Welding Tool name: Welding Tool

View File

@@ -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]]}]} {"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]]}]}

Binary file not shown.

After

Width:  |  Height:  |  Size: 178 B

Binary file not shown.

After

Width:  |  Height:  |  Size: 133 B

Binary file not shown.

Before

Width:  |  Height:  |  Size: 177 B

After

Width:  |  Height:  |  Size: 151 B

Binary file not shown.

Before

Width:  |  Height:  |  Size: 216 B

Binary file not shown.

After

Width:  |  Height:  |  Size: 172 B

Binary file not shown.

After

Width:  |  Height:  |  Size: 213 B

Binary file not shown.

After

Width:  |  Height:  |  Size: 156 B

Binary file not shown.

After

Width:  |  Height:  |  Size: 197 B

Binary file not shown.

After

Width:  |  Height:  |  Size: 190 B

View File

@@ -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]]}]}