diff --git a/CommunityEntity.UI.cs b/CommunityEntity.UI.cs index 9dafffa..0639f12 100644 --- a/CommunityEntity.UI.cs +++ b/CommunityEntity.UI.cs @@ -1,9 +1,10 @@ -using UnityEngine; +using UnityEngine; using System.Collections; using System.Collections.Generic; using System.Linq; using Facepunch.Extend; using System.IO; +using Rust.Workshop; #if CLIENT @@ -127,6 +128,33 @@ private void CreateComponents( GameObject go, JSON.Object obj ) SetImageFromServer( c, uint.Parse( obj.GetString( "png" ) ) ); } + if ( obj.ContainsKey( "itemid" ) ) + { + var itemdef = ItemManager.FindItemDefinition( obj.GetInt( "itemid" ) ); + if ( itemdef != null ) + { + c.sprite = itemdef.iconSprite; + + if ( obj.ContainsKey( "skinid" ) ) + { + var requestedSkin = obj.GetInt( "skinid" ); + var skin = itemdef.skins.FirstOrDefault( x => x.id == requestedSkin ); + if ( skin.id == requestedSkin ) + { + c.sprite = skin.invItem.icon; + } + else + { + var workshopSprite = WorkshopIconLoader.Find( (ulong)requestedSkin ); + if ( workshopSprite != null ) + { + c.sprite = workshopSprite; + } + } + } + } + } + GraphicComponentCreated( c, obj ); break;