public static Serial TargetObject() { if (!Core.LoggedIn) return Serial.Invalid; TargetData info = new TargetData(); info.TargetId = (uint)new Random().Next(); OperationResult result = new OperationResult(); lock (syncRoot) { if (CurrentState != State.Ready) { Reset(); } Debug.Assert(CurrentState == State.Ready, "CurrentState is not Ready. Internal error."); clientTarget = info; operationResult = result; CurrentState = State.Target; BeginTimeout(PhoenixTargetTimeout); Core.SendToClient(info.ToData()); } result.Event.WaitOne(); if (info.Serial == 0) info.Serial = Serial.Invalid; Debug.WriteLine("Client returned object target. Serial=0x" + info.Serial.ToString("X8"), "UIManager"); return info.Serial; }
private static CallbackResult OnServerTargetMulti(byte[] data, CallbackResult prevResult) { lock (syncRoot) { TargetData td = new TargetData(); td.Type = data[1]; td.TargetId = ByteConverter.BigEndian.ToUInt32(data, 2); ushort multi = ByteConverter.BigEndian.ToUInt16(data, 18); Trace.WriteLine("Server target \"Place Multi 0x" + multi.ToString("X4") + "\" received.", "UIManager"); // Simulate standart target packet so i don't have to handle it specially :) return OnServerTarget(td.ToData(), prevResult); } }
public static StaticTarget Target() { if (!Core.LoggedIn) return null; TargetData info = new TargetData(); info.Type = 1; info.TargetId = (uint)new Random().Next(); info.X = 0xFFFF; info.Y = 0xFFFF; OperationResult result = new OperationResult(); lock (syncRoot) { if (CurrentState != State.Ready) { Reset(); } Debug.Assert(CurrentState == State.Ready, "CurrentState is not Ready. Internal error."); Core.SendToClient(info.ToData()); clientTarget = info; operationResult = result; CurrentState = State.Target; BeginTimeout(PhoenixTargetTimeout); } result.Event.WaitOne(); Debug.WriteLine(String.Format("Client returned target: Serial=0x{0:X8} X={1} Y={2} Z={3} Graphic=0x{4:X4}", info.Serial, info.X, info.Y, info.Z, info.Graphic), "UIManager"); return new StaticTarget(info.Serial, info.X, info.Y, info.Z, info.Graphic); }