本文整理汇总了C#中Terraria.Item.RealSetDefaults方法的典型用法代码示例。如果您正苦于以下问题:C# Item.RealSetDefaults方法的具体用法?C# Item.RealSetDefaults怎么用?C# Item.RealSetDefaults使用的例子?那么恭喜您, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类Terraria.Item
的用法示例。
在下文中一共展示了Item.RealSetDefaults方法的3个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的C#代码示例。
示例1: CreateItem
public static Item CreateItem(string itemName, int stack = 0)
{
Item item = new Item();
item.RealSetDefaults(itemName);
if (stack > 0) item.stack = stack;
return item;
}
示例2: OnSetDefaults
internal static void OnSetDefaults(Item item, int type, bool noMatCheck)
{
Dictionary<string, BinBuffer> data = null;
if (item.P_BHandler != null)
data = ((ItemBHandler)item.P_BHandler).data;
item.P_BHandler = null;
item.P_UseSound = null;
if (ModLoader.Reloading && !RecipeDefHandler.SettingUpRecipes)
{
item.RealSetDefaults(type, noMatCheck);
if (!FillingVanilla)
Logging.LogWarning("Tried to call SetDefaults on an Item while [re|un]?loading mods.");
return;
}
ItemBHandler h = null; // will be set to <non-null> only if a behaviour handler will be attached
item.RealSetDefaults(0, noMatCheck);
if (Handler.ItemDef.DefsByType.ContainsKey(type))
{
var d = Handler.ItemDef.DefsByType[type];
item.type = item.netID = type;
item.width = item.height = 16;
item.stack = item.maxStack = 1;
Handler.ItemDef.CopyDefToEntity(d, item);
if (RecipeDefHandler.SettingUpRecipes)
return;
if (d.CreateBehaviour != null)
{
h = new ItemBHandler();
var b = d.CreateBehaviour();
if (b != null)
{
b.Mod = d.Mod == PrismApi.VanillaInfo ? null : ModData.mods[d.Mod];
h.behaviours.Add(b);
}
}
}
else
item.RealSetDefaults(type, noMatCheck);
if (RecipeDefHandler.SettingUpRecipes)
return;
var bs = ModData.mods.Values
.Select(m => new KeyValuePair<ModDef, ItemBehaviour>(m, m.ContentHandler.CreateGlobalItemBInternally()))
.Where(kvp => kvp.Value != null)
.Select(kvp =>
{
kvp.Value.Mod = kvp.Key;
return kvp.Value;
});
if (!bs.IsEmpty() && h == null)
h = new ItemBHandler();
if (h != null)
{
h.behaviours.AddRange(bs);
if (data != null)
h.data = data;
h.Create();
item.P_BHandler = h;
foreach (var b in h.Behaviours)
b.Entity = item;
h.OnInit();
}
}
示例3: AddItem
private void AddItem(string name)
{
Item item = new Item();
item.RealSetDefaults(name);
AddItem(item);
}