-
Notifications
You must be signed in to change notification settings - Fork 29
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
- Loading branch information
Showing
10 changed files
with
147 additions
and
1 deletion.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
40 changes: 40 additions & 0 deletions
40
src/common/Edelstein.Common.Gameplay.Game/Objects/Reactors/FieldReactor.cs
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,40 @@ | ||
using System; | ||
using Edelstein.Protocol.Gameplay.Game.Contracts.Packets.Send; | ||
using Edelstein.Protocol.Gameplay.Game.Objects; | ||
using Edelstein.Protocol.Gameplay.Game.Objects.Reactors; | ||
using Edelstein.Protocol.Gameplay.Game.Objects.Reactors.Templates; | ||
using Edelstein.Protocol.Gameplay.Game.Templates.Spatial; | ||
using Edelstein.Protocol.Network.Packets; | ||
using Edelstein.Protocol.Utilities.Spatial; | ||
|
||
namespace Edelstein.Common.Gameplay.Game.Objects.Reactors; | ||
|
||
public class FieldReactor( | ||
IReactorTemplate template, | ||
IPoint2D position, | ||
bool facingLeft = true | ||
) : AbstractFieldObject(position), IFieldReactor | ||
{ | ||
public override FieldObjectType Type => FieldObjectType.Reactor; | ||
public IReactorTemplate Template => template; | ||
|
||
public override IDispatchable GetDispatchEnterField(bool isEnterField = false) | ||
=> new ReactorEnterField | ||
{ | ||
ObjectID = ObjectID ?? 0, | ||
TemplateID = template.ID, | ||
State = 0, | ||
X = (short)position.X, | ||
Y = (short)position.Y, | ||
Flip = facingLeft | ||
}; | ||
|
||
public override IDispatchable GetDispatchLeaveField(bool isLeaveField = false) | ||
=> new ReactorLeaveField | ||
{ | ||
ObjectID = ObjectID ?? 0, | ||
State = 0, | ||
X = (short)position.X, | ||
Y = (short)position.Y | ||
}; | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
34 changes: 34 additions & 0 deletions
34
src/common/Edelstein.Common.Gameplay.Game/Templates/FieldTemplateReactor.cs
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,34 @@ | ||
using System; | ||
using Duey.Abstractions; | ||
using Edelstein.Common.Utilities.Spatial; | ||
using Edelstein.Protocol.Gameplay.Game.Templates; | ||
using Edelstein.Protocol.Utilities.Spatial; | ||
|
||
namespace Edelstein.Common.Gameplay.Game.Templates; | ||
|
||
public record FieldTemplateReactor : IFieldTemplateReactor | ||
{ | ||
public string? Name { get; } | ||
public int TemplateID { get; } | ||
|
||
public int ReactorTime { get; } | ||
|
||
public bool IsFacingLeft { get; } | ||
public IPoint2D Position { get; } | ||
|
||
public FieldTemplateReactor(IDataNode node) | ||
{ | ||
TemplateID = Convert.ToInt32(node.ResolveString("id") ?? "-1"); | ||
|
||
ReactorTime = node.ResolveInt("reactorTime") ?? 0; | ||
|
||
IsFacingLeft = !(node.ResolveBool("f") ?? false); | ||
|
||
Position = new Point2D( | ||
node.ResolveInt("x") ?? int.MinValue, | ||
node.ResolveInt("y") ?? int.MinValue | ||
); | ||
|
||
Name = node.ResolveString("name") ?? "NO-NAME"; | ||
} | ||
} |
16 changes: 16 additions & 0 deletions
16
src/protocol/Edelstein.Protocol.Gameplay.Game/Contracts/Packets/Send/ReactorEnterField.cs
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,16 @@ | ||
using BinarySerialization; | ||
using Edelstein.Protocol.Network.Packets; | ||
using Edelstein.Protocol.Network.Packets.Types; | ||
|
||
namespace Edelstein.Protocol.Gameplay.Game.Contracts.Packets.Send; | ||
|
||
public record ReactorEnterField() : StructuredSendPacket((short)PacketSendOperation.ReactorEnterField) | ||
{ | ||
[FieldOrder(0)] public required int ObjectID { get; init; } | ||
[FieldOrder(1)] public required int TemplateID { get; init; } | ||
[FieldOrder(2)] public required byte State { get; init; } | ||
[FieldOrder(3)] public short X { get; init; } | ||
[FieldOrder(4)] public short Y { get; init; } | ||
[FieldOrder(5)] public bool Flip { get; init; } | ||
[FieldOrder(6)] public LPString Name { get; init; } = new(); | ||
} |
12 changes: 12 additions & 0 deletions
12
src/protocol/Edelstein.Protocol.Gameplay.Game/Contracts/Packets/Send/ReactorLeaveField.cs
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,12 @@ | ||
using BinarySerialization; | ||
using Edelstein.Protocol.Network.Packets; | ||
|
||
namespace Edelstein.Protocol.Gameplay.Game.Contracts.Packets.Send; | ||
|
||
public record ReactorLeaveField() : StructuredSendPacket((short)PacketSendOperation.ReactorLeaveField) | ||
{ | ||
[FieldOrder(0)] public required int ObjectID { get; init; } | ||
[FieldOrder(1)] public required byte State { get; init; } | ||
[FieldOrder(2)] public short X { get; init; } | ||
[FieldOrder(3)] public short Y { get; init; } | ||
} |
8 changes: 8 additions & 0 deletions
8
src/protocol/Edelstein.Protocol.Gameplay.Game/Objects/Reactors/IFieldReactor.cs
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,8 @@ | ||
using Edelstein.Protocol.Gameplay.Game.Objects.Reactors.Templates; | ||
|
||
namespace Edelstein.Protocol.Gameplay.Game.Objects.Reactors; | ||
|
||
public interface IFieldReactor : IFieldObject | ||
{ | ||
IReactorTemplate Template { get; } | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
14 changes: 14 additions & 0 deletions
14
src/protocol/Edelstein.Protocol.Gameplay.Game/Templates/IFieldTemplateReactor.cs
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,14 @@ | ||
using Edelstein.Protocol.Utilities.Spatial; | ||
|
||
namespace Edelstein.Protocol.Gameplay.Game.Templates; | ||
|
||
public interface IFieldTemplateReactor | ||
{ | ||
string? Name { get; } | ||
int TemplateID { get; } | ||
|
||
int ReactorTime { get; } | ||
|
||
bool IsFacingLeft { get; } | ||
IPoint2D Position { get; } | ||
} |