本文整理汇总了C++中object::ContentsCount方法的典型用法代码示例。如果您正苦于以下问题:C++ object::ContentsCount方法的具体用法?C++ object::ContentsCount怎么用?C++ object::ContentsCount使用的例子?那么, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类object
的用法示例。
在下文中一共展示了object::ContentsCount方法的2个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的C++代码示例。
示例1: AddCyclopsAI
global func AddCyclopsAI(object clonk) // somewhat hacky, but it works
{
var effect_name = "IntCyclopsAI";
var fx = GetEffect(effect_name, clonk);
if (!fx) fx = AddEffect(effect_name, clonk, 1, 2);
if (!fx || !clonk) return nil;
clonk.ai = fx;
// bin inventory
var cnt = clonk->ContentsCount();
fx.bound_weapons = CreateArray(cnt);
for (var i=0; i<cnt; ++i) fx.bound_weapons[i] = clonk->Contents(i);
// set home
fx.home_x = clonk->GetX();
fx.home_y = clonk->GetY();
fx.home_dir = DIR_Left;
// set guard range
fx.guard_range = {
x = fx.home_x-AI_DefGuardRangeX,
y = fx.home_y-AI_DefGuardRangeY,
wdt = AI_DefGuardRangeX*2,
hgt = AI_DefGuardRangeY*2};
fx.spray_old = {time = 0, v0 = 0, v1 = 0, reach = 0};
fx.spray_cur = {time = 0, v0 = 0, v1 = 0, reach = 0};
AI->SetMaxAggroDistance(clonk, AI_DefMaxAggroDistance);
return fx;
}
示例2: BindInventory
// Set the current inventory to be removed when the clonk dies. Only works if clonk has an AI.
func BindInventory(object clonk)
{
var fx = GetEffect("S2AI", clonk);
if (!fx || !clonk) return false;
var cnt = clonk->ContentsCount();
fx.bound_weapons = CreateArray(cnt);
for (var i=0; i<cnt; ++i) fx.bound_weapons[i] = clonk->Contents(i);
clonk->Call(fx.ai.UpdateDebugDisplay, fx);
return true;
}