World Storage (#112)
* Added generic crate assets. Added open flag to StorageComponent. * StorageComponent door toggling works. * Door now updates based on if someone is subscribed to the Storage. * Added License to crate.rsi Fixed Icon of crate. * Added basic Locker. * Added Fire Extinguisher. * Added ability to close the storage UI by the server. Notify the server that the UI is closed, so that the player is unsubscribed from the storage. Unsubscribe the player from a storage if the player entity moves out of range. * Add check to make sure entity is on the same map as the storage. * Update Engine module. * Update Engine.
This commit is contained in:
@@ -14,6 +14,7 @@ using SS14.Shared.IoC;
|
||||
using SS14.Shared.Log;
|
||||
using SS14.Shared.Serialization;
|
||||
using System.Collections.Generic;
|
||||
using SS14.Shared.ViewVariables;
|
||||
|
||||
namespace Content.Server.GameObjects
|
||||
{
|
||||
@@ -28,12 +29,32 @@ namespace Content.Server.GameObjects
|
||||
private int StorageCapacityMax = 10000;
|
||||
public HashSet<IPlayerSession> SubscribedSessions = new HashSet<IPlayerSession>();
|
||||
|
||||
[ViewVariables(VVAccess.ReadWrite)]
|
||||
public bool Open
|
||||
{
|
||||
get => _open;
|
||||
set
|
||||
{
|
||||
if (_open == value)
|
||||
return;
|
||||
|
||||
_open = value;
|
||||
Dirty();
|
||||
}
|
||||
}
|
||||
|
||||
public override void OnAdd()
|
||||
{
|
||||
base.OnAdd();
|
||||
|
||||
storage = ContainerManagerComponent.Create<Container>("storagebase", Owner);
|
||||
}
|
||||
|
||||
/// <inheritdoc />
|
||||
public override ComponentState GetComponentState()
|
||||
{
|
||||
return new StorageComponentState(_open);
|
||||
}
|
||||
|
||||
public override void ExposeData(ObjectSerializer serializer)
|
||||
{
|
||||
@@ -155,6 +176,7 @@ namespace Content.Server.GameObjects
|
||||
Logger.DebugS("Storage", "Storage (UID {0}) subscribed player session (UID {1}).", Owner.Uid, session.AttachedEntityUid);
|
||||
session.PlayerStatusChanged += HandlePlayerSessionChangeEvent;
|
||||
SubscribedSessions.Add(session);
|
||||
UpdateDoorState();
|
||||
}
|
||||
}
|
||||
|
||||
@@ -164,9 +186,18 @@ namespace Content.Server.GameObjects
|
||||
/// <param name="channel"></param>
|
||||
public void UnsubscribeSession(IPlayerSession session)
|
||||
{
|
||||
Logger.DebugS("Storage", "Storage (UID {0}) unsubscribed player session (UID {1}).", Owner.Uid, session.AttachedEntityUid);
|
||||
SubscribedSessions.Remove(session);
|
||||
SendNetworkMessage(new CloseStorageUIMessage(), session.ConnectedClient);
|
||||
if(SubscribedSessions.Contains(session))
|
||||
{
|
||||
Logger.DebugS("Storage", "Storage (UID {0}) unsubscribed player session (UID {1}).", Owner.Uid, session.AttachedEntityUid);
|
||||
SubscribedSessions.Remove(session);
|
||||
SendNetworkMessage(new CloseStorageUIMessage(), session.ConnectedClient);
|
||||
UpdateDoorState();
|
||||
}
|
||||
}
|
||||
|
||||
private void UpdateDoorState()
|
||||
{
|
||||
Open = SubscribedSessions.Count != 0;
|
||||
}
|
||||
|
||||
public void HandlePlayerSessionChangeEvent(object obj, SessionStatusEventArgs SSEA)
|
||||
@@ -210,7 +241,8 @@ namespace Content.Server.GameObjects
|
||||
|
||||
switch (message)
|
||||
{
|
||||
case RemoveEntityMessage msg:
|
||||
case RemoveEntityMessage _:
|
||||
{
|
||||
var playerMan = IoCManager.Resolve<IPlayerManager>();
|
||||
var session = playerMan.GetSessionByChannel(netChannel);
|
||||
var playerentity = session.AttachedEntity;
|
||||
@@ -237,6 +269,16 @@ namespace Content.Server.GameObjects
|
||||
entity.GetComponent<ITransformComponent>().WorldPosition = ourtransform.WorldPosition;
|
||||
}
|
||||
}
|
||||
}
|
||||
break;
|
||||
|
||||
case CloseStorageUIMessage _:
|
||||
{
|
||||
var playerMan = IoCManager.Resolve<IPlayerManager>();
|
||||
var session = playerMan.GetSessionByChannel(netChannel);
|
||||
|
||||
UnsubscribeSession(session);
|
||||
}
|
||||
break;
|
||||
}
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user