-
-
Notifications
You must be signed in to change notification settings - Fork 77
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Adopt ECS Design Pattern (Part II) (#73)
* 开始对 BlockEntity 使用 ECS * 完成 BlockEntity 的改造 * fix typos * fix typos
- Loading branch information
Showing
42 changed files
with
724 additions
and
395 deletions.
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
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
25 changes: 25 additions & 0 deletions
25
src/MineCase.Server.Grains/Components/BlockWorldPositionComponent.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,25 @@ | ||
using System; | ||
using System.Collections.Generic; | ||
using System.Text; | ||
using System.Threading.Tasks; | ||
using MineCase.Engine; | ||
using MineCase.World; | ||
|
||
namespace MineCase.Server.Components | ||
{ | ||
internal class BlockWorldPositionComponent : Component | ||
{ | ||
public static readonly DependencyProperty<BlockWorldPos> BlockWorldPositionProperty = | ||
DependencyProperty.Register<BlockWorldPos>("BlockWorldPosition", typeof(BlockWorldPositionComponent)); | ||
|
||
public BlockWorldPos BlockWorldPosition => AttachedObject.GetValue(BlockWorldPositionProperty); | ||
|
||
public BlockWorldPositionComponent(string name = "blockWorldPosition") | ||
: base(name) | ||
{ | ||
} | ||
|
||
public Task SetBlockWorldPosition(BlockWorldPos value) => | ||
AttachedObject.SetLocalValue(BlockWorldPositionProperty, value); | ||
} | ||
} |
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
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
28 changes: 28 additions & 0 deletions
28
src/MineCase.Server.Grains/Game/BlockEntities/Components/BlockEntityLiftTimeComponent.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,28 @@ | ||
using System; | ||
using System.Collections.Generic; | ||
using System.Text; | ||
using System.Threading.Tasks; | ||
using MineCase.Engine; | ||
using MineCase.Server.Components; | ||
|
||
namespace MineCase.Server.Game.BlockEntities.Components | ||
{ | ||
internal class BlockEntityLiftTimeComponent : Component<BlockEntityGrain>, IHandle<SpawnBlockEntity>, IHandle<DestroyBlockEntity> | ||
{ | ||
public BlockEntityLiftTimeComponent(string name = "blockEntityLifeTime") | ||
: base(name) | ||
{ | ||
} | ||
|
||
async Task IHandle<SpawnBlockEntity>.Handle(SpawnBlockEntity message) | ||
{ | ||
await AttachedObject.GetComponent<WorldComponent>().SetWorld(message.World); | ||
await AttachedObject.GetComponent<BlockWorldPositionComponent>().SetBlockWorldPosition(message.Position); | ||
} | ||
|
||
Task IHandle<DestroyBlockEntity>.Handle(DestroyBlockEntity message) | ||
{ | ||
return AttachedObject.Tell(Disable.Default); | ||
} | ||
} | ||
} |
Oops, something went wrong.