movement sit/stand
This commit is contained in:
committed by
Casper Warden
parent
971e57a097
commit
050841b8f9
@@ -422,4 +422,14 @@ export class Agent
|
||||
this.appearanceComplete = true;
|
||||
this.appearanceCompleteEvent.next();
|
||||
}
|
||||
|
||||
setControlFlag(flag: ControlFlags): void
|
||||
{
|
||||
this.controlFlags = this.controlFlags | flag;
|
||||
}
|
||||
|
||||
clearControlFlag(flag: ControlFlags): void
|
||||
{
|
||||
this.controlFlags = this.controlFlags & ~flag;
|
||||
}
|
||||
}
|
||||
|
||||
@@ -12,6 +12,7 @@ import { GroupCommands } from './commands/GroupCommands';
|
||||
import { InventoryCommands } from './commands/InventoryCommands';
|
||||
import { ParcelCommands } from './commands/ParcelCommands';
|
||||
import { FriendCommands } from './commands/FriendCommands';
|
||||
import { MovementCommands } from './commands/MovementCommands';
|
||||
|
||||
export class ClientCommands
|
||||
{
|
||||
@@ -26,6 +27,7 @@ export class ClientCommands
|
||||
public agent: AgentCommands;
|
||||
public group: GroupCommands;
|
||||
public inventory: InventoryCommands;
|
||||
public movement: MovementCommands;
|
||||
|
||||
constructor(region: Region, agent: Agent, bot: Bot)
|
||||
{
|
||||
@@ -40,6 +42,7 @@ export class ClientCommands
|
||||
this.agent = new AgentCommands(region, agent, bot);
|
||||
this.group = new GroupCommands(region, agent, bot);
|
||||
this.inventory = new InventoryCommands(region, agent, bot);
|
||||
this.movement = new MovementCommands(region, agent, bot);
|
||||
}
|
||||
|
||||
shutdown(): void
|
||||
|
||||
56
lib/classes/commands/MovementCommands.ts
Normal file
56
lib/classes/commands/MovementCommands.ts
Normal file
@@ -0,0 +1,56 @@
|
||||
import { ControlFlags, PacketFlags } from "../..";
|
||||
import { AgentRequestSitMessage, AgentSitMessage } from "../MessageClasses";
|
||||
import { UUID } from "../UUID";
|
||||
import { Vector3 } from "../Vector3";
|
||||
import { CommandsBase } from "./CommandsBase";
|
||||
|
||||
export class MovementCommands extends CommandsBase {
|
||||
|
||||
async sitOnObject(targetID: UUID, offset: Vector3): Promise<void>
|
||||
{
|
||||
await this.requestSitOnObject(targetID, offset);
|
||||
await this.sitOn();
|
||||
}
|
||||
|
||||
sitOnGround(): void
|
||||
{
|
||||
this.agent.setControlFlag(ControlFlags.AGENT_CONTROL_SIT_ON_GROUND);
|
||||
this.agent.sendAgentUpdate();
|
||||
}
|
||||
|
||||
stand(): void
|
||||
{
|
||||
this.agent.clearControlFlag(ControlFlags.AGENT_CONTROL_SIT_ON_GROUND);
|
||||
this.agent.setControlFlag(ControlFlags.AGENT_CONTROL_STAND_UP);
|
||||
this.agent.sendAgentUpdate();
|
||||
this.agent.clearControlFlag(ControlFlags.AGENT_CONTROL_STAND_UP);
|
||||
this.agent.sendAgentUpdate();
|
||||
}
|
||||
|
||||
private async requestSitOnObject(targetID: UUID, offset: Vector3): Promise<void>
|
||||
{
|
||||
const msg = new AgentRequestSitMessage();
|
||||
msg.AgentData = {
|
||||
AgentID: this.agent.agentID,
|
||||
SessionID: this.circuit.sessionID,
|
||||
};
|
||||
msg.TargetObject = {
|
||||
TargetID: targetID,
|
||||
Offset: offset,
|
||||
};
|
||||
|
||||
const seqID = this.circuit.sendMessage(msg, PacketFlags.Reliable);
|
||||
return this.circuit.waitForAck(seqID, 10000);
|
||||
}
|
||||
|
||||
private async sitOn(): Promise<void>
|
||||
{
|
||||
const msg = new AgentSitMessage();
|
||||
msg.AgentData = {
|
||||
AgentID: this.agent.agentID,
|
||||
SessionID: this.circuit.sessionID,
|
||||
};
|
||||
const seqID = this.circuit.sendMessage(msg, PacketFlags.Reliable);
|
||||
return this.circuit.waitForAck(seqID, 10000);
|
||||
}
|
||||
}
|
||||
Reference in New Issue
Block a user