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

@@ -73,7 +73,6 @@
<Compile Include="GameObjects\Components\Storage\ClientStorageComponent.cs" />
<Compile Include="Properties\AssemblyInfo.cs" />
<Compile Include="GameObjects\Components\Items\ClientHandsComponent.cs" />
<Compile Include="GameObjects\Components\Doors\ClientDoorComponent.cs" />
<Compile Include="Interfaces\GameObjects\Components\Items\IHandsComponent.cs" />
<Compile Include="UserInterface\HandsGui.cs" />
</ItemGroup>

View File

@@ -42,8 +42,6 @@ namespace Content.Client
factory.Register<HandsComponent>();
factory.RegisterReference<HandsComponent, IHandsComponent>();
factory.Register<ClientStorageComponent>();
factory.Register<ClientDoorComponent>();
factory.Register<ClientInventoryComponent>();
}
}

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);
@@ -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");
@@ -214,7 +214,6 @@ namespace Content.Client.GameObjects
}
}
private class InventoryButton : Control
{
public Slots Slot;

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()
@@ -100,7 +100,6 @@ namespace Content.Client.GameObjects.Components.Storage
protected override void Initialize()
{
base.Initialize();
HideOnClose = true;
@@ -122,7 +121,6 @@ namespace Content.Client.GameObjects.Components.Storage
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);
}

View File

@@ -208,7 +208,7 @@ namespace Content.Client.UserInterface
{
if (entity.TryGetComponent<IconComponent>(out var component) && component.Icon != null)
{
return component.Icon;
return component.Icon.Default;
}
return IoCManager.Resolve<IResourceCache>().GetFallback<TextureResource>();
}

View File

@@ -3,6 +3,7 @@ using Content.Server.Interfaces.GameObjects;
using Content.Shared.GameObjects;
using SS14.Server.GameObjects;
using SS14.Shared.GameObjects;
using SS14.Shared.GameObjects.Serialization;
using SS14.Shared.Interfaces.GameObjects;
using SS14.Shared.Interfaces.GameObjects.Components;
using SS14.Shared.Log;
@@ -12,13 +13,26 @@ using Content.Server.GameObjects.EntitySystems;
namespace Content.Server.GameObjects
{
public class ServerDoorComponent : SharedDoorComponent, IAttackHand
public class ServerDoorComponent : Component, IAttackHand
{
public override string Name => "Door";
public bool Opened { get; private set; }
private float OpenTimeCounter;
private CollidableComponent collidableComponent;
private SpriteComponent spriteComponent;
private string OpenSprite;
private string CloseSprite;
public override void ExposeData(EntitySerializer serializer)
{
base.ExposeData(serializer);
serializer.DataField(ref OpenSprite, "openstate", "Objects/door_ewo.png");
serializer.DataField(ref CloseSprite, "closestate", "Objects/door_ew.png");
}
public override void Initialize()
{
@@ -26,12 +40,14 @@ namespace Content.Server.GameObjects
collidableComponent = Owner.GetComponent<CollidableComponent>();
collidableComponent.OnBump += OnBump;
spriteComponent = Owner.GetComponent<SpriteComponent>();
}
public override void OnRemove()
{
collidableComponent.OnBump -= OnBump;
collidableComponent = null;
spriteComponent = null;
}
public bool Attackhand(IEntity user)
@@ -62,6 +78,7 @@ namespace Content.Server.GameObjects
{
Opened = true;
collidableComponent.IsHardCollidable = false;
spriteComponent.LayerSetTexture(0, OpenSprite);
}
public bool Close()
@@ -74,14 +91,10 @@ namespace Content.Server.GameObjects
Opened = false;
OpenTimeCounter = 0;
collidableComponent.IsHardCollidable = true;
spriteComponent.LayerSetTexture(0, CloseSprite);
return true;
}
public override ComponentState GetComponentState()
{
return new DoorComponentState(Opened);
}
private const float AUTO_CLOSE_DELAY = 5;
public override void Update(float frameTime)
{

View File

@@ -11,6 +11,8 @@ namespace Content.Server.GameObjects.Components.Interactable.Tools
/// </summary>
class WelderComponent : ToolComponent, EntitySystems.IUse
{
SpriteComponent spriteComponent;
public override string Name => "Welder";
/// <summary>
@@ -41,6 +43,13 @@ namespace Content.Server.GameObjects.Components.Interactable.Tools
//private string OnSprite { get; set; }
//private string OffSprite { get; set; }
public override void Initialize()
{
base.Initialize();
spriteComponent = Owner.GetComponent<SpriteComponent>();
}
public override void LoadParameters(YamlMappingNode mapping)
{
base.LoadParameters(mapping);
@@ -72,9 +81,14 @@ namespace Content.Server.GameObjects.Components.Interactable.Tools
public override void Update(float frameTime)
{
Fuel = Math.Min(Fuel - FuelLossRate, 0);
if (!Activated)
{
return;
}
if(Activated && Fuel == 0)
Fuel = Math.Max(Fuel - (FuelLossRate * frameTime), 0);
if (Fuel == 0)
{
ToggleStatus();
}
@@ -106,18 +120,17 @@ namespace Content.Server.GameObjects.Components.Interactable.Tools
/// <returns></returns>
public bool ToggleStatus()
{
if(Activated)
if (Activated)
{
Activated = false;
//TODO : Change sprite on deactivation
// Layer 1 is the flame.
spriteComponent.LayerSetVisible(1, false);
return true;
}
else if(CanActivate())
else if (CanActivate())
{
Activated = true;
//TODO : Change sprite on activation
spriteComponent.LayerSetVisible(1, true);
return true;
}
else

View File

@@ -64,7 +64,6 @@
</ItemGroup>
<ItemGroup>
<Compile Include="EntryPoint.cs" />
<Compile Include="GameObjects\Components\Doors\SharedDoorComponent.cs" />
<Compile Include="GameObjects\Components\Inventory\EquipmentSlotDefinitions.cs" />
<Compile Include="GameObjects\Components\Inventory\InventoryTemplates.cs" />
<Compile Include="GameObjects\Components\Inventory\SharedInventoryComponent.cs" />

View File

@@ -1,23 +0,0 @@
using System;
using SS14.Shared.GameObjects;
namespace Content.Shared.GameObjects
{
public abstract class SharedDoorComponent : Component
{
public override string Name => "Door";
public override uint? NetID => ContentNetIDs.DOOR;
public override Type StateType => typeof(DoorComponentState);
}
[Serializable]
public class DoorComponentState : ComponentState
{
public readonly bool Opened;
public DoorComponentState(bool opened) : base(ContentNetIDs.DOOR)
{
Opened = opened;
}
}
}

View File

@@ -7,7 +7,6 @@
public const uint DESTRUCTIBLE = 1001;
public const uint TEMPERATURE = 1002;
public const uint HANDS = 1003;
public const uint DOOR = 1004;
public const uint STORAGE = 1005;
public const uint INVENTORY = 1006;
}

View File

@@ -5,11 +5,10 @@
- type: Transform
- type: Clickable
- type: Sprite
sprites:
- Items/shoes.png
texture: Items/shoes.png
- type: Icon
icon: Items/shoes.png
texture: Items/shoes.png
- type: Damageable
resistanceset: Standard

View File

@@ -16,9 +16,11 @@
name: Shoes
components:
- type: Sprite
sprite: Items/shoes.png
texture: Items/shoes.png
- type: Icon
icon: Items/shoes.png
texture: Items/shoes.png
- type: Clothing
Slots:
- shoes
@@ -29,9 +31,11 @@
name: Janitor Jumpsuit
components:
- type: Sprite
sprite: Items/janitorsuit.png
texture: Items/janitorsuit.png
- type: Icon
icon: Items/janitorsuit.png
texture: Items/janitorsuit.png
- type: Clothing
Slots:
- innerclothing
@@ -42,9 +46,9 @@
name: Security Vest
components:
- type: Sprite
sprite: Clothing/armorvest.png
texture: Clothing/armorvest.png
- type: Icon
icon: Clothing/armorvest.png
texture: Clothing/armorvest.png
- type: Clothing
Slots:
- outerclothing
@@ -55,9 +59,9 @@
name: Utility Belt
components:
- type: Sprite
sprite: Clothing/belt_utility.png
texture: Clothing/belt_utility.png
- type: Icon
icon: Clothing/belt_utility.png
texture: Clothing/belt_utility.png
Size: 30
- type: Clothing
Slots:
@@ -71,9 +75,9 @@
name: Backpack
components:
- type: Sprite
sprite: Clothing/backpack.png
texture: Clothing/backpack.png
- type: Icon
icon: Clothing/backpack.png
texture: Clothing/backpack.png
Size: 9999
- type: Clothing
Slots:
@@ -87,9 +91,9 @@
name: Mesons
components:
- type: Sprite
sprite: Clothing/glasses_meson.png
texture: Clothing/glasses_meson.png
- type: Icon
icon: Clothing/glasses_meson.png
texture: Clothing/glasses_meson.png
- type: Clothing
Slots:
- eyes
@@ -100,9 +104,9 @@
name: Insulated Gloves
components:
- type: Sprite
sprite: Clothing/gloves_yellow.png
texture: Clothing/gloves_yellow.png
- type: Icon
icon: Clothing/gloves_yellow.png
texture: Clothing/gloves_yellow.png
- type: Clothing
Slots:
- gloves
@@ -113,9 +117,9 @@
name: Security Helmet
components:
- type: Sprite
sprite: Clothing/helmet_sec.png
texture: Clothing/helmet_sec.png
- type: Icon
icon: Clothing/helmet_sec.png
texture: Clothing/helmet_sec.png
- type: Clothing
Slots:
- head
@@ -126,9 +130,9 @@
name: Gas Mask
components:
- type: Sprite
sprite: Clothing/gasmask.png
texture: Clothing/gasmask.png
- type: Icon
icon: Clothing/gasmask.png
texture: Clothing/gasmask.png
- type: Clothing
Slots:
- mask
@@ -139,9 +143,9 @@
name: Identification Card
components:
- type: Sprite
sprite: Clothing/idcard_standard.png
texture: Clothing/idcard_standard.png
- type: Icon
icon: Clothing/idcard_standard.png
texture: Clothing/idcard_standard.png
- type: Clothing
Slots:
- idcard
@@ -152,9 +156,9 @@
name: Headset Radio
components:
- type: Sprite
sprite: Clothing/ears_headset.png
texture: Clothing/ears_headset.png
- type: Icon
icon: Clothing/ears_headset.png
texture: Clothing/ears_headset.png
- type: Clothing
Slots:
- ears

View File

@@ -6,12 +6,10 @@
- type: Clickable
- type: Sprite
drawdepth: FloorPlaceable
sprites:
- Objects/door_ew.png
- Objects/door_ewo.png
texture: Objects/door_ew.png
- type: Icon
icon: Objects/door_ew.png
texture: Objects/door_ew.png
- type: BoundingBox
aabb: "1,-0.75,2,0.75"

View File

@@ -16,9 +16,9 @@
id: RedToolboxItem
components:
- type: Sprite
sprite: Items/toolbox_r.png
texture: Items/toolbox_r.png
- type: Icon
icon: Items/toolbox_r.png
texture: Items/toolbox_r.png
- type: Storage
Capacity: 60
- type: Item
@@ -30,9 +30,9 @@
id: BlueToolboxItem
components:
- type: Sprite
sprite: Items/toolbox_b.png
texture: Items/toolbox_b.png
- type: Icon
icon: Items/toolbox_b.png
texture: Items/toolbox_b.png
- type: Storage
Capacity: 60
- type: Item
@@ -44,9 +44,9 @@
id: YellowToolboxItem
components:
- type: Sprite
sprite: Items/toolbox_y.png
texture: Items/toolbox_y.png
- type: Icon
icon: Items/toolbox_y.png
texture: Items/toolbox_y.png
- type: Storage
Capacity: 60
- type: Item
@@ -58,9 +58,9 @@
id: MopItem
components:
- type: Sprite
sprite: Items/mop.png
texture: Items/mop.png
- type: Icon
icon: Items/mop.png
texture: Items/mop.png
- type: Item
Size: 10
@@ -71,7 +71,7 @@
id: FlashlightLantern
components:
- type: Sprite
sprite: Items/Flashlight.png
texture: Items/Flashlight.png
- type: Icon
icon: Items/Flashlight.png
texture: Items/Flashlight.png
- type: PointLight

View File

@@ -8,10 +8,9 @@
- type: Sprite
drawdepth: FloorPlaceable
color: Red
sprites:
- Objects/eightdirwire.png
texture: Objects/eightdirwire.png
- type: Icon
icon: Objects/eightdirwire.png
texture: Objects/eightdirwire.png
- type: PowerTransfer
snap:
@@ -34,10 +33,9 @@
- type: BoundingBox
- type: Sprite
drawdepth: FloorPlaceable
sprites:
- Objects/generator.png
texture: Objects/generator.png
- type: Icon
icon: Objects/generator.png
texture: Objects/generator.png
- type: PowerGenerator
- type: entity
@@ -49,10 +47,9 @@
- type: BoundingBox
- type: Sprite
drawdepth: FloorPlaceable
sprites:
- Objects/provider.png
texture: Objects/provider.png
- type: Icon
icon: Objects/provider.png
texture: Objects/provider.png
- type: PowerProvider
Range: 5
Priority: Provider
@@ -78,10 +75,9 @@
- type: BoundingBox
- type: Sprite
drawdepth: FloorPlaceable
sprites:
- Objects/storage.png
texture: Objects/storage.png
- type: Icon
icon: Objects/storage.png
texture: Objects/storage.png
- type: PowerStorage
Capacity: 3000
Charge: 1000
@@ -98,10 +94,9 @@
- type: BoundingBox
- type: Sprite
drawdepth: FloorPlaceable
sprites:
- Objects/wiredmachine.png
texture: Objects/wiredmachine.png
- type: Icon
icon: Objects/wiredmachine.png
texture: Objects/wiredmachine.png
- type: PowerDevice
Drawtype: Node
Load: 100
@@ -116,10 +111,9 @@
- type: BoundingBox
- type: Sprite
drawdepth: FloorPlaceable
sprites:
- Objects/wirelessmachine.png
texture: Objects/wirelessmachine.png
- type: Icon
icon: Objects/wirelessmachine.png
texture: Objects/wirelessmachine.png
- type: PowerDevice
Drawtype: Both
Load: 200

View File

@@ -4,10 +4,13 @@
components:
- type: Transform
- type: Sprite
directional: false
drawdepth: FloorPlaceable
sprite: Objects/projectilebullet.png
texture: Objects/projectilebullet.png
rotation: 180
- type: Icon
icon: Objects/projectilebullet.png
texture: Objects/projectilebullet.png
- type: BoundingBox
- type: Physics
edgeslide: false

View File

@@ -5,9 +5,9 @@
components:
- type: Wirecutter
- type: Sprite
sprite: Objects/wirecutter.png
texture: Objects/wirecutter.png
- type: Icon
icon: Objects/wirecutter.png
texture: Objects/wirecutter.png
- type: MeleeWeapon
- type: entity
@@ -17,9 +17,9 @@
components:
- type: Screwdriver
- type: Sprite
sprite: Objects/screwdriver.png
texture: Objects/screwdriver.png
- type: Icon
icon: Objects/screwdriver.png
texture: Objects/screwdriver.png
- type: MeleeWeapon
- type: entity
@@ -29,9 +29,16 @@
components:
- type: Welder
- type: Sprite
sprite: Objects/welder.png
sprite: Objects/tools.rsi
layers:
- state: welder
- state: welder_flame
shader: unshaded
visible: false
- type: Icon
icon: Objects/welder.png
sprite: Objects/tools.rsi
state: welder
- type: MeleeWeapon
- type: entity
@@ -41,9 +48,9 @@
components:
- type: Wrench
- type: Sprite
sprite: Objects/wrench.png
texture: Objects/wrench.png
- type: Icon
icon: Objects/wrench.png
texture: Objects/wrench.png
- type: MeleeWeapon
- type: entity
@@ -53,9 +60,9 @@
components:
- type: Crowbar
- type: Sprite
sprite: Objects/crowbar.png
texture: Objects/crowbar.png
- type: Icon
icon: Objects/crowbar.png
texture: Objects/crowbar.png
- type: MeleeWeapon
- type: entity
@@ -65,6 +72,6 @@
components:
- type: Multitool
- type: Sprite
sprite: Objects/multitool.png
texture: Objects/multitool.png
- type: Icon
icon: Objects/multitool.png
texture: Objects/multitool.png

View File

@@ -7,8 +7,7 @@
- type: BoundingBox
- type: Sprite
drawdepth: FloorPlaceable
sprites:
- TurrBase
texture: Buildings/TurrBase.png
- type: entity
id: TurretTopGun
@@ -19,8 +18,7 @@
- type: BoundingBox
- type: Sprite
drawdepth: WallMountedItems
sprites:
- TurrTop
texture: Buildings/TurrTop.png
- type: AiController
logic: AimShootLife
vision: 6.0
@@ -34,8 +32,7 @@
- type: BoundingBox
- type: Sprite
drawdepth: WallMountedItems
sprites:
- TurrLamp
texture: Buildings/TurrLamp.png
- type: AiController
logic: AimShootLife
vision: 6.0
@@ -43,4 +40,3 @@
radius: 512
mask: flashlight_mask
autoRot: true

View File

@@ -4,9 +4,9 @@
id: LaserItem
components:
- type: Sprite
sprite: Objects/gun.png
texture: Objects/gun.png
- type: Icon
icon: Objects/gun.png
texture: Objects/gun.png
- type: HitscanWeapon
- type: Item
Size: 24
@@ -17,9 +17,9 @@
id: GUNITEM
components:
- type: Sprite
sprite: Objects/projectileweapon.png
texture: Objects/projectileweapon.png
- type: Icon
icon: Objects/projectileweapon.png
texture: Objects/projectileweapon.png
- type: ProjectileWeapon
- type: Item
Size: 24

View File

@@ -5,8 +5,8 @@
- type: Transform
- type: Clickable
- type: Sprite
sprite: Items/medkit_r.png
texture: Items/medkit_r.png
- type: Icon
icon: Items/medkit_r.png
texture: Items/medkit_r.png

View File

@@ -0,0 +1,32 @@
{
"version": 1,
"size": {
"x": 32,
"y": 32
},
"states": [
{
"name": "welder",
"select": [],
"flags": {},
"directions": 1,
"delays": [
[
1.0
]
]
},
{
"name": "welder_flame",
"select": [],
"flags": {},
"directions": 1,
"delays": [
[
0.2,
0.1
]
]
}
]
}

Binary file not shown.

After

Width:  |  Height:  |  Size: 527 B

Binary file not shown.

After

Width:  |  Height:  |  Size: 181 B

2
engine

Submodule engine updated: 9aed85b4c7...4471e0ccca