private void CheckNpcOwnerId(NpcInfo info) { if (null == info) { return; } if (info.OwnerId > 0) { Room room = GetRoom(); if (null != room && null != room.GetActiveScene()) { int new_owner_id = 0; bool is_online = false; foreach (User v in room.RoomUsers) { if (null != v.Info && v.UserControlState != (int)UserControlState.UserDropped && v.UserControlState != (int)UserControlState.Remove) { new_owner_id = v.Info.GetId(); if (new_owner_id == info.OwnerId) { is_online = true; break; } } } if (!is_online) { info.OwnerId = new_owner_id; Msg_RC_SyncNpcOwnerId builder = DataSyncUtility.BuildSyncNpcOwnerIdMessage(info); NotifyAreaUser(info, builder, false); } } } }
public static Msg_RC_SyncNpcOwnerId BuildSyncNpcOwnerIdMessage(EntityInfo npc) { Msg_RC_SyncNpcOwnerId builder = new Msg_RC_SyncNpcOwnerId(); builder.npc_id = npc.GetId(); builder.owner_id = npc.OwnerId; return(builder); }
internal static Msg_RC_SyncNpcOwnerId BuildSyncNpcOwnerIdMessage(NpcInfo npc) { Msg_RC_SyncNpcOwnerId builder = new Msg_RC_SyncNpcOwnerId(); builder.npc_id = npc.GetId(); builder.owner_id = npc.OwnerId; return(builder); }
internal static void Execute(object msg, NetConnection conn) { Msg_RC_SyncNpcOwnerId target_msg = msg as Msg_RC_SyncNpcOwnerId; if (null == target_msg) { return; } EntityInfo obj = PluginFramework.Instance.GetEntityById(target_msg.npc_id); if (null != obj) { EntityInfo npc = obj as EntityInfo; if (null != npc) { npc.OwnerId = target_msg.owner_id; } } }