DayZ 1.27
DayZ Explorer by KGB
 
Загрузка...
Поиск...
Не найдено
InventoryInputUserData.c
См. документацию.
1
3{
5 static void SerializeMove(ParamsWriteContext ctx, int type, notnull InventoryLocation src, notnull InventoryLocation dst)
6 {
8 ctx.Write(type);
9 src.WriteToContext(ctx);
10 dst.WriteToContext(ctx);
11 }
12
13 static void SendInputUserDataMove(int type, notnull InventoryLocation src, notnull InventoryLocation dst)
14 {
15 if (GetGame().IsClient())
16 {
17 if (LogManager.IsSyncLogEnable()) syncDebugPrint("[syncinv] t=" + GetGame().GetTime() + "ms sending cmd=" + typename.EnumToString(InventoryCommandType, type) + " src=" + InventoryLocation.DumpToStringNullSafe(src) + " dst=" + InventoryLocation.DumpToStringNullSafe(dst));
19 SerializeMove(ctx, type, src, dst);
20 ctx.Send();
21 }
22 }
23
24 static void SendServerMove(Man player, int type, notnull InventoryLocation src, notnull InventoryLocation dst)
25 {
26 if (GetGame().IsServer())
27 {
28 if (LogManager.IsSyncLogEnable()) syncDebugPrint("[syncinv] server sending cmd=" + typename.EnumToString(InventoryCommandType, type) + " src=" + InventoryLocation.DumpToStringNullSafe(src) + " dst=" + InventoryLocation.DumpToStringNullSafe(dst));
30 SerializeMove(ctx, type, src, dst);
31 GameInventory.ServerLocationSyncMoveEntity(player, src.GetItem(), ctx);
32 }
33 }
34
35
37 static void SerializeSwap(ParamsWriteContext ctx, notnull InventoryLocation src1, notnull InventoryLocation src2, notnull InventoryLocation dst1, notnull InventoryLocation dst2, bool skippedSwap)
38 {
41 src1.WriteToContext(ctx);
42 src2.WriteToContext(ctx);
43 dst1.WriteToContext(ctx);
44 dst2.WriteToContext(ctx);
45 ctx.Write(skippedSwap);
46 }
47
48 static void SendInputUserDataSwap(notnull InventoryLocation src1, notnull InventoryLocation src2, notnull InventoryLocation dst1, notnull InventoryLocation dst2, bool skippedSwap = false)
49 {
50 if (GetGame().IsClient())
51 {
52 if (LogManager.IsSyncLogEnable()) syncDebugPrint("[syncinv] t=" + GetGame().GetTime() + "ms sending cmd=SWAP src1=" + InventoryLocation.DumpToStringNullSafe(src1) + " src2=" + InventoryLocation.DumpToStringNullSafe(src2) + " dst1=" + InventoryLocation.DumpToStringNullSafe(dst1) + " dst2=" + InventoryLocation.DumpToStringNullSafe(dst2));
54 SerializeSwap(ctx, src1, src2, dst1, dst2, skippedSwap);
55 ctx.Send();
56 }
57 }
58
59 static void SendServerSwap(notnull InventoryLocation src1, notnull InventoryLocation src2, notnull InventoryLocation dst1, notnull InventoryLocation dst2, bool skippedSwap = false)
60 {
61 if (GetGame().IsServer())
62 {
63 if (LogManager.IsSyncLogEnable()) syncDebugPrint("[syncinv] server sending cmd=SWAP src1=" + InventoryLocation.DumpToStringNullSafe(src1) + " src2=" + InventoryLocation.DumpToStringNullSafe(src2) + " dst1=" + InventoryLocation.DumpToStringNullSafe(dst1) + " dst2=" + InventoryLocation.DumpToStringNullSafe(dst2));
65 SerializeSwap(ctx, src1, src2, dst1, dst2, skippedSwap);
66 GameInventory.ServerLocationSwap(src1, src2, dst1, dst2, ctx);
67 }
68 }
69
70
73 {
75 ctx.Write(InventoryCommandType.HAND_EVENT);
76 e.WriteToContext(ctx);
77 }
78
80 {
81 if (GetGame().IsClient())
82 {
83 if (LogManager.IsSyncLogEnable()) syncDebugPrint("[syncinv] t=" + GetGame().GetTime() + "ms SendInputUserDataHandEvent e=" + e.DumpToString());
85 SerializeHandEvent(ctx, e);
86 ctx.Send();
87 }
88 }
89
90 static void SendServerHandEventViaInventoryCommand(notnull Man player, HandEventBase e)
91 {
92 // Warning: this uses NetworkMessageInventoryCommand
93 if (GetGame().IsServer())
94 {
95 if (e.IsServerSideOnly())
96 Error("[syncinv] SendServerHandEvent - called on server side event only, e=" + e.DumpToString());
97 if (player.IsAlive())
98 Error("[syncinv] SendServerHandEvent - called on living thing.. server hand command is only for dead people, e=" + e.DumpToString());
99 if (LogManager.IsSyncLogEnable()) syncDebugPrint("[syncinv] SendServerHandEventViaInventoryCommand SendInputUserDataHandEvent e=" + e.DumpToString());
101 SerializeHandEvent(ctx, e);
102 GameInventory.ServerHandEvent(player, e.GetSrcEntity(), ctx);
103 }
104 }
105
106}
107
void syncDebugPrint(string s)
Определения Debug.c:1
InventoryCommandType
Определения Inventory.c:3
const int INPUT_UDT_INVENTORY
Определения _constants.c:9
float GetTime()
Определения NotificationSystem.c:35
static proto native bool ServerHandEvent(notnull Man player, notnull EntityAI item, ParamsWriteContext ctx)
hand event to clients
static proto native bool ServerLocationSwap(notnull InventoryLocation src1, notnull InventoryLocation src2, notnull InventoryLocation dst1, notnull InventoryLocation dst2, ParamsWriteContext ctx)
swaps two entities
static proto native bool ServerLocationSyncMoveEntity(Man player, notnull EntityAI item, ParamsWriteContext ctx)
synchronously removes item from current inventory location and adds it to destination + sync via inve...
script counterpart to engine's class Inventory
Определения Inventory.c:79
override bool IsServerSideOnly()
Определения Hand_Events.c:718
override string DumpToString()
Определения Hand_Events.c:332
override void WriteToContext(ParamsWriteContext ctx)
Определения Hand_Events.c:282
Abstracted event, not to be used, only inherited.
Определения Hand_Events.c:209
static void SerializeSwap(ParamsWriteContext ctx, notnull InventoryLocation src1, notnull InventoryLocation src2, notnull InventoryLocation dst1, notnull InventoryLocation dst2, bool skippedSwap)
swap
Определения InventoryInputUserData.c:37
static void SendServerMove(Man player, int type, notnull InventoryLocation src, notnull InventoryLocation dst)
Определения InventoryInputUserData.c:24
static void SendInputUserDataHandEvent(HandEventBase e)
Определения InventoryInputUserData.c:79
static void SendInputUserDataMove(int type, notnull InventoryLocation src, notnull InventoryLocation dst)
Определения InventoryInputUserData.c:13
static void SendInputUserDataSwap(notnull InventoryLocation src1, notnull InventoryLocation src2, notnull InventoryLocation dst1, notnull InventoryLocation dst2, bool skippedSwap=false)
Определения InventoryInputUserData.c:48
static void SerializeHandEvent(ParamsWriteContext ctx, HandEventBase e)
hand
Определения InventoryInputUserData.c:72
static void SerializeMove(ParamsWriteContext ctx, int type, notnull InventoryLocation src, notnull InventoryLocation dst)
move
Определения InventoryInputUserData.c:5
static void SendServerSwap(notnull InventoryLocation src1, notnull InventoryLocation src2, notnull InventoryLocation dst1, notnull InventoryLocation dst2, bool skippedSwap=false)
Определения InventoryInputUserData.c:59
static void SendServerHandEventViaInventoryCommand(notnull Man player, HandEventBase e)
Определения InventoryInputUserData.c:90
static string DumpToStringNullSafe(InventoryLocation loc)
Определения InventoryLocation.c:226
InventoryLocation.
Определения InventoryLocation.c:29
static bool IsSyncLogEnable()
Определения Debug.c:678
Определения Debug.c:594
proto native void Send()
Определения gameplay.c:121
proto bool Write(void value_out)
proto native CGame GetGame()
Serializer ParamsWriteContext
Определения gameplay.c:16
void Error(string err)
Messagebox with error message.
Определения EnDebug.c:90