private void InitializeWithSync(NPC npc) { if (this.AwaitsInitialization || this.IsInitialized || !ElementsNPC.CanHaveElements(npc)) { return; } this.AwaitsInitialization = true; LoadHooks.AddPostWorldLoadOnceHook(() => { this.IsInitialized = true; this.AwaitsInitialization = false; if (ElementsAPI.PreNPCInitialize(npc)) { if (this.AutoInitializeElement(npc)) { if (Main.netMode == 2) { NPCElementsProtocol.Broadcast(npc.whoAmI); } else { this.InitializeColorAnimation(); } } } }); }
private void Initialize(Item item) { if (this.AwaitsInitialization || this.IsInitialized || !ElementsItem.CanHaveElements(item)) { return; } this.AwaitsInitialization = true; LoadHooks.AddWorldLoadOnceHook(() => { this.AwaitsInitialization = false; this.IsInitialized = true; if (ElementsAPI.PreItemInitialize(item)) { this.AutoInitializeElement(item); } }); }