1 [
EntityEditorProps(
category:
"GameScripted/Test", description:
"Testing entity for scripted replication", color:
"0 0 255 255")]
15 static void Encode(SSnapSerializerBase snapshot, ScriptCtx hint, ScriptBitSerializer packet)
17 snapshot.Serialize(packet, 9);
21 static bool Decode(ScriptBitSerializer packet, ScriptCtx hint, SSnapSerializerBase snapshot)
23 return snapshot.Serialize(packet, 9);
27 static bool SnapCompare(SSnapSerializerBase lhs, SSnapSerializerBase rhs, ScriptCtx hint)
29 return lhs.CompareSnapshots(rhs, 9);
33 static bool PropCompare(
RplTestPropType prop, SSnapSerializerBase snapshot, ScriptCtx hint)
35 return snapshot.Compare(prop.iVal, 4)
36 && snapshot.Compare(prop.fVal, 4)
37 && snapshot.Compare(prop.bVal, 1);
41 static bool Extract(
RplTestPropType prop, ScriptCtx hint, SSnapSerializerBase snapshot)
43 snapshot.SerializeBytes(prop.iVal, 4);
44 snapshot.SerializeBytes(prop.fVal, 4);
45 snapshot.SerializeBytes(prop.bVal, 1);
51 static bool Inject(SSnapSerializerBase snapshot, ScriptCtx hint,
RplTestPropType prop)
53 snapshot.SerializeBytes(prop.iVal, 4);
54 snapshot.SerializeBytes(prop.fVal, 4);
55 snapshot.SerializeBytes(prop.bVal, 1);
66 [
RplProp(condition: RplCondition.NoOwner)]
67 private int m_iTest = 0;
68 private int m_iTestLast = 0;
72 [
RplProp(onRplName:
"OnRpl_CustomProp")]
75 void OnRpl_CustomProp()
77 Print(
"CUSTOM RPLPROP CHANGE1: " + customProp.iVal);
78 Print(
"CUSTOM RPLPROP CHANGE2: " + customProp.fVal);
79 Print(
"CUSTOM RPLPROP CHANGE3: " + customProp.bVal);
83 [
RplRpc(RplChannel.Reliable, RplRcver.Broadcast)]
84 void NetTestRpc(
int testNum)
86 Print(
"RPC RECEIVE: " + testNum.ToString());
90 override void EOnFrame(IEntity owner,
float timeSlice)
92 if (Debug.KeyState(KeyCode.KC_P))
94 Debug.ClearKey(KeyCode.KC_P);
95 int rndRPCNum = Math.RandomIntInclusive(0, 100);
96 Rpc(NetTestRpc, rndRPCNum);
97 Print(
"RPC SEND: " + rndRPCNum.ToString());
100 if (RplSession.Mode() == RplMode.Client)
104 Print(
"RPLPROP CHANGED: " +
m_iTest);
105 Print(
"CUSTOM RPLPROP CHANGED1: " + customProp.iVal);
106 Print(
"CUSTOM RPLPROP CHANGED2: " + customProp.fVal);
107 Print(
"CUSTOM RPLPROP CHANGED3: " + customProp.bVal);
121 if (RplSession.Mode() != RplMode.Client)
123 m_iTest = Math.RandomIntInclusive(0, 100);
124 customProp.iVal = Math.RandomIntInclusive(0, 100);
125 customProp.fVal = Math.RandomFloatInclusive(0, 100);
126 customProp.bVal = customProp.iVal > 50;
129 Print(
"RPLPROP CHANGE: " +
m_iTest);
130 Print(
"CUSTOM RPLPROP CHANGE1: " + customProp.iVal);
131 Print(
"CUSTOM RPLPROP CHANGE2: " + customProp.fVal);
132 Print(
"CUSTOM RPLPROP CHANGE3: " + customProp.bVal);
139 SetEventMask(EntityEvent.FRAME);
140 SetFlags(EntityFlags.ACTIVE,
true);