mirror of
https://github.com/project-redbud/FunGame-Core.git
synced 2026-04-20 05:24:59 +00:00
地图格子添加事件;插件的控制台输入方法签名修改为指令+参数;添加互动点实体类
This commit is contained in:
parent
a6087f98a6
commit
08e5414d00
15
Entity/Explore/InteractionPoint.cs
Normal file
15
Entity/Explore/InteractionPoint.cs
Normal file
@ -0,0 +1,15 @@
|
||||
using Milimoe.FunGame.Core.Interface.Entity;
|
||||
|
||||
namespace Milimoe.FunGame.Core.Entity
|
||||
{
|
||||
public class InteractionPoint : BaseEntity
|
||||
{
|
||||
public int CustomValue { get; set; } = 0;
|
||||
public string Description { get; set; } = "";
|
||||
|
||||
public override bool Equals(IBaseEntity? other)
|
||||
{
|
||||
return other is InteractionPoint && other.GetIdName() == GetIdName();
|
||||
}
|
||||
}
|
||||
}
|
||||
@ -59,10 +59,10 @@ namespace Milimoe.FunGame.Core.Library.Common.Addon.Example
|
||||
|
||||
public override string Author => "FunGamer";
|
||||
|
||||
public override void ProcessInput(string input)
|
||||
public override void ProcessInput(string order, string[] args)
|
||||
{
|
||||
// 该方法用于接收服务器控制台的输入并处理
|
||||
if (input.Equals("info", StringComparison.CurrentCultureIgnoreCase))
|
||||
if (order.Equals("info", StringComparison.CurrentCultureIgnoreCase))
|
||||
{
|
||||
// 使用PluginController的输出方式
|
||||
Controller.WriteLine($"This is {nameof(ExampleServerPlugin)}!!");
|
||||
|
||||
@ -203,11 +203,16 @@ namespace Milimoe.FunGame.Core.Library.Common.Addon
|
||||
public bool SetCharacterCurrentGrid(Character character, Grid target)
|
||||
{
|
||||
Grid? current = GetCharacterCurrentGrid(character);
|
||||
current?.Characters.Remove(character);
|
||||
if (current != null)
|
||||
{
|
||||
current.Characters.Remove(character);
|
||||
current.OnCharacterExited(character);
|
||||
}
|
||||
if (Grids.ContainsValue(target))
|
||||
{
|
||||
target.Characters.Add(character);
|
||||
Characters[character] = target;
|
||||
target.OnCharacterEntered(character);
|
||||
return true;
|
||||
}
|
||||
return false;
|
||||
@ -221,7 +226,11 @@ namespace Milimoe.FunGame.Core.Library.Common.Addon
|
||||
public void RemoveCharacter(Character character)
|
||||
{
|
||||
Grid? current = GetCharacterCurrentGrid(character);
|
||||
current?.Characters.Remove(character);
|
||||
if (current != null)
|
||||
{
|
||||
current.Characters.Remove(character);
|
||||
current.OnCharacterExited(character);
|
||||
}
|
||||
Characters[character] = Grid.Empty;
|
||||
}
|
||||
|
||||
|
||||
@ -40,11 +40,43 @@ namespace Milimoe.FunGame.Core.Library.Common.Addon
|
||||
/// </summary>
|
||||
public HashSet<Effect> Effects { get; set; } = [];
|
||||
|
||||
/// <summary>
|
||||
/// 格子上的交互点
|
||||
/// </summary>
|
||||
public HashSet<InteractionPoint> InteractionPoints { get; set; } = [];
|
||||
|
||||
/// <summary>
|
||||
/// 此格子呈现的颜色(默认为 <see cref="Color.Gray"/> )
|
||||
/// </summary>
|
||||
public Color Color { get; set; } = Color.Gray;
|
||||
|
||||
public delegate void CharacterEnteredHandler(Character character);
|
||||
/// <summary>
|
||||
/// 角色进入格子事件
|
||||
/// </summary>
|
||||
public event CharacterEnteredHandler? CharacterEntered;
|
||||
/// <summary>
|
||||
/// 触发角色进入格子事件
|
||||
/// </summary>
|
||||
/// <param name="character"></param>
|
||||
public void OnCharacterEntered(Character character)
|
||||
{
|
||||
CharacterEntered?.Invoke(character);
|
||||
}
|
||||
public delegate void CharacterExitedHandler(Character character);
|
||||
/// <summary>
|
||||
/// 角色离开格子事件
|
||||
/// </summary>
|
||||
public event CharacterExitedHandler? CharacterExited;
|
||||
/// <summary>
|
||||
/// 触发角色离开格子事件
|
||||
/// </summary>
|
||||
/// <param name="character"></param>
|
||||
public void OnCharacterExited(Character character)
|
||||
{
|
||||
CharacterExited?.Invoke(character);
|
||||
}
|
||||
|
||||
/// <summary>
|
||||
/// 默认的字符串表示形式
|
||||
/// </summary>
|
||||
|
||||
@ -93,8 +93,9 @@ namespace Milimoe.FunGame.Core.Library.Common.Addon
|
||||
/// <summary>
|
||||
/// 接收服务器控制台的输入
|
||||
/// </summary>
|
||||
/// <param name="input"></param>
|
||||
public abstract void ProcessInput(string input);
|
||||
/// <param name="order"></param>
|
||||
/// <param name="args"></param>
|
||||
public abstract void ProcessInput(string order, string[] args);
|
||||
|
||||
/// <summary>
|
||||
/// 处理服务器广播的非标准 DataRequest 请求
|
||||
|
||||
@ -93,8 +93,9 @@ namespace Milimoe.FunGame.Core.Library.Common.Addon
|
||||
/// <summary>
|
||||
/// 接收服务器控制台的输入
|
||||
/// </summary>
|
||||
/// <param name="input"></param>
|
||||
public abstract void ProcessInput(string input);
|
||||
/// <param name="order"></param>
|
||||
/// <param name="args"></param>
|
||||
public abstract void ProcessInput(string order, string[] args);
|
||||
|
||||
/// <summary>
|
||||
/// 处理服务器广播的非标准 DataRequest 请求
|
||||
|
||||
Loading…
x
Reference in New Issue
Block a user