Sprite refactor (#63)

* Sprite refactor compatibility.

* Sprite-level rotation.

* Dude it works.

Welder now has an unshaded flame toggle!

Door component no longer on client!

* Remove debug text.

* Update.
This commit is contained in:
Pieter-Jan Briers
2018-05-08 08:20:15 +02:00
committed by clusterfack
parent 2ba705ffe9
commit 61a1e769d7
25 changed files with 181 additions and 224 deletions

View File

@@ -1,71 +0,0 @@
using Content.Shared.GameObjects;
using Lidgren.Network;
using SS14.Client.GameObjects;
using SS14.Shared.GameObjects;
using SS14.Shared.Utility;
using YamlDotNet.RepresentationModel;
namespace Content.Client.GameObjects
{
public class ClientDoorComponent : SharedDoorComponent
{
public bool Opened { get; private set; }
private SpriteComponent spriteComponent;
private string OpenSprite = "Objects/door_ewo.png";
private string CloseSprite = "Objects/door_ew.png";
public override void Initialize()
{
base.Initialize();
spriteComponent = Owner.GetComponent<SpriteComponent>();
}
private void Open()
{
Opened = true;
spriteComponent.SetSpriteByKey(OpenSprite);
}
private void Close()
{
Opened = false;
spriteComponent.SetSpriteByKey(CloseSprite);
}
public override void HandleComponentState(ComponentState state)
{
var castState = (DoorComponentState)state;
if (castState.Opened == Opened)
{
return;
}
if (castState.Opened)
{
Open();
}
else
{
Close();
}
}
public override void LoadParameters(YamlMappingNode mapping)
{
base.LoadParameters(mapping);
YamlNode node;
if (mapping.TryGetNode("openstate", out node))
{
OpenSprite = node.AsString();
}
if (mapping.TryGetNode("closestate", out node))
{
CloseSprite = node.AsString();
}
}
}
}

View File

@@ -71,7 +71,7 @@ namespace Content.Client.GameObjects
/// <param name="message"></param>
private void OpenMenu(object sender, BoundKeyChangedMessage message)
{
if(message.Function == BoundKeyFunctions.OpenCharacterMenu && message.State == BoundKeyState.Down)
if (message.Function == BoundKeyFunctions.OpenCharacterMenu && message.State == BoundKeyState.Down)
{
Window.AddToScreen();
Window.Open();
@@ -126,7 +126,7 @@ namespace Content.Client.GameObjects
GridContainer.Columns = elements_x;
IndexedSlots = new List<Slots>(inventory.SlotMasks);
foreach(Slots slot in IndexedSlots)
foreach (Slots slot in IndexedSlots)
{
InventoryButton newbutton = new InventoryButton(slot);
@@ -138,7 +138,7 @@ namespace Content.Client.GameObjects
else
{
//Store slot button and give it the default onpress behavior for empty elements
newbutton.GetChild<Button>("Button").OnPressed += AddToInventory;
newbutton.GetChild<Button>("Button").OnPressed += AddToInventory;
InventorySlots.Add(slot, newbutton);
}
@@ -146,7 +146,7 @@ namespace Content.Client.GameObjects
{
newbutton.GetChild<Button>("Button").Text = SlotNames[slot];
}
GridContainer.AddChild(newbutton);
}
}
@@ -166,9 +166,9 @@ namespace Content.Client.GameObjects
button.GetChild<Button>("Button").OnPressed -= AddToInventory;
//Gets entity sprite and assigns it to button texture
if (entity.TryGetComponent(out SpriteComponent sprite))
if (entity.TryGetComponent(out IconComponent sprite))
{
var tex = sprite.CurrentSprite;
var tex = sprite.Icon.Default;
var rect = button.GetChild("CenterContainer").GetChild<TextureRect>("TextureRect");
@@ -213,7 +213,6 @@ namespace Content.Client.GameObjects
InventoryComponent.SendEquipMessage(control.Slot);
}
}
private class InventoryButton : Control
{

View File

@@ -31,7 +31,7 @@ namespace Content.Client.GameObjects.Components.Storage
base.OnAdd();
Window = new StorageWindow()
{ StorageEntity = this};
{ StorageEntity = this };
}
public override void OnRemove()
@@ -97,10 +97,9 @@ namespace Content.Client.GameObjects.Components.Storage
public ClientStorageComponent StorageEntity;
protected override ResourcePath ScenePath => new ResourcePath("/Scenes/Storage/Storage.tscn");
protected override void Initialize()
{
base.Initialize();
HideOnClose = true;
@@ -117,12 +116,11 @@ namespace Content.Client.GameObjects.Components.Storage
public void BuildEntityList()
{
EntityList.DisposeAllChildren();
var storagelist = StorageEntity.StoredEntities;
foreach (var entityuid in storagelist)
{
var entity = IoCManager.Resolve<IEntityManager>().GetEntity(entityuid.Key);
var button = new EntityButton()
@@ -136,9 +134,9 @@ namespace Content.Client.GameObjects.Components.Storage
container.GetChild<Control>("Control").GetChild<Label>("Size").Text = string.Format("{0}", entityuid.Value);
//Gets entity sprite and assigns it to button texture
if (entity.TryGetComponent(out SpriteComponent sprite))
if (entity.TryGetComponent(out IconComponent icon))
{
var tex = sprite.CurrentSprite;
var tex = icon.Icon.Default;
var rect = container.GetChild("TextureWrap").GetChild<TextureRect>("TextureRect");
if (tex != null)
@@ -158,7 +156,7 @@ namespace Content.Client.GameObjects.Components.Storage
}
//Sets information about entire storage container current capacity
if(StorageEntity.StorageCapacityMax != 0)
if (StorageEntity.StorageCapacityMax != 0)
{
Information.Text = String.Format("Items: {0}, Stored: {1}/{2}", storagelist.Count, StorageEntity.StorageSizeUsed, StorageEntity.StorageCapacityMax);
}