using Yuanshen.Protocol; namespace Yuanshen.Gameserver.Game; internal sealed class GameGadget { public uint EntityId { get; } public GadgetNode Node { get; } public uint GadgetId => Node.GadgetId; public uint NodeId => Node.NodeId; public bool IsChest => Node.IsChest; public bool IsDrop => Node.IsDrop; public uint DropItemId { get; init; } public uint DropCount { get; init; } public ulong DropGuid { get; init; } public GameGadget(GadgetNode node, uint entityId) { Node = node; EntityId = entityId; } public SceneEntityInfo AsSceneEntity() { SceneEntityInfo entity = new() { EntityType = ProtEntityType.ProtEntityGadget, EntityId = EntityId, LifeState = 1, MotionInfo = new MotionInfo { Pos = Node.Pos, Rot = Node.Rot, Speed = new Vector(), State = MotionState.MotionStandby }, EntityClientData = new EntityClientData(), EntityAuthorityInfo = new EntityAuthorityInfo { AbilityInfo = new AbilitySyncStateInfo { IsInited = true }, RendererChangedInfo = new EntityRendererChangedInfo(), AiInfo = new SceneEntityAiInfo { IsAiOpen = false, BornPos = Node.Pos }, BornPos = Node.Pos }, Gadget = new SceneGadgetInfo { GadgetId = Node.GadgetId, GroupId = Node.GroupId, ConfigId = Node.ConfigId, OwnerEntityId = 0, GadgetState = Node.State, GadgetType = Node.GadgetType, IsShowCutscene = false, AuthorityPeerId = Player.PeerId, IsEnableInteract = true, InteractId = 0, MarkFlag = Node.MarkFlag, BornType = GadgetBornType.GadgetBornNone } }; if (IsDrop) entity.Gadget.TrifleItem = new Item { ItemId = DropItemId, Guid = DropGuid, Material = new Material { Count = DropCount } }; entity.PropList.Add(new PropPair { Type = 4001, PropValue = new PropValue { Type = 4001, Ival = Node.Level, Val = Node.Level } }); return entity; } }