yuanshen/Yuanshen.Gameserver/Game/GameGadget.cs
wisedev 62205c8062 Chests, ore and artifact drops
Gadgets are streamed alongside monsters now, so chests and ore nodes show up in
the world and can be interacted with. The two flows differ: for a chest the
client sends the finish request itself and the loot is granted on that one, for
ore it sends nothing more so the server has to close everything on the first
request.

Artifacts used to be silently dropped on the floor because the item ids that
actually roll were not in the reliquary table at all. Added the missing rows and
gave them real main stat and substat rolls instead of the fixed four.

Dropped items survive a relogin. The inventory is still rebuilt from the tables
on every login, so the trick is to remember where the default set ends and only
persist what was found in the world. Gacha and shop weapons were disappearing
the same way and are fixed by the same change.
2026-09-04 10:11:21 +03:00

67 lines
2 KiB
C#

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 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,
BornType = GadgetBornType.GadgetBornNone,
GadgetState = Node.State,
GadgetType = Node.GadgetType,
IsShowCutscene = false,
AuthorityPeerId = Player.PeerId,
IsEnableInteract = true,
InteractId = 0,
MarkFlag = Node.MarkFlag
}
};
entity.PropList.Add(new PropPair
{
Type = 4001,
PropValue = new PropValue { Type = 4001, Ival = Node.Level, Val = Node.Level }
});
return entity;
}
}