mirror of
https://github.com/duckietm/Nitro-V3.git
synced 2026-06-19 23:16:21 +00:00
🆕 Updated Chooser & Furni command - now glowing !
This commit is contained in:
@@ -0,0 +1,100 @@
|
||||
import { ChooserSelectionFilter, GetRoomEngine, IRoomObjectSpriteVisualization, RoomObjectCategory } from '@nitrots/nitro-renderer';
|
||||
|
||||
export class chooserSelectionVisualizer
|
||||
{
|
||||
private static activeFilters: Map<string, ChooserSelectionFilter> = new Map();
|
||||
private static animationFrameId: number | null = null;
|
||||
|
||||
private static startAnimation(): void
|
||||
{
|
||||
if (this.animationFrameId !== null) return;
|
||||
|
||||
const animate = (time: number) => {
|
||||
const elapsed = time / 1000; // Convert to seconds
|
||||
this.activeFilters.forEach(filter => {
|
||||
filter.time = elapsed; // Update time uniform
|
||||
});
|
||||
this.animationFrameId = requestAnimationFrame(animate);
|
||||
};
|
||||
|
||||
this.animationFrameId = requestAnimationFrame(animate);
|
||||
}
|
||||
|
||||
private static stopAnimation(): void
|
||||
{
|
||||
if (this.animationFrameId !== null) {
|
||||
cancelAnimationFrame(this.animationFrameId);
|
||||
this.animationFrameId = null;
|
||||
}
|
||||
}
|
||||
|
||||
public static show(id: number, category: number = RoomObjectCategory.FLOOR): void
|
||||
{
|
||||
const roomObject = GetRoomEngine().getRoomObject(GetRoomEngine().activeRoomId, id, category);
|
||||
if (!roomObject) return;
|
||||
|
||||
const visualization = roomObject.visualization as IRoomObjectSpriteVisualization;
|
||||
if (!visualization || !visualization.sprites || !visualization.sprites.length) return;
|
||||
|
||||
const filter = new ChooserSelectionFilter(
|
||||
[0.700, 0.880, 0.950],
|
||||
[0.290, 0.350, 0.390]
|
||||
);
|
||||
const key = `${id}_${category}`;
|
||||
this.activeFilters.set(key, filter);
|
||||
|
||||
for (const sprite of visualization.sprites)
|
||||
{
|
||||
if (sprite.blendMode === 1) continue;
|
||||
const existing = (sprite.filters || []).filter(f => !(f instanceof ChooserSelectionFilter));
|
||||
sprite.filters = [...existing, filter];
|
||||
}
|
||||
|
||||
this.startAnimation();
|
||||
}
|
||||
|
||||
public static hide(id: number, category: number = RoomObjectCategory.FLOOR): void
|
||||
{
|
||||
const roomObject = GetRoomEngine().getRoomObject(GetRoomEngine().activeRoomId, id, category);
|
||||
if (!roomObject) return;
|
||||
|
||||
const visualization = roomObject.visualization as IRoomObjectSpriteVisualization;
|
||||
if (!visualization) return;
|
||||
|
||||
const key = `${id}_${category}`;
|
||||
this.activeFilters.delete(key);
|
||||
|
||||
for (const sprite of visualization.sprites)
|
||||
{
|
||||
sprite.filters = (sprite.filters || []).filter(f => !(f instanceof ChooserSelectionFilter));
|
||||
}
|
||||
|
||||
if (this.activeFilters.size === 0) {
|
||||
this.stopAnimation();
|
||||
}
|
||||
}
|
||||
|
||||
public static clearAll(): void
|
||||
{
|
||||
const roomEngine = GetRoomEngine();
|
||||
|
||||
const roomObjects = [
|
||||
...roomEngine.getRoomObjects(roomEngine.activeRoomId, RoomObjectCategory.FLOOR),
|
||||
...roomEngine.getRoomObjects(roomEngine.activeRoomId, RoomObjectCategory.WALL)
|
||||
];
|
||||
|
||||
for (const roomObject of roomObjects)
|
||||
{
|
||||
const visualization = roomObject.visualization as IRoomObjectSpriteVisualization;
|
||||
if (!visualization) continue;
|
||||
|
||||
for (const sprite of visualization.sprites)
|
||||
{
|
||||
sprite.filters = (sprite.filters || []).filter(f => !(f instanceof ChooserSelectionFilter));
|
||||
}
|
||||
}
|
||||
|
||||
this.activeFilters.clear();
|
||||
this.stopAnimation();
|
||||
}
|
||||
}
|
||||
@@ -3,12 +3,18 @@ export class RoomObjectItem
|
||||
private _id: number;
|
||||
private _category: number;
|
||||
private _name: string;
|
||||
private _ownerId: number;
|
||||
private _ownerName: string;
|
||||
private _type?: string;
|
||||
|
||||
constructor(id: number, category: number, name: string)
|
||||
constructor(id: number, category: number, name: string, ownerId: number = 0, ownerName: string = '#', type?: string)
|
||||
{
|
||||
this._id = id;
|
||||
this._category = category;
|
||||
this._name = name;
|
||||
this._ownerId = ownerId;
|
||||
this._ownerName = ownerName;
|
||||
this._type = type;
|
||||
}
|
||||
|
||||
public get id(): number
|
||||
@@ -25,4 +31,19 @@ export class RoomObjectItem
|
||||
{
|
||||
return this._name;
|
||||
}
|
||||
|
||||
public get ownerId(): number
|
||||
{
|
||||
return this._ownerId;
|
||||
}
|
||||
|
||||
public get ownerName(): string
|
||||
{
|
||||
return this._ownerName ?? '#';
|
||||
}
|
||||
|
||||
public get type(): string
|
||||
{
|
||||
return this._type ?? '-';
|
||||
}
|
||||
}
|
||||
|
||||
@@ -1,4 +1,5 @@
|
||||
export * from './AvatarInfoFurni';
|
||||
export * from './ChooserSelectionVisualizer';
|
||||
export * from './AvatarInfoName';
|
||||
export * from './AvatarInfoPet';
|
||||
export * from './AvatarInfoRentableBot';
|
||||
|
||||
Reference in New Issue
Block a user