提交修改

This commit is contained in:
Bob.Song
2026-03-06 09:44:00 +08:00
parent e125bb869e
commit db7bc90fe2
3631 changed files with 9050 additions and 395938 deletions

View File

@@ -0,0 +1,52 @@
using System;
namespace Fantasy
{
/// <summary>
/// 聊天频道类型
/// </summary>
[Flags]
public enum ChatChannelType
{
None = 0,
World = 1 << 1, // 世界频道
Private = 1 << 2, // 私聊频道
System = 1 << 3, // 系统频道
Broadcast = 1 << 4, // 广播频道
Notice = 1 << 5, // 公告频道
Team = 1 << 6, // 队伍频道
Near = 1 << 7, // 附近频道
CurrentMap = 1 << 8, // 当前地图频道
// 所有频道
All = World | Private | System | Broadcast | Notice | Team | Near,
// 其他聊天栏显示的频道
Display = World | Private | System | Broadcast | Notice | Team | Near | CurrentMap
}
/// <summary>
/// 聊天节点类型
/// </summary>
public enum ChatNodeType
{
None = 0,
Position = 1, // 位置节点
OpenUI = 2, // 打开UI节点
Link = 3, // 链接节点
Item = 4, // 物品节点
Text = 5, // 文本节点
Image = 6, // 图片节点
}
/// <summary>
/// 聊天节点事件类型
/// </summary>
public enum ChatNodeEvent
{
None = 0,
OpenUI = 1, // 打开UI节点
ClickLink = 2, // 点击链接节点
UseItem = 3, // 使用物品节点
Position = 4, // 位置节点
}
}

View File

@@ -0,0 +1,11 @@
fileFormatVersion: 2
guid: 1cf2785958c454fb98765b594d346806
MonoImporter:
externalObjects: {}
serializedVersion: 2
defaultReferences: []
executionOrder: 0
icon: {instanceID: 0}
userData:
assetBundleName:
assetBundleVariant:

View File

@@ -0,0 +1,16 @@
using System.Runtime.Serialization;
using LightProto;
using MongoDB.Bson.Serialization.Attributes;
using Newtonsoft.Json;
namespace Fantasy
{
public partial class ChatInfoTree
{
[BsonIgnore]
[JsonIgnore]
[ProtoIgnore]
[IgnoreDataMember]
public Scene Scene { get; set; }
}
}

View File

@@ -0,0 +1,11 @@
fileFormatVersion: 2
guid: 0079ff8530a474be1a7962b88311db20
MonoImporter:
externalObjects: {}
serializedVersion: 2
defaultReferences: []
executionOrder: 0
icon: {instanceID: 0}
userData:
assetBundleName:
assetBundleVariant:

View File

@@ -0,0 +1,79 @@
using System.Collections.Generic;
using Fantasy.Serialize;
namespace Fantasy
{
public static class ChatNodeEventHelper
{
public static void Handler(Scene scene, ChatInfoNode node)
{
switch ((ChatNodeEvent)node.ChatNodeEvent)
{
case ChatNodeEvent.ClickLink:
{
ClickLinkHandler(scene, node);
return;
}
case ChatNodeEvent.OpenUI:
{
OpenUIHandler(scene, node);
return;
}
case ChatNodeEvent.Position:
{
PositionHandler(scene, node);
return;
}
case ChatNodeEvent.UseItem:
{
UseItemHandler(scene, node);
return;
}
}
}
private static void ClickLinkHandler(Scene scene, ChatInfoNode node)
{
if (node.Data == null || node.Data.Length == 0)
{
return;
}
var chatLinkNode = SerializerManager.ProtoBufHelper.Deserialize<ChatLinkNode>(node.Data);
// 拿到这个之后,就可以为所欲为了。
// 根据自己的逻辑和UI设计做出相应的处理。
Log.Debug($"ClickLinkHandler Link:{chatLinkNode.Link}");
}
private static void OpenUIHandler(Scene scene, ChatInfoNode node)
{
if (node.Data == null || node.Data.Length == 0)
{
return;
}
var chatOpenUINode =SerializerManager.ProtoBufHelper.Deserialize<ChatOpenUINode>(node.Data);
// 拿到这个之后,就可以为所欲为了。
// 根据自己的逻辑和UI设计做出相应的处理。
Log.Debug($"OpenUIHandler UIName:{chatOpenUINode.UIName}");
}
private static void PositionHandler(Scene scene, ChatInfoNode node)
{
if (node.Data == null || node.Data.Length == 0)
{
return;
}
var chatPositionNode =SerializerManager.ProtoBufHelper.Deserialize<ChatPositionNode>(node.Data);
// 拿到这个之后,就可以为所欲为了。
// 根据自己的逻辑和UI设计做出相应的处理。
Log.Debug($"PositionHandler MapName:{chatPositionNode.MapName} X:{chatPositionNode.PosX} Y:{chatPositionNode.PosY} Z:{chatPositionNode.PosZ}");
}
private static void UseItemHandler(Scene scene, ChatInfoNode node)
{
// TODO: Implement UseItemHandler
}
}
}

View File

@@ -0,0 +1,11 @@
fileFormatVersion: 2
guid: 17bb297b8f01b4b90a7f306acd81b672
MonoImporter:
externalObjects: {}
serializedVersion: 2
defaultReferences: []
executionOrder: 0
icon: {instanceID: 0}
userData:
assetBundleName:
assetBundleVariant:

View File

@@ -0,0 +1,128 @@
using Fantasy.Serialize;
namespace Fantasy
{
/// <summary>
/// 聊天信息节点
/// </summary>
public static class ChatNodeFactory
{
/// <summary>
/// 添加文本节点
/// </summary>
/// <param name="chatInfoTree"></param>
/// <param name="content"></param>
/// <returns></returns>
public static ChatInfoTree AddendTextNode(this ChatInfoTree chatInfoTree, string content)
{
var chatInfoNode = new ChatInfoNode()
{
ChatNodeType = (int)ChatNodeType.Text,
Content = content
};
chatInfoTree.Node.Add(chatInfoNode);
return chatInfoTree;
}
/// <summary>
/// 添加链接节点
/// </summary>
/// <param name="chatInfoTree"></param>
/// <param name="content"></param>
/// <param name="link"></param>
/// <returns></returns>
public static ChatInfoTree AddendLinkNode(this ChatInfoTree chatInfoTree, string content,string link)
{
var chatLinkNode = new ChatLinkNode()
{
Link = link
};
// var serializerComponent = chatInfoTree.Scene.GetComponent<SerializerComponent>();
var chatInfoNode = new ChatInfoNode()
{
ChatNodeType = (int)ChatNodeType.Link,
ChatNodeEvent = (int)ChatNodeEvent.ClickLink,
Content = content,
Data = SerializerManager.ProtoBufHelper.Serialize(chatLinkNode)
};
chatInfoTree.Node.Add(chatInfoNode);
return chatInfoTree;
}
/// <summary>
/// 添加图片节点
/// </summary>
/// <param name="chatInfoTree"></param>
/// <param name="content"></param>
/// <returns></returns>
public static ChatInfoTree AddendImageNode(this ChatInfoTree chatInfoTree, string content)
{
var chatInfoNode = new ChatInfoNode()
{
ChatNodeType = (int)ChatNodeType.Image,
Content = content
};
chatInfoTree.Node.Add(chatInfoNode);
return chatInfoTree;
}
/// <summary>
/// 添加打开UI节点
/// </summary>
/// <param name="chatInfoTree"></param>
/// <param name="content"></param>
/// <param name="uiName"></param>
/// <returns></returns>
public static ChatInfoTree AddendOpenUINode(this ChatInfoTree chatInfoTree, string content,string uiName)
{
var chatOpenUINode = new ChatOpenUINode()
{
UIName = uiName
};
// var serializerComponent = chatInfoTree.Scene.GetComponent<SerializerComponent>();
var chatInfoNode = new ChatInfoNode()
{
ChatNodeType = (int)ChatNodeType.OpenUI,
ChatNodeEvent = (int)ChatNodeEvent.OpenUI,
Content = content,
Data = SerializerManager.ProtoBufHelper.Serialize(chatOpenUINode)
};
chatInfoTree.Node.Add(chatInfoNode);
return chatInfoTree;
}
/// <summary>
/// 添加位置节点
/// </summary>
/// <param name="chatInfoTree"></param>
/// <param name="content"></param>
/// <param name="mapName"></param>
/// <param name="mapX"></param>
/// <param name="mapY"></param>
/// <param name="mapZ"></param>
/// <returns></returns>
public static ChatInfoTree AddendPositionNode(this ChatInfoTree chatInfoTree, string content, string mapName,
float mapX, float mapY, float mapZ)
{
var chatPositionNode = new ChatPositionNode()
{
MapName = mapName,
PosX = mapX,
PosY = mapY,
PosZ = mapZ,
};
// var serializerComponent = chatInfoTree.Scene.GetComponent<SerializerComponent>();
var chatInfoNode = new ChatInfoNode()
{
ChatNodeType = (int)ChatNodeType.Position,
ChatNodeEvent = (int)ChatNodeEvent.Position,
Content = content,
Data = SerializerManager.ProtoBufHelper.Serialize(chatPositionNode)
};
chatInfoTree.Node.Add(chatInfoNode);
return chatInfoTree;
}
}
}

View File

@@ -0,0 +1,11 @@
fileFormatVersion: 2
guid: 608005f1b93de4f9c965dd56e560e9c4
MonoImporter:
externalObjects: {}
serializedVersion: 2
defaultReferences: []
executionOrder: 0
icon: {instanceID: 0}
userData:
assetBundleName:
assetBundleVariant:

View File

@@ -0,0 +1,120 @@
namespace Fantasy
{
/// <summary>
/// 创建聊天树的总入口
/// </summary>
public static class ChatTreeFactory
{
/// <summary>
/// 创建世界聊天树
/// </summary>
/// <param name="scene"></param>
/// <returns></returns>
public static ChatInfoTree World(Scene scene)
{
return new ChatInfoTree()
{
Scene = scene,
ChatChannelType = (int)ChatChannelType.World,
};
}
/// <summary>
/// 创建私聊聊天树
/// </summary>
/// <param name="scene"></param>
/// <returns></returns>
public static ChatInfoTree Private(Scene scene)
{
return new ChatInfoTree()
{
Scene = scene,
ChatChannelType = (int)ChatChannelType.Private,
};
}
/// <summary>
/// 创建系统聊天树
/// </summary>
/// <param name="scene"></param>
/// <returns></returns>
public static ChatInfoTree System(Scene scene)
{
return new ChatInfoTree()
{
Scene = scene,
ChatChannelType = (int)ChatChannelType.System,
};
}
/// <summary>
/// 创建公广播聊天树
/// </summary>
/// <param name="scene"></param>
/// <returns></returns>
public static ChatInfoTree Broadcast(Scene scene)
{
return new ChatInfoTree()
{
Scene = scene,
ChatChannelType = (int)ChatChannelType.Broadcast,
};
}
/// <summary>
/// 创建公告聊天树
/// </summary>
/// <param name="scene"></param>
/// <returns></returns>
public static ChatInfoTree Notice(Scene scene)
{
return new ChatInfoTree()
{
Scene = scene,
ChatChannelType = (int)ChatChannelType.Notice,
};
}
/// <summary>
/// 创建队伍聊天树
/// </summary>
/// <param name="scene"></param>
/// <returns></returns>
public static ChatInfoTree Team(Scene scene)
{
return new ChatInfoTree()
{
Scene = scene,
ChatChannelType = (int)ChatChannelType.Team,
};
}
/// <summary>
/// 创建附近人聊天树
/// </summary>
/// <param name="scene"></param>
/// <returns></returns>
public static ChatInfoTree Near(Scene scene)
{
return new ChatInfoTree()
{
Scene = scene,
ChatChannelType = (int)ChatChannelType.Near,
};
}
/// <summary>
/// 创建当前地图聊天树
/// </summary>
/// <param name="scene"></param>
/// <returns></returns>
public static ChatInfoTree CurrentMap(Scene scene)
{
return new ChatInfoTree()
{
Scene = scene,
ChatChannelType = (int)ChatChannelType.CurrentMap,
};
}
}
}

View File

@@ -0,0 +1,11 @@
fileFormatVersion: 2
guid: 13c4041549f6e405a985eea47dbf08b7
MonoImporter:
externalObjects: {}
serializedVersion: 2
defaultReferences: []
executionOrder: 0
icon: {instanceID: 0}
userData:
assetBundleName:
assetBundleVariant: