Airlocks rewritten to use appearances, use less ugly sprite from Eris.

This commit is contained in:
Pieter-Jan Briers
2019-03-16 20:40:07 +01:00
parent 1b3d3debc1
commit 84aa369809
17 changed files with 86 additions and 30 deletions

View File

@@ -74,6 +74,7 @@
<Compile Include="EntryPoint.cs" />
<Compile Include="GameObjects\Components\Actor\CharacterInterface.cs" />
<Compile Include="GameObjects\Components\DamageableComponent.cs" />
<Compile Include="GameObjects\Components\Doors\AirlockVisualizer2D.cs" />
<Compile Include="GameObjects\Components\HUD\Inventory\ClientInventoryComponent.cs" />
<Compile Include="GameObjects\Components\Mobs\ICharacterUI.cs" />
<Compile Include="GameObjects\Components\Mobs\SpeciesUI.cs" />

View File

@@ -0,0 +1,40 @@
using System;
using Content.Shared.GameObjects.Components.Doors;
using SS14.Client.GameObjects;
using SS14.Client.Interfaces.GameObjects.Components;
namespace Content.Client.GameObjects.Components.Doors
{
public class AirlockVisualizer2D : AppearanceVisualizer
{
public override void OnChangeData(AppearanceComponent component)
{
base.OnChangeData(component);
var sprite = component.Owner.GetComponent<ISpriteComponent>();
if (!component.TryGetData(DoorVisuals.VisualState, out DoorVisualState state))
{
state = DoorVisualState.Closed;
}
switch (state)
{
case DoorVisualState.Closed:
case DoorVisualState.Closing:
sprite.LayerSetState(DoorVisualLayers.Base, "closed");
break;
case DoorVisualState.Opening:
case DoorVisualState.Open:
sprite.LayerSetState(DoorVisualLayers.Base, "open");
break;
default:
throw new ArgumentOutOfRangeException();
}
}
}
public enum DoorVisualLayers
{
Base
}
}

View File

@@ -9,6 +9,7 @@ using SS14.Shared.Log;
using SS14.Shared.Maths;
using SS14.Shared.IoC;
using Content.Server.GameObjects.EntitySystems;
using Content.Shared.GameObjects.Components.Doors;
using SS14.Shared.Serialization;
using SS14.Shared.Interfaces.Network;
using SS14.Shared.ViewVariables;
@@ -24,31 +25,20 @@ namespace Content.Server.GameObjects
private float OpenTimeCounter;
private CollidableComponent collidableComponent;
private SpriteComponent spriteComponent;
private string OpenSprite;
private string CloseSprite;
public override void ExposeData(ObjectSerializer serializer)
{
base.ExposeData(serializer);
serializer.DataField(ref OpenSprite, "openstate", "Objects/door_ewo.png");
serializer.DataField(ref CloseSprite, "closestate", "Objects/door_ew.png");
}
private AppearanceComponent _appearance;
public override void Initialize()
{
base.Initialize();
collidableComponent = Owner.GetComponent<CollidableComponent>();
spriteComponent = Owner.GetComponent<SpriteComponent>();
_appearance = Owner.GetComponent<AppearanceComponent>();
}
public override void OnRemove()
{
collidableComponent = null;
spriteComponent = null;
_appearance = null;
base.OnRemove();
}
@@ -87,7 +77,7 @@ namespace Content.Server.GameObjects
{
Opened = true;
collidableComponent.IsHardCollidable = false;
spriteComponent.LayerSetTexture(0, OpenSprite);
_appearance.SetData(DoorVisuals.VisualState, DoorVisualState.Open);
}
public bool Close()
@@ -100,7 +90,7 @@ namespace Content.Server.GameObjects
Opened = false;
OpenTimeCounter = 0;
collidableComponent.IsHardCollidable = true;
spriteComponent.LayerSetTexture(0, CloseSprite);
_appearance.SetData(DoorVisuals.VisualState, DoorVisualState.Closed);
return true;
}

View File

@@ -64,6 +64,7 @@
<ItemGroup>
<Compile Include="EntryPoint.cs" />
<Compile Include="GameObjects\Components\Damage\DamageableComponent.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

@@ -0,0 +1,22 @@
using System;
using SS14.Shared.Serialization;
namespace Content.Shared.GameObjects.Components.Doors
{
[NetSerializable]
[Serializable]
public enum DoorVisuals
{
VisualState,
}
[NetSerializable]
[Serializable]
public enum DoorVisualState
{
Closed,
Opening,
Open,
Closing,
}
}

View File

@@ -166,7 +166,7 @@ entities:
pos: 6,-4
rot: -1.570796 rad
type: Transform
- type: DoorContent
- type: airlock
components:
- grid: 0
pos: -5.5,-4.5
@@ -238,7 +238,7 @@ entities:
pos: -2.5,-4.5
rot: -1.570796 rad
type: Transform
- type: DoorContent
- type: airlock
components:
- grid: 0
pos: 4.5,-4.5

View File

@@ -1,23 +1,24 @@
- type: entity
id: DoorContent
name: Actual door
description: It opens, it closes!
id: airlock
name: Airlock
description: It opens, it closes, and maybe crushes you.
components:
- type: Clickable
- type: Sprite
drawdepth: Mobs # They're on the same layer as mobs, perspective.
texture: Objects/door_ew.png
sprite: Buildings/airlock_basic.rsi
layers:
- state: closed
map: ["enum.DoorVisualLayers.Base"]
- type: Icon
texture: Objects/door_ew.png
sprite: Buildings/airlock_basic.rsi
state: closed
- type: BoundingBox
aabb: "-2,-0.75,-1,0.75"
sizeX: 1.9
offsetY: 1.5
- type: Collidable
- type: Door
placement:
snap:
- Wall
- type: Appearance
visuals:
- type: AirlockVisualizer2D

Binary file not shown.

After

Width:  |  Height:  |  Size: 933 B

Binary file not shown.

After

Width:  |  Height:  |  Size: 2.4 KiB

Binary file not shown.

After

Width:  |  Height:  |  Size: 1.3 KiB

Binary file not shown.

After

Width:  |  Height:  |  Size: 933 B

View File

@@ -0,0 +1 @@
{"version": 1, "size": {"x": 32, "y": 32}, "license": "CC-BY-SA-3.0", "copyright": "Taken from https://github.com/discordia-space/CEV-Eris/blob/2b969adc2dfd3e9621bf3597c5cbffeb3ac8c9f0/icons/obj/doors/doorint.dmi", "states": [{"name": "closed", "directions": 1, "delays": [[1.0]]}, {"name": "closing", "directions": 1, "delays": [[0.2, 0.2, 0.1, 0.1, 0.1, 0.1, 0.1, 0.3]]}, {"name": "deny", "directions": 1, "delays": [[0.1, 0.1, 0.1]]}, {"name": "locked", "directions": 1, "delays": [[1.0]]}, {"name": "o_closing", "directions": 1, "delays": [[0.2, 0.1, 0.1, 0.1, 0.1, 0.1, 0.1, 0.4]]}, {"name": "o_opening", "directions": 1, "delays": [[0.2, 0.2, 0.1, 0.1, 0.1, 0.1, 0.1, 0.3]]}, {"name": "open", "directions": 1, "delays": [[1.0]]}, {"name": "opening", "directions": 1, "delays": [[0.2, 0.2, 0.1, 0.1, 0.1, 0.1, 0.1, 0.3]]}, {"name": "spark", "directions": 1, "delays": [[0.1, 0.1, 0.1, 0.1, 0.1, 0.1]]}]}

Binary file not shown.

After

Width:  |  Height:  |  Size: 2.5 KiB

Binary file not shown.

After

Width:  |  Height:  |  Size: 2.4 KiB

Binary file not shown.

After

Width:  |  Height:  |  Size: 278 B

Binary file not shown.

After

Width:  |  Height:  |  Size: 2.3 KiB

Binary file not shown.

After

Width:  |  Height:  |  Size: 2.2 KiB