Doors! (#12)
* Doors WiP * Kinda seem to work now? * Finished * Oh yeah maybe enable that. * It works except it doesn't * Undo formatting changes * BuildChecker too
This commit is contained in:
committed by
GitHub
parent
ec3e7968a6
commit
7f196fc415
@@ -63,6 +63,7 @@
|
||||
<Compile Include="Prototypes\DiscoBall.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>
|
||||
@@ -98,4 +99,4 @@
|
||||
<ContentAssemblies Include="$(OutputPath)Content.Client.pdb" Condition="'$(Configuration)' == 'Debug'" />
|
||||
<ContentAssemblies Include="$(OutputPath)Content.Shared.pdb" Condition="'$(Configuration)' == 'Debug'" />
|
||||
</ItemGroup>
|
||||
</Project>
|
||||
</Project>
|
||||
|
||||
@@ -21,6 +21,8 @@ namespace Content.Client
|
||||
|
||||
factory.Register<HandsComponent>();
|
||||
factory.RegisterReference<HandsComponent, IHandsComponent>();
|
||||
|
||||
factory.Register<ClientDoorComponent>();
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
@@ -0,0 +1,71 @@
|
||||
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 = "door_ewo";
|
||||
private string CloseSprite = "door_ew";
|
||||
|
||||
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();
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
Reference in New Issue
Block a user