本文整理匯總了C#中Terraria.NPC.RealSetDefaults方法的典型用法代碼示例。如果您正苦於以下問題:C# NPC.RealSetDefaults方法的具體用法?C# NPC.RealSetDefaults怎麽用?C# NPC.RealSetDefaults使用的例子?那麽, 這裏精選的方法代碼示例或許可以為您提供幫助。您也可以進一步了解該方法所在類Terraria.NPC
的用法示例。
在下文中一共展示了NPC.RealSetDefaults方法的3個代碼示例,這些例子默認根據受歡迎程度排序。您可以為喜歡或者感覺有用的代碼點讚,您的評價將有助於係統推薦出更棒的C#代碼示例。
示例1: FillVanilla
/// <summary>
/// Adds all the original vanilla items.
/// </summary>
internal static void FillVanilla()
{
for (int i = -65; i < NPCID.Count; i++)
{
if (i == 0)
continue;
NPC n = new NPC();
n.RealSetDefaults(i);
NpcDef def = new NpcDef(Lang.npcName(n.type, true));
def.InternalName = n.name;
def.Type = n.type;
def.NetID = i;
CopyNpcToDef(def, n);
DefFromType.Add(i, def);
VanillaDefFromName.Add(n.name, def);
}
}
示例2: OnSetDefaults
internal static void OnSetDefaults(NPC n, int type, float scaleOverride)
{
n.P_BHandler = null;
n.P_BuffBHandler = new object[NPC.maxBuffs];
n.P_Music = null;
n.P_SoundOnHit = null;
n.P_SoundOnDeath = null;
if (ModLoader.Reloading)
{
n.RealSetDefaults(type);
if (!FillingVanilla)
Logging.LogWarning("Tried to call SetDefaults on an NPC while [re|un]?loading mods.");
return;
}
NpcBHandler h = null; // will be set to <non-null> only if a behaviour handler will be attached
if (type < NPCID.Count && !ModLoader.Reloading && !FillingVanilla && type != 0 && Handler.NpcDef.DefsByType.Count > 0)
n.RealSetDefaults(type < 0 ? Handler.NpcDef.DefsByType[type].Type : type, scaleOverride);
else
n.RealSetDefaults(0, scaleOverride);
if (Handler.NpcDef.DefsByType.ContainsKey(type))
{
var d = Handler.NpcDef.DefsByType[type];
n.type = n.netID = type;
n.width = n.height = 16;
Handler.NpcDef.CopyDefToEntity(d, n);
if (Main.expertMode)
n.scaleStats();
n.life = n.lifeMax; //! BEEP BOOP
n.defDamage = n.damage;
n.defDefense = n.defense;
if (scaleOverride > -1f)
n.scale = scaleOverride;
if (d.CreateBehaviour != null)
{
var b = d.CreateBehaviour();
if (b != null)
{
h = new NpcBHandler();
b.Mod = d.Mod == PrismApi.VanillaInfo ? null : ModData.mods[d.Mod];
h.behaviours.Add(b);
}
}
}
else
n.RealSetDefaults(type, scaleOverride);
var bs = ModLoader.Reloading ? Empty<NpcBehaviour>.Array : ModData.mods.Values
.Select(m => new KeyValuePair<ModDef, NpcBehaviour>(m, m.ContentHandler.CreateGlobalNpcBInternally()))
.Where(kvp => kvp.Value != null)
.Select(kvp =>
{
kvp.Value.Mod = kvp.Key;
return kvp.Value;
});
if (!bs.IsEmpty() && h == null)
h = new NpcBHandler();
if (h != null)
{
h.behaviours.AddRange(bs);
h.Create();
n.P_BHandler = h;
foreach (var b in h.Behaviours)
b.Entity = n;
//h.OnInit();
}
}
示例3: OnSetDefaults
internal static void OnSetDefaults(NPC n, int type, float scaleOverride)
{
NpcBHandler h = null;
if (type >= NPCID.Count)
{
n.RealSetDefaults(0, scaleOverride);
if (DefFromType.ContainsKey(type))
{
var d = DefFromType[type];
n.type = n.netID = type;
n.width = n.height = 16;
CopyDefToNpc(n, d);
if (scaleOverride > -1f)
n.scale = scaleOverride;
h = new NpcBHandler();
if (d.CreateBehaviour != null)
{
var b = d.CreateBehaviour();
if (b != null)
h.behaviours.Add(b);
}
n.BHandler = h;
}
}
else
n.RealSetDefaults(type, scaleOverride);
//TODO: add global hooks here (and check for null)
if (h != null)
{
h.Create();
n.BHandler = h;
foreach (var b in h.Behaviours)
b.Entity = n;
h.OnInit();
}
}