Already is 0.5s in repeater. the furni slow to follow userI'm not sure I understand, you can decrease the time for the repeat wired?
Sorry, plus emulatorFirst step is stating which emulator you are using.
Thank you, i need for plus emulatorThis was an issue I tried relentlessly to fix. I really struggled. Hope you find a solution! - Arcturus Morningstar has no issue with this.
Would that make the pursuit of furniture faster?I would look into the OnCycle function of the wired, to see how often the wired function is being called. It might only be executed once a second, instead of everything half a second.
If your timer cycle is only checking it every second, then it's impossible for it to move every 0.5 seconds, so yes it would.Would that make the pursuit of furniture faster?
My code of MoveFurniToUser is:If your timer cycle is only checking it every second, then it's impossible for it to move every 0.5 seconds, so yes it would.
public Point GetChaseMovement(Item Item)
{
int Distance = 99;
Point Coord = new Point(0, 0);
int iX = Item.GetX;
int iY = Item.GetY;
bool X = false;
foreach (RoomUser User in _room.GetRoomUserManager().GetRoomUsers())
{
if (User.X == Item.GetX || Item.GetY == User.Y)
{
if (User.X == Item.GetX)
{
int Difference = Math.Abs(User.Y - Item.GetY);
if (Difference < Distance)
{
Distance = Difference;
Coord = User.Coordinate;
X = false;
}
else
continue;
}
else if (User.Y == Item.GetY)
{
int Difference = Math.Abs(User.X - Item.GetX);
if (Difference < Distance)
{
Distance = Difference;
Coord = User.Coordinate;
X = true;
}
else
continue;
}
else if (User.Y != Item.GetY)
{
int Difference = Math.Abs(User.X - Item.GetY);
if (Difference < Distance)
{
Distance = Difference;
Coord = User.Coordinate;
X = true;
}
else
continue;
}
else
continue;
}
}
if (Distance > 5)
return Item.GetSides().OrderBy(x => Guid.NewGuid()).FirstOrDefault();
if (X && Distance < 99)
{
if (iX > Coord.X)
{
iX--;
return new Point(iX, iY);
}
else
{
iX++;
return new Point(iX, iY);
}
}
else if (!X && Distance < 99)
{
if (iY > Coord.Y)
{
iY--;
return new Point(iX, iY);
}
else
{
iY++;
return new Point(iX, iY);
}
}
else
return Item.Coordinate;
}
public bool OnCycle()
{
if (Instance == null || !Requested || _next < 1)
return false;
var time = OreoServer.GetUnixTimestamp();
if (_next <= time)
{
foreach (
var Item in
SetItems.Values.ToList()
.Where(Item => Item != null)
.Where(Item => Instance.GetRoomItemHandler().GetFloor.Contains(Item)))
{
Item toRemove;
if (Instance.GetWired().OtherBoxHasItem(this, Item.Id))
SetItems.TryRemove(Item.Id, out toRemove);
var Point = Instance.GetGameMap().GetChaseMovement(Item);
Instance.GetWired().onUserFurniCollision(Instance, Item);
if (!Instance.GetGameMap().ItemCanMove(Item, Point))
continue;
if (Instance.GetGameMap().CanRollItemHere(Point.X, Point.Y) &&
!Instance.GetGameMap().SquareHasUsers(Point.X, Point.Y))
{
var NewZ = Item.GetZ;
var CanBePlaced = true;
var Items = Instance.GetGameMap().GetCoordinatedItems(Point);
foreach (var IItem in Items.ToList().Where(IItem => IItem != null && IItem.Id != Item.Id))
{
if (!IItem.GetBaseItem().Walkable)
{
_next = 0;
CanBePlaced = false;
break;
}
if (IItem.TotalHeight > NewZ)
NewZ = IItem.TotalHeight;
if (CanBePlaced && !IItem.GetBaseItem().Stackable)
CanBePlaced = false;
}
if (CanBePlaced && Point != Item.Coordinate)
{
Instance.SendMessage(new SlideObjectBundleComposer(Item.GetX, Item.GetY, Item.GetZ, Point.X,
Point.Y, NewZ, 0, 0, Item.Id));
Instance.GetRoomItemHandler().SetFloorItem(Item, Point.X, Point.Y, NewZ);
}
}
}
_next = 0;
return true;
}
return false;
}
I already have put the code OnCycle, don't this is?The function that calls oncycle, has nothing to do with OnCycle
internal class MoveFurniToUserBox : IWiredItem, IWiredCycle
{
private double _delay;
private double _next;
private bool Requested;
public MoveFurniToUserBox(Room Instance, Item Item)
{
this.Instance = Instance;
this.Item = Item;
SetItems = new ConcurrentDictionary<int, Item>();
TickCount = Delay;
Requested = false;
}
public double Delay
{
get { return _delay; }
set
{
_delay = value;
TickCount = value + 1;
}
}
public double TickCount { get; set; }
public bool OnCycle()
{
if (Instance == null || !Requested || _next < 1)
return false;
var time = OreoServer.GetUnixTimestamp();
if (_next <= time)
{
foreach (
var Item in
SetItems.Values.ToList()
.Where(Item => Item != null)
.Where(Item => Instance.GetRoomItemHandler().GetFloor.Contains(Item)))
{
Item toRemove;
if (Instance.GetWired().OtherBoxHasItem(this, Item.Id))
SetItems.TryRemove(Item.Id, out toRemove);
var Point = Instance.GetGameMap().GetChaseMovement(Item);
Instance.GetWired().onUserFurniCollision(Instance, Item);
if (!Instance.GetGameMap().ItemCanMove(Item, Point))
continue;
if (Instance.GetGameMap().CanRollItemHere(Point.X, Point.Y) &&
!Instance.GetGameMap().SquareHasUsers(Point.X, Point.Y))
{
var NewZ = Item.GetZ;
var CanBePlaced = true;
var Items = Instance.GetGameMap().GetCoordinatedItems(Point);
foreach (var IItem in Items.ToList().Where(IItem => IItem != null && IItem.Id != Item.Id))
{
if (!IItem.GetBaseItem().Walkable)
{
_next = 0;
CanBePlaced = false;
break;
}
if (IItem.TotalHeight > NewZ)
NewZ = IItem.TotalHeight;
if (CanBePlaced && !IItem.GetBaseItem().Stackable)
CanBePlaced = false;
}
if (CanBePlaced && Point != Item.Coordinate)
{
Instance.SendMessage(new SlideObjectBundleComposer(Item.GetX, Item.GetY, Item.GetZ, Point.X,
Point.Y, NewZ, 0, 0, Item.Id));
Instance.GetRoomItemHandler().SetFloorItem(Item, Point.X, Point.Y, NewZ);
}
}
}
_next = 0;
return true;
}
return false;
}
public Room Instance { get; set; }
public Item Item { get; set; }
public WiredBoxType Type => WiredBoxType.EffectMoveFurniToNearestUser;
public ConcurrentDictionary<int, Item> SetItems { get; set; }
public string StringData { get; set; }
public bool BoolData { get; set; }
public string ItemsData { get; set; }
public void HandleSave(ClientPacket Packet)
{
var Unknown = Packet.PopInt();
var Unknown2 = Packet.PopString();
SetItems.Clear();
var FurniCount = Packet.PopInt();
for (var i = 0; i < FurniCount; i++)
{
var SelectedItem = Instance.GetRoomItemHandler().GetItem(Packet.PopInt());
if (SelectedItem != null && !Instance.GetWired().OtherBoxHasItem(this, SelectedItem.Id))
SetItems.TryAdd(SelectedItem.Id, SelectedItem);
}
var Delay = Packet.PopInt();
this.Delay = Delay;
}
public bool Execute(params object[] Params)
{
if (SetItems.Count == 0)
return false;
if (_next < 1 || _next < OreoServer.GetUnixTimestamp())
{
_next = OreoServer.GetUnixTimestamp() + Delay;
}
if (!Requested)
{
TickCount = Delay;
Requested = true;
}
return true;
}
}
OK I suck with wired so at some point today you'll have to show me how this is setup and I'll investigateThanks