本文整理汇总了TypeScript中camelot-unchained.hasClientAPI函数的典型用法代码示例。如果您正苦于以下问题:TypeScript hasClientAPI函数的具体用法?TypeScript hasClientAPI怎么用?TypeScript hasClientAPI使用的例子?那么, 这里精选的函数代码示例或许可以为您提供帮助。
在下文中一共展示了hasClientAPI函数的8个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的TypeScript代码示例。
示例1: default
export default () => {
slashCommands();
if (!hasClientAPI()) return;
// hook up for console messages to system messages
client.OnConsoleText((text: string) => events.fire('system_message', text));
}
示例2: return
return (dispatch: (action: any) => any) => {
dispatch(init());
if (!hasClientAPI()) return;
// init handlers / events
events.on(events.clientEventTopics.handlesEnemyTarget, (player: Player) => dispatch(characterUpdate(player)));
};
示例3: return
return (dispatch: (action: any) => any) => {
dispatch(init());
if (!hasClientAPI()) return;
// init handlers / events
client.OnCharacterStaminaChanged((current: number, max: number) => dispatch(staminaChanged(current, max)));
client.OnCharacterHealthChanged((current: number, max: number) => dispatch(healthChanged(current, max, BodyParts.Torso)));
client.OnCharacterNameChanged((name: string) => dispatch(nameChanged(name)));
client.OnCharacterRaceChanged((race: race) => dispatch(raceChanged(race)));
client.OnCharacterFactionChanged((faction: faction) => dispatch(factionChanged(faction)));
events.on(events.clientEventTopics.handlesCharacter, (player: Player) => dispatch(characterUpdate(player)));
};
示例4: fakePlayer
}
export interface PlayerState {
playerStatus: PlayerStatus;
events: {
key: number,
value: string,
textType: string,
iconType: string,
timestamp: number,
}[];
}
const initialState = {
playerStatus: fakePlayer(),
events: hasClientAPI() ? [] : fakeEvents(),
}
function clone<T>(obj: T): T {
return Object.assign({}, obj);
}
let key = 3;
export default function reducer(state: PlayerState = initialState,
action: PlayerAction = {type: null}) : PlayerState {
switch(action.type) {
case INIT:
return Object.assign({}, state, {
});
示例5: default
export default () => {
if (!hasClientAPI()) return;
/**
* Set field of view
*/
registerSlashCommand('fov', 'set your field of view, client accepts values from 20 -> 179.9', (params: string) => {
const argv = parseArgs(params);
const degrees = argv._.length > 0 ? argv._[0] : 120;
client.FOV(degrees);
});
/**
* Drop a temporary light at the characters feet
*/
registerSlashCommand('droplight',
'drop a light at your location, options: (colors are 0-255) droplight <intensity> <radius> <red> <green> <blue>',
(params: string) => {
if (params.length == 0) return;
const argv = parseArgs(params);
if (argv._.length > 0) {
const intensity = argv._.length >= 0 ? argv._[0] : 1;
const radius = argv._.length > 1 ? argv._[1] : 20;
const red = argv._.length > 2 ? argv._[2] : 100;
const green = argv._.length > 3 ? argv._[3] : 100;
const blue = argv._.length > 4 ? argv._[4] : 100;
client.DropLight(intensity, radius, red, green, blue);
return;
}
const intensity = argv.intensity ? argv.intensity : 1;
const radius = argv.radius > 1 ? argv.radius : 20;
const red = argv.red > 2 ? argv.red : 100;
const green = argv.green > 3 ? argv.green : 100;
const blue = argv.blue > 4 ? argv.blue : 100;
client.DropLight(intensity, radius, red, green, blue);
});
/**
* Remove all lights placed with the drop light command
*/
registerSlashCommand('resetlights', 'removes all dropped lights from the world', (params: string) => {
client.ResetLights();
});
/**
* Count all the placed blocks in the world
*/
registerSlashCommand('countblocks', 'count all placed blocks in the world.', () => {
client.CountBlocks();
setTimeout(() => systemMessage(`There are ${client.placedBlockCount} blocks in this world.`), 1000);
});
/**
* Quit the game
*/
registerSlashCommand('exit', 'quit the game', () => client.Quit());
/**
* Build Var handling -- generally for dev use things only
*/
registerSlashCommand('var', 'Buildvar control: No params = help, var name only = get value, var name and value = set value', (params: string) => {
if (params.length == 0) {
client.SendSlashCommand('help');
} else {
client.SendSlashCommand(params);
}
});
registerSlashCommand('replacesubstance', 'replace blocks with type args[0] with blocks with type of args[1]', (params: string) => {
if (params.length == 0) return;
const argv = parseArgs(params);
if(argv._.length >= 2){
client.ReplaceSubstance(argv._[0], argv._[1]);
}
return;
});
registerSlashCommand('replaceshape', 'replace blocks with shape args[0] with blocks with shape of args[1]', (params: string) => {
if (params.length == 0) return;
const argv = parseArgs(params);
if(argv._.length >= 2){
client.ReplaceShapes(argv._[0], argv._[1]);
}
return;
});
registerSlashCommand('replaceselectedsubstance', 'replace blocks with type args[0] with blocks with type of args[1] within selected range', (params: string) => {
if (params.length == 0) return;
const argv = parseArgs(params);
if(argv._.length >= 2){
client.ReplaceSelectedSubstance(argv._[0], argv._[1]);
}
return;
});
registerSlashCommand('replaceselectedshape', 'replace blocks with shape args[0] to blocks with shape of args[1] within selected range', (params: string) => {
if (params.length == 0) return;
const argv = parseArgs(params);
if(argv._.length >= 2){
client.ReplaceSelectedShapes(argv._[0], argv._[1]);
}
return;
//.........这里部分代码省略.........
示例6: default
export default () => {
if (!hasClientAPI()) return;
/**
* Create a new Warband
*
* usage:
*
* 1. Create a temporary warband, this type of warband will go away after all members leave. This is the standard "Party".
* /createWarband
*
* 2. Create a permanent warband, this type of warband will live on until it is abandonded by all its members.
* /createWarband Friendship Warriors
*/
registerSlashCommand('createWarband', 'Create a Warband. Optionally, accepts a name if you wish to make this a permanent Warband.', (name: string = '') => {
webAPI.warbands.createWarband(client.shardID, client.characterID, false, name)
.then((response: any) => {
if (!response.ok) {
// something went wrong
console.error(response);
return;
}
// success
});
});
/**
* Invite a player to your warband you are invite
*
* usage: /invite mehuge
*/
let friendlyTargetName: string = '';
client.OnFriendlyTargetNameChanged((name: string) => {
friendlyTargetName = name;
});
registerSlashCommand('invite', 'Invite a player to your warband. Will use either your current friendly target, or a character name if you provide one.',
(name: string = '') => {
if (name.length > 0) {
webAPI.warbands.inviteCharacterToWarbandByName(client.shardID, client.characterID, name)
.then((response: any) => {
if (!response.ok) {
// something went wrong
console.error(response);
return;
}
// success
});
} else if (friendlyTargetName && friendlyTargetName !== '') {
webAPI.warbands.inviteCharacterToWarbandByName(client.shardID, client.characterID, friendlyTargetName)
.then((response: any) => {
if (!response.ok) {
// something went wrong
console.error(response);
return;
}
// success
});
} else {
systemMessage('No friendly target to invite. Provide a name or select a friendly target and try again.');
}
});
registerSlashCommand('joinWarband', 'Join an existing Warband.', (args: string) => {
let argv = yargs(args);
if (argv._.length === 1) {
// name only
webAPI.warbands.joinWarbandByName(client.shardID, argv._[0], client.characterID)
.then((response: any) => {
if (!response.ok) {
// something went wrong
console.error(response);
return;
}
// success
});
} else if (argv._.length === 2) {
// name and invite code
webAPI.warbands.joinWarbandByName(client.shardID, argv._[0], client.characterID, argv._[1])
.then((response: any) => {
if (!response.ok) {
// something went wrong
console.error(response);
return;
}
// success
});
} else {
//.........这里部分代码省略.........
示例7: initialState
function initialState() {
return {
playerStatus: fakePlayer(),
events: hasClientAPI() ? [] : fakeHealthEvents(),
};
}
示例8: default
export default () => {
slashCommands();
signalr.initializeSignalR();
if (!hasClientAPI()) return;
// hook up for console messages to system messages
client.OnConsoleText((text: string) => events.fire('system_message', text));
client.OnToggleHUDItem((name: string) => {
console.log(name);
events.fire('hudnav--navigate', name);
});
function combatLogToString(log: CombatLog): string {
// fromName (fromFaction) > toName
// (toFaction) | {damages} | {disruption} | {heals} | {cures} | {resources} | {impulse} | {activeEffects}
//
// {damages} (RED) => recieved (sent - recieved) part type [100(20) RIGHTLEG SLASHING]
// {disruption} (ORANGE) => recieved (sent - receieved) tracks [100(20) PRIMARYWEAPON]
// {resources} (YELLOW) => recieved (sent - recieved) type
// {heals} (GREEN) => recieved (sent - recieved) part
// {cures} (BLUE) => HEAD(2) TORSO
// {impulse} (INDIGO) => recieved (sent - recieved) IMPULSE
// {activeEffects} (VIOLET) => activeEffects[0] activeEffects[1] ...
let output = `${log.fromName}(${Faction[log.fromFaction]}) > ${log.toName}(${Faction[log.toFaction]}) | `;
if (log.damages) {
for (let i = 0; i < log.damages.length; ++i) {
const d = log.damages[i];
output += `::red::${d.recieved.toFixed(0)}(${Math.abs(d.sent - d.recieved).toFixed(0)}) ${bodyParts[d.part]}
${damageTypes[d.type]} | `;
}
}
if (log.disruption) {
output += `::orange::${log.disruption.recieved.toFixed(0)}(${Math.abs(log.disruption.sent - log.disruption.recieved)
.toFixed(0)}) DISRUPTION ${log.disruption.source} `;
if (log.disruption.tracksInterupted === skillTracks.NONE) {
output += ` | `;
} else {
if (log.disruption.tracksInterupted & skillTracks.BOTHWEAPONS) {
output += ` ${skillTracks[skillTracks.BOTHWEAPONS]}`;
} else if (log.disruption.tracksInterupted & skillTracks.PRIMARYWEAPON) {
output += ` ${skillTracks[skillTracks.PRIMARYWEAPON]} `;
} else if (log.disruption.tracksInterupted & skillTracks.SECONDARYWEAPON) {
output += ` ${skillTracks[skillTracks.SECONDARYWEAPON]} `;
}
if (log.disruption.tracksInterupted & skillTracks.VOICE) {
output += ` ${skillTracks[skillTracks.VOICE]} `;
}
if (log.disruption.tracksInterupted & skillTracks.MIND) {
output += ` ${skillTracks[skillTracks.MIND]} `;
}
output += ` INTERRUPTED | `;
}
}
if (log.heals) {
for (let i = 0; i < log.heals.length; ++i) {
const h = log.heals[i];
output += `::green::HEALED ${h.recieved.toFixed(0)}(${Math.abs(h.sent - h.recieved).toFixed(0)})
${bodyParts[h.part]} | `;
}
}
if (log.cures) {
output += `::blue::CURED `;
const curedParts = [0,0,0,0,0,0];
for (let i = 0; i < log.cures.length; ++i) {
curedParts[log.cures[i]] += 1;
}
for (let i = 0; i < curedParts.length; ++i) {
if (curedParts[i] > 0) {
output += ` ${bodyParts[i]}(${curedParts[i]}) `;
}
}
output += '| ';
}
if (log.resources) {
for (let i = 0; i < log.resources.length; ++i) {
const d = log.resources[i];
output += `::yellow::${d.recieved.toFixed(0)}(${Math.abs(d.sent - d.recieved).toFixed(0)})
${resourceTypes[d.type]} | `;
}
}
if (log.impulse) {
output += `::indigo::${log.impulse.recieved.toFixed(0)}(${Math.abs(log.impulse.sent - log.impulse.recieved)
//.........这里部分代码省略.........