decal system & crayons (#5183)

Co-authored-by: Paul <ritter.paul1+git@googlemail.com>
This commit is contained in:
Paul Ritter
2021-12-03 15:35:57 +01:00
committed by GitHub
parent 46a63d82b0
commit 219d91c6da
22 changed files with 2100 additions and 220 deletions

View File

@@ -1,29 +0,0 @@
using Content.Shared.Crayon;
using JetBrains.Annotations;
using Robust.Client.GameObjects;
using Robust.Shared.GameObjects;
using Robust.Shared.Maths;
namespace Content.Client.Crayon
{
[UsedImplicitly]
public class CrayonDecalVisualizer : AppearanceVisualizer
{
public override void OnChangeData(AppearanceComponent component)
{
base.OnChangeData(component);
var sprite = component.Owner.GetComponent<SpriteComponent>();
if (component.TryGetData(CrayonVisuals.State, out string state))
{
sprite.LayerSetState(0, state);
}
if (component.TryGetData(CrayonVisuals.Color, out string color))
{
sprite.LayerSetColor(0, Color.FromName(color));
}
}
}
}

View File

@@ -1,5 +1,6 @@
using System.Linq;
using Content.Shared.Crayon;
using Content.Shared.Decals;
using Robust.Client.GameObjects;
using Robust.Shared.GameObjects;
using Robust.Shared.IoC;
@@ -22,9 +23,8 @@ namespace Content.Client.Crayon.UI
_menu.OnClose += Close;
var prototypeManager = IoCManager.Resolve<IPrototypeManager>();
var crayonDecals = prototypeManager.EnumeratePrototypes<CrayonDecalPrototype>().FirstOrDefault();
if (crayonDecals != null)
_menu.Populate(crayonDecals);
var crayonDecals = prototypeManager.EnumeratePrototypes<DecalPrototype>().Where(x => x.Tags.Contains("crayon"));
_menu.Populate(crayonDecals);
_menu.OpenCentered();
}

View File

@@ -1,6 +1,7 @@
using System.Collections.Generic;
using Content.Client.Stylesheets;
using Content.Shared.Crayon;
using Content.Shared.Decals;
using Robust.Client.AutoGenerated;
using Robust.Client.Graphics;
using Robust.Client.UserInterface.Controls;
@@ -89,14 +90,12 @@ namespace Content.Client.Crayon.UI
RefreshList();
}
public void Populate(CrayonDecalPrototype proto)
public void Populate(IEnumerable<DecalPrototype> prototypes)
{
var path = new ResourcePath(proto.SpritePath);
_decals = new Dictionary<string, Texture>();
foreach (var state in proto.Decals)
foreach (var decalPrototype in prototypes)
{
var rsi = new SpriteSpecifier.Rsi(path, state);
_decals.Add(state, rsi.Frame0());
_decals.Add(decalPrototype.ID, decalPrototype.Sprite.Frame0());
}
RefreshList();