using System;
using System.Collections.Generic;
using Woodpecker.Specialized.Text;
using Woodpecker.Specialized.Encoding;
using Woodpecker.Net.Game.Messages;
using Woodpecker.Game.Moderation;
using Woodpecker.Game.Rooms.Units;
using Woodpecker.Game.Rooms.Instances;
using Woodpecker.Game.Rooms.Pathfinding;
namespace Woodpecker.Game.Rooms.Instances.Interaction
{
///
/// Provides common target methods for both public spaces and user flats.
///
public partial class roomReactor : Reactor
{
#region Target methods
///
/// 52 - "@t"
///
public void CHAT()
{
roomUser Me = Session.roomInstance.getRoomUser(Session.ID);
if (!Me.isMuted)
{
string Text = Request.getParameter(0);
stringFunctions.filterVulnerableStuff(ref Text, true);
if (!this.handleSpecialChatCommand(Text))
{
Session.roomInstance.sendTalk(Me.ID, Me.X, Me.Y, Text);
Session.roomInstance.animateTalkingUnit(Me, ref Text, true);
Engine.Game.Moderation.addChatMessageToLogStack(Session.ID, Session.User.ID, Session.roomID, 0, chatType.say, ref Text);
}
this.handleBotResponse(Text);
}
}
///
/// 55 - "@w"
///
public void SHOUT()
{
roomUser Me = Session.roomInstance.getRoomUser(Session.ID);
if (!Me.isMuted)
{
string Text = Request.getParameter(0);
stringFunctions.filterVulnerableStuff(ref Text, true);
if (!this.handleSpecialChatCommand(Text))
{
Session.roomInstance.sendShout(Me.ID, Me.X, Me.Y, Text);
Session.roomInstance.animateTalkingUnit(Me, ref Text, true);
Engine.Game.Moderation.addChatMessageToLogStack(Session.ID, Session.User.ID, Session.roomID, 0, chatType.shout, ref Text);
}
this.handleBotResponse(Text);
}
}
///
/// 56 - "@x"
///
public void WHISPER()
{
roomUser Me = Session.roomInstance.getRoomUser(Session.ID);
if (!Me.isMuted)
{
string whisperBody = Request.getParameter(0);
string receiverName = whisperBody.Substring(0, whisperBody.IndexOf(' '));
string Text = whisperBody.Substring(receiverName.Length + 1);
stringFunctions.filterVulnerableStuff(ref Text, true);
serverMessage Whisper = new serverMessage(25); // "@Y"
Whisper.appendWired(Me.ID);
Whisper.appendClosedValue(Text);
Session.gameConnection.sendMessage(Whisper);
if (receiverName.Length > 0 && receiverName != Session.User.Username)
{
roomUser Receiver = Session.roomInstance.getRoomUser(receiverName);
if (Receiver != null)
Receiver.Session.gameConnection.sendMessage(Whisper);
Engine.Game.Moderation.addChatMessageToLogStack(Session.ID, Session.User.ID, Session.roomID, Receiver.Session.User.ID, chatType.whisper, ref Text);
}
}
}
///
/// 60 - "@|"
///
public void G_HMAP()
{
Response.Initialize(31); // "@_"
Response.Append(Session.roomInstance.getClientFloorMap());
sendResponse();
}
///
/// 61 - "@}"
///
public void G_USRS()
{
Response.Initialize(28); // "@\"
Response.Append(Session.roomInstance.getRoomUnits());
sendResponse();
}
///
/// 62 - "@~"
///
public void G_OBJS()
{
Response.Initialize(30); // "@^"
//if (Session.roomInstance.getModel().typeName.Contains("model"))
Response.Append(Session.roomInstance.getFloorItems(true));
/*else //public room
{
String Publicroom_items = "a160 crl_lamp 16 0 0 0 1\r\ny170 crl_sofa2c 17 0 0 4 2\r\nw180 crl_sofa2b 18 0 0 4 2\r\nv190 crl_sofa2a 19 0 0 4 2\r\na200 crl_lamp 20 0 0 0 1\r\nb161 crl_chair 16 1 0 2 2\r\na72 crl_lamp 7 2 0 0 1\r\na112 crl_lamp 11 2 0 0 1\r\nb162 crl_chair 16 2 0 2 2\r\nc53 crl_pillar 5 3 0 0 1\r\nb73 crl_chair 7 3 0 2 2\r\nu93 crl_table1b 9 3 0 0 1\r\ns113 crl_sofa1c 11 3 0 6 2\r\nb163 crl_chair 16 3 0 2 2\r\nA193 crl_table2b 19 3 0 0 1\r\nz203 crl_table2a 20 3 0 0 1\r\na04 crl_lamp 0 4 0 0 1\r\ny14 crl_sofa2c 1 4 0 4 2\r\nw24 crl_sofa2b 2 4 0 4 2\r\nv34 crl_sofa2a 3 4 0 4 2\r\na44 crl_lamp 4 4 0 0 1\r\nt94 crl_table1a 9 4 0 0 1\r\nr114 crl_sofa1b 11 4 0 6 2\r\nh154 crl_wall2a 15 4 0 0 1\r\na164 crl_lamp 16 4 0 0 1\r\nb05 crl_chair 0 5 0 2 2\r\nb75 crl_chair 7 5 0 2 2\r\nq115 crl_sofa1a 11 5 0 6 2\r\nA26 crl_table2b 2 6 0 0 1\r\nz36 crl_table2a 3 6 0 0 1\r\na116 crl_lamp 11 6 0 0 1\r\nb07 crl_chair 0 7 0 2 2\r\na08 crl_lamp 0 8 0 0 1\r\nD18 crl_sofa3c 1 8 0 0 2\r\nC28 crl_sofa3b 2 8 0 0 2\r\nB38 crl_sofa3a 3 8 0 0 2\r\na48 crl_lamp 4 8 0 0 1\r\no198 crl_barchair2 19 8 0 0 2\r\np208 crl_tablebar 20 8 0 0 1\r\no218 crl_barchair2 21 8 0 0 2\r\nE59 crl_pillar2 5 9 0 0 1\r\nc99 crl_pillar 9 9 0 0 1\r\nP815 crl_desk1a 8 15 0 0 1\r\nO915 crl_deski 9 15 0 0 1\r\nN1015 crl_deskh 10 15 0 0 1\r\nM1016 crl_deskg 10 16 0 0 1\r\nL1017 crl_deskf 10 17 0 0 1\r\nK1018 crl_deske 10 18 0 0 1\r\nK1019 crl_deske 10 19 0 0 1\r\nK1020 crl_deske 10 20 0 0 1\r\nK1021 crl_deske 10 21 0 0 1\r\nK1022 crl_deske 10 22 0 0 1\r\nK1023 crl_deske 10 23 0 0 1\r\nG724 crl_wallb 7 24 0 0 1\r\nK1024 crl_deske 10 24 0 0 1\r\nF725 crl_walla 7 25 0 0 1\r\nH825 crl_desk1b 8 25 0 0 1\r\nI925 crl_desk1c 9 25 0 0 1\r\nJ1025 crl_desk1d 10 25 0 0 1\r\nd1227 crl_lamp2 12 27 0 0 1\r\nf1327 crl_cabinet2 13 27 0 0 1\r\ne1427 crl_cabinet1 14 27 0 0 1\r\nd1527 crl_lamp2 15 27 0 0 1";
string[] sItems = Publicroom_items.Split('\n');
Publicroom_items = "";
for (int i = 0; i < sItems.Length; i++)
{
string[] sData = sItems[i].Split(' ');
int sX = Convert.ToInt32(sData[2]);
int sY = Convert.ToInt32(sData[3]);
//template.mDynamicHeightmap[sX, sY] = 0;
//template.mSquares[sX, sY] = SquareState.Closed;
//template.mDynamicHeight[sX, sY] = 1.0F;
Publicroom_items += sData[0] + " " + sData[1] + " " + sData[2] + " " + sData[3] + " " + sData[4] + " " + sData[5] + Convert.ToChar(13);
}
Response.Append(Publicroom_items);
}*/
sendResponse();
Response.Initialize(32); // "@`"
//Response.Append(Session.roomInstance.getFloorItems(false));
Response.Append("H");
sendResponse();
}
///
/// 63 - "@"
///
public void G_ITEMS()
{
Response.Initialize(45); // "@m"
Response.Append(Session.roomInstance.getWallItems());
sendResponse();
}
///
/// 64 - "A@"
///
public void G_STAT()
{
Response.Initialize(34); // "@b"
Response.Append(Session.roomInstance.getRoomUnitStatuses());
sendResponse();
Session.roomInstance.startUser(Session);
}
///
/// 75 - "AK"
///
public void MOVE()
{
try
{
byte toX = Convert.ToByte(base64Encoding.Decode(Request.Content.Substring(0, 2)));
byte toY = Convert.ToByte(base64Encoding.Decode(Request.Content.Substring(2, 2)));
Session.roomInstance.requestStartRoomUnitWalk(Session.ID, toX, toY, false);
}
catch { }
}
///
/// 79 - "AO"
///
public void LOOKTO()
{
roomUser Me = Session.roomInstance.getRoomUser(Session.ID);
if (!Me.hasStatus("sit") && !Me.hasStatus("lay")) // Can rotate
{
string[] Coords = Request.Content.Split(' ');
int toX = int.Parse(Coords[0]);
int toY = int.Parse(Coords[1]);
Me.rotationHead = rotationCalculator.calculateHumanDirection(Me.X, Me.Y, toX, toY);
Me.rotationBody = Me.rotationHead;
Me.requiresUpdate = true;
}
}
///
/// 80 - "AP"
///
public void CARRYDRINK()
{
roomUser Me = Session.roomInstance.getRoomUser(Session.ID);
Items.carryItemHelper.setHandItem(ref Me, Request.Content);
}
///
/// 87 - "AW"
///
public void CARRYITEM()
{
string Item = "20"; // Camera
roomUser Me = Session.roomInstance.getRoomUser(Session.ID);
Items.carryItemHelper.setHandItem(ref Me, Item);
}
///
/// 93 - "A]"
///
public void DANCE()
{
roomUser Me = Session.roomInstance.getRoomUser(Session.ID);
if(Me.hasStatus("sit") || Me.hasStatus("lay") || Me.hasStatus("swim")) // Can't dance right now
return;
string danceType = null;
if (Request.Content.Length > 0) // Club dance
{
int danceID = Request.getNextWiredParameter();
if (danceID < 1 || danceID > 4 || !Session.User.hasFuseRight("fuse_use_club_dance"))
return;
danceType = danceID.ToString();
}
Me.removeStatus("handitem");
Me.addStatus("dance", "dance", danceType, 0, null, 0, 0);
}
///
/// 94 - "A^"
///
public void WAVE()
{
roomUser Me = Session.roomInstance.getRoomUser(Session.ID);
Me.addStatus("wave", "wave", null, 2, null, 0, 0);
}
///
/// 115 - "As"
///
public void GOAWAY()
{
Session.kickFromRoom("");
}
///
/// 126 - "A~"
///
public void GETROOMAD()
{
Response.Initialize(208); // "CP"
string adImage = ""; // TODO: configure this ad
string adUri = ""; // TODO: idem dito
if (adImage.Length > 0)
{
Response.appendTabbedValue(adImage);
Response.Append(adUri);
}
else
Response.Append(0); // No advertisement to be shown
sendResponse();
}
///
/// 158 - "B^"
///
public void SETBADGE()
{
string newBadge = Request.getParameter(0);
if(!Engine.Game.Users.userHasBadge(Session.User,newBadge))
return;
bool showBadge = wireEncoding.decodeBoolean(Request.Content[Request.Content.Length - 1]);
if(showBadge)
Session.User.Badge = newBadge;
else
Session.User.Badge = "";
Session.roomInstance.updateUserBadge(Session.ID);
Session.User.updateAppearanceDetails();
}
///
/// 215 - "CW"
///
public void GET_ALIAS_LIST()
{
Response.Initialize(295); // "Dg"
Response.Append(Engine.Game.Items.spriteIndex);
sendResponse();
Response.Initialize(297); // "Di"
Response.appendWired(false);
sendResponse();
}
#endregion
}
}