Component Messaging Rework (#36)
* Remove DiscoBall. * Changes `IEntity.AddComponent(IComponent)` to `IEntity.AddComponent<T>`. * Pulled ComponentManager registration out of Component into Entity. * Killed component message params. * Updated engine submodule.
This commit is contained in:
2
.gitmodules
vendored
2
.gitmodules
vendored
@@ -1,4 +1,4 @@
|
||||
[submodule "engine"]
|
||||
path = engine
|
||||
url = https://github.com/space-wizards/space-station-14.git
|
||||
branch = 1771ca4b4c043f95e2a1830e78362df9bb03a656
|
||||
branch = 98b7e4ee9ede281f5159539fbb9dba3d08a015cf
|
||||
@@ -60,7 +60,6 @@
|
||||
</ItemGroup>
|
||||
<ItemGroup>
|
||||
<Compile Include="EntryPoint.cs" />
|
||||
<Compile Include="Prototypes\DiscoBall.cs" />
|
||||
<Compile Include="Properties\AssemblyInfo.cs" />
|
||||
<Compile Include="GameObjects\Components\Items\ClientHandsComponent.cs" />
|
||||
<Compile Include="GameObjects\Components\Doors\ClientDoorComponent.cs" />
|
||||
|
||||
@@ -1,10 +1,7 @@
|
||||
using Content.Client.Interfaces.GameObjects;
|
||||
using Content.Client.UserInterface;
|
||||
using Content.Shared.GameObjects;
|
||||
using Lidgren.Network;
|
||||
using SS14.Client.Interfaces.UserInterface;
|
||||
using SS14.Client.UserInterface;
|
||||
using SS14.Shared;
|
||||
using SS14.Shared.GameObjects;
|
||||
using SS14.Shared.Interfaces.GameObjects;
|
||||
using SS14.Shared.IoC;
|
||||
@@ -50,7 +47,7 @@ namespace Content.Client.GameObjects
|
||||
|
||||
public void SendChangeHand(string index)
|
||||
{
|
||||
Owner.SendComponentNetworkMessage(this, NetDeliveryMethod.ReliableUnordered, index);
|
||||
SendNetworkMessage(new ClientChangedHandMsg(index));
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
@@ -1,39 +0,0 @@
|
||||
using SS14.Client.GameObjects;
|
||||
using SS14.Shared.GameObjects;
|
||||
using SS14.Shared.Maths;
|
||||
|
||||
namespace Content.Client.Prototypes
|
||||
{
|
||||
// Instantiated through reflection by the prototype system.
|
||||
public class DiscoBall : Entity
|
||||
{
|
||||
private PointLightComponent _lightComponent;
|
||||
private float _hue;
|
||||
|
||||
/// <inheritdoc />
|
||||
public override void Initialize()
|
||||
{
|
||||
base.Initialize();
|
||||
_lightComponent = GetComponent<PointLightComponent>();
|
||||
}
|
||||
|
||||
/// <inheritdoc />
|
||||
public override void Shutdown()
|
||||
{
|
||||
base.Shutdown();
|
||||
_lightComponent = null;
|
||||
}
|
||||
|
||||
/// <inheritdoc />
|
||||
public override void Update(float frameTime)
|
||||
{
|
||||
_hue += frameTime / 10;
|
||||
if (_hue > 1)
|
||||
{
|
||||
_hue -= 1;
|
||||
}
|
||||
|
||||
_lightComponent.Color = Color4.FromHsl(new Vector4(_hue, 1, 0.5f, 0.5f));
|
||||
}
|
||||
}
|
||||
}
|
||||
@@ -256,18 +256,17 @@ namespace Content.Server.GameObjects
|
||||
ActiveIndex = orderedHands[index];
|
||||
}
|
||||
|
||||
public override void HandleNetworkMessage(IncomingEntityComponentMessage message)
|
||||
public override void HandleMessage(object owner, ComponentMessage message)
|
||||
{
|
||||
if (message.MessageParameters.Count != 1)
|
||||
base.HandleMessage(owner, message);
|
||||
|
||||
switch (message)
|
||||
{
|
||||
return;
|
||||
case ClientChangedHandMsg msg:
|
||||
if (HasHand(msg.Index))
|
||||
ActiveIndex = msg.Index;
|
||||
break;
|
||||
}
|
||||
var index = message.MessageParameters[0];
|
||||
if (index is string newIndex && HasHand(newIndex))
|
||||
{
|
||||
ActiveIndex = newIndex;
|
||||
}
|
||||
base.HandleNetworkMessage(message);
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
@@ -84,17 +84,15 @@ namespace Content.Server.GameObjects.Components.Power
|
||||
}
|
||||
}
|
||||
|
||||
public override void OnAdd(IEntity owner)
|
||||
public override void OnAdd()
|
||||
{
|
||||
base.OnAdd(owner);
|
||||
base.OnAdd();
|
||||
|
||||
if (Drawtype == DrawTypes.Both || Drawtype == DrawTypes.Node)
|
||||
{
|
||||
if (!owner.TryGetComponent(out PowerNodeComponent node))
|
||||
if (!Owner.TryGetComponent(out PowerNodeComponent node))
|
||||
{
|
||||
var factory = IoCManager.Resolve<IComponentFactory>();
|
||||
node = factory.GetComponent<PowerNodeComponent>();
|
||||
owner.AddComponent(node);
|
||||
Owner.AddComponent<PowerNodeComponent>();
|
||||
}
|
||||
node.OnPowernetConnect += PowernetConnect;
|
||||
node.OnPowernetDisconnect += PowernetDisconnect;
|
||||
|
||||
@@ -33,15 +33,13 @@ namespace Content.Server.GameObjects.Components.Power
|
||||
}
|
||||
}
|
||||
|
||||
public override void OnAdd(IEntity owner)
|
||||
public override void OnAdd()
|
||||
{
|
||||
base.OnAdd(owner);
|
||||
base.OnAdd();
|
||||
|
||||
if (!owner.TryGetComponent(out PowerNodeComponent node))
|
||||
if (!Owner.TryGetComponent(out PowerNodeComponent node))
|
||||
{
|
||||
var factory = IoCManager.Resolve<IComponentFactory>();
|
||||
node = factory.GetComponent<PowerNodeComponent>();
|
||||
owner.AddComponent(node);
|
||||
Owner.AddComponent<PowerNodeComponent>();
|
||||
}
|
||||
node.OnPowernetConnect += PowernetConnect;
|
||||
node.OnPowernetDisconnect += PowernetDisconnect;
|
||||
|
||||
@@ -78,15 +78,13 @@ namespace Content.Server.GameObjects.Components.Power
|
||||
}
|
||||
}
|
||||
|
||||
public override void OnAdd(IEntity owner)
|
||||
public override void OnAdd()
|
||||
{
|
||||
base.OnAdd(owner);
|
||||
base.OnAdd();
|
||||
|
||||
if (!owner.TryGetComponent(out PowerNodeComponent node))
|
||||
if (!Owner.TryGetComponent(out PowerNodeComponent node))
|
||||
{
|
||||
var factory = IoCManager.Resolve<IComponentFactory>();
|
||||
node = factory.GetComponent<PowerNodeComponent>();
|
||||
owner.AddComponent(node);
|
||||
Owner.AddComponent<PowerNodeComponent>();
|
||||
}
|
||||
node.OnPowernetConnect += PowernetConnect;
|
||||
node.OnPowernetDisconnect += PowernetDisconnect;
|
||||
|
||||
@@ -7,6 +7,7 @@ using SS14.Shared.Interfaces.GameObjects.Components;
|
||||
using SS14.Shared.IoC;
|
||||
using System.Collections.Generic;
|
||||
using System.Linq;
|
||||
using SS14.Shared.Enums;
|
||||
|
||||
namespace Content.Server.GameObjects.EntitySystems
|
||||
{
|
||||
|
||||
@@ -1,22 +0,0 @@
|
||||
- type: entity
|
||||
name: Disco Ball
|
||||
id: discoball
|
||||
class: Content.Client.Prototypes.DiscoBall
|
||||
components:
|
||||
- type: Transform
|
||||
- type: Sprite
|
||||
sprites:
|
||||
- wall_light
|
||||
|
||||
- type: Icon
|
||||
icon: wall_light
|
||||
|
||||
- type: PointLight
|
||||
|
||||
- type: entity
|
||||
name: Disco Ball Small Edition
|
||||
id: discoballsmall
|
||||
parent: discoball
|
||||
components:
|
||||
- type: PointLight
|
||||
radius: 128
|
||||
2
engine
2
engine
Submodule engine updated: 1771ca4b4c...98b7e4ee9e
Reference in New Issue
Block a user