public bool Execute(params object[] stuff) { if (!Items.Any()) { return(true); } bool useExtradata, useRot, usePos; Dictionary <uint, string[]> itemsOriginalData; try { if (string.IsNullOrWhiteSpace(OtherString) || !OtherString.Contains(",") || !OtherExtraString.Contains("|")) { return(false); } string[] booleans = OtherString.ToLower().Split(','); useExtradata = booleans[0] == "true"; useRot = booleans[1] == "true"; usePos = booleans[2] == "true"; itemsOriginalData = OtherExtraString.Split('/').Select(data => data.Split('|')).ToDictionary(array => uint.Parse(array[0]), array => array.Skip(1).ToArray()); } catch (Exception e) { Writer.LogException(e.ToString()); return(false); } foreach (RoomItem current in Items) { if (current == null || !itemsOriginalData.ContainsKey(current.Id)) { return(false); } string[] originalData = itemsOriginalData[current.Id]; if (useRot) { if (current.Rot != int.Parse(originalData[1])) { return(false); } } if (useExtradata) { if (current.ExtraData == string.Empty) { current.ExtraData = "0"; } if (current.ExtraData != (originalData[0] == string.Empty ? "0" : originalData[0])) { return(false); } } if (!usePos) { continue; } string[] originalPos = originalData[2].Split(','); if ((current.X != int.Parse(originalPos[0])) || (current.Y != int.Parse(originalPos[1]))) { return(false); } } return(true); }
public bool Execute(params object[] stuff) { if (Room == null) { return(false); } if (string.IsNullOrWhiteSpace(OtherString) || string.IsNullOrWhiteSpace(OtherExtraString)) { return(false); } string[] booleans = OtherString.Split(','); if (booleans.Length < 3) { return(false); } bool extraData = booleans[0] == "true"; bool rot = booleans[1] == "true"; bool position = booleans[2] == "true"; foreach (string itemData in OtherExtraString.Split('/')) { if (string.IsNullOrWhiteSpace(itemData)) { continue; } string[] innerData = itemData.Split('|'); uint itemId = uint.Parse(innerData[0]); RoomItem fItem = Room.GetRoomItemHandler().GetItem(itemId); if (fItem == null) { continue; } string extraDataToSet = extraData ? innerData[1] : fItem.ExtraData; int rotationToSet = rot ? int.Parse(innerData[2]) : fItem.Rot; string[] positions = innerData[3].Split(','); int xToSet = position ? int.Parse(positions[0]) : fItem.X; int yToSet = position ? int.Parse(positions[1]) : fItem.Y; double zToSet = position ? double.Parse(positions[2]) : fItem.Z; ServerMessage serverMessage = new ServerMessage(LibraryParser.OutgoingRequest("ItemAnimationMessageComposer")); serverMessage.AppendInteger(fItem.X); serverMessage.AppendInteger(fItem.Y); serverMessage.AppendInteger(xToSet); serverMessage.AppendInteger(yToSet); serverMessage.AppendInteger(1); serverMessage.AppendInteger(fItem.Id); serverMessage.AppendString(fItem.Z.ToString(Yupi.CultureInfo)); serverMessage.AppendString(zToSet.ToString(Yupi.CultureInfo)); serverMessage.AppendInteger(0); Room.SendMessage(serverMessage); Room.GetRoomItemHandler() .SetFloorItem(null, fItem, xToSet, yToSet, rotationToSet, false, false, false, false, false); fItem.ExtraData = extraDataToSet; fItem.UpdateState(); Room.GetGameMap().GenerateMaps(); } return(true); }
public bool Execute(params object[] stuff) { if (Room == null) { return(false); } if (String.IsNullOrWhiteSpace(OtherString) || String.IsNullOrWhiteSpace(OtherExtraString)) { return(false); } var booleans = OtherString.Split(','); if (booleans.Length < 3) { return(false); } var extraData = booleans[0] == "true"; var rot = booleans[1] == "true"; var position = booleans[2] == "true"; foreach (var itemData in OtherExtraString.Split('/')) { if (String.IsNullOrWhiteSpace(itemData)) { continue; } var innerData = itemData.Split('|'); var itemId = uint.Parse(innerData[0]); var fItem = Room.GetRoomItemHandler().GetItem(itemId); if (fItem == null) { continue; } var extraDataToSet = (extraData) ? innerData[1] : fItem.ExtraData; var rotationToSet = (rot) ? int.Parse(innerData[2]) : fItem.Rot; var positions = innerData[3].Split(','); var xToSet = (position) ? int.Parse(positions[0]) : fItem.X; var yToSet = (position) ? int.Parse(positions[1]) : fItem.Y; var zToSet = (position) ? double.Parse(positions[2]) : fItem.Z; var serverMessage = new ServerMessage(LibraryParser.OutgoingRequest("ItemAnimationMessageComposer")); serverMessage.AppendInteger(fItem.X); serverMessage.AppendInteger(fItem.Y); serverMessage.AppendInteger(xToSet); serverMessage.AppendInteger(yToSet); serverMessage.AppendInteger(1); serverMessage.AppendInteger(fItem.Id); serverMessage.AppendString(fItem.Z.ToString(Plus.CultureInfo)); serverMessage.AppendString(zToSet.ToString(Plus.CultureInfo)); serverMessage.AppendInteger(0); Room.SendMessage(serverMessage); Room.GetRoomItemHandler() .SetFloorItem(null, fItem, xToSet, yToSet, rotationToSet, false, false, false, false, false); fItem.ExtraData = extraDataToSet; fItem.UpdateState(); } return(true); }