Keeps the repo root clean - only README.md visible on landing page. Co-Authored-By: Claude Opus 4.6 (1M context) <noreply@anthropic.com>
56 lines
1.3 KiB
C#
56 lines
1.3 KiB
C#
var furnitures = new Dictionary<int, (int x, int y)> {
|
|
{ 880616572, (25, 13) },
|
|
{ 880617415, (13, 13) },
|
|
{ 880617090, (13, 29) },
|
|
{ 880617208, (25, 29) }
|
|
};
|
|
|
|
var lastusedid = -1;
|
|
var nearfurni = false;
|
|
|
|
Log("Furniture proximity trigger started");
|
|
Log($"Monitoring {furnitures.Count} furniture items");
|
|
|
|
bool isnearfurniture(int x, int y, out int furniid) {
|
|
foreach (var furni in furnitures) {
|
|
var dx = Math.Abs(x - furni.Value.x);
|
|
var dy = Math.Abs(y - furni.Value.y);
|
|
|
|
if (dx <= 1 && dy <= 1) {
|
|
furniid = furni.Key;
|
|
return true;
|
|
}
|
|
}
|
|
furniid = -1;
|
|
return false;
|
|
}
|
|
|
|
while (Run) {
|
|
if (Self == null || Self.Location == null) {
|
|
Delay(100);
|
|
continue;
|
|
}
|
|
|
|
var x = Self.Location.X;
|
|
var y = Self.Location.Y;
|
|
|
|
if (isnearfurniture(x, y, out int furniid)) {
|
|
if (!nearfurni || furniid != lastusedid) {
|
|
Send(Out["UseFurniture"], furniid, 0);
|
|
Log($"Used furniture {furniid} from position ({x},{y})");
|
|
lastusedid = furniid;
|
|
nearfurni = true;
|
|
}
|
|
}
|
|
else {
|
|
if (nearfurni) {
|
|
Log("Left furniture area");
|
|
nearfurni = false;
|
|
lastusedid = -1;
|
|
}
|
|
}
|
|
|
|
Delay(100);
|
|
}
|
|
|
|
Log("Proximity trigger stopped"); |