コード例 #1
0
 public void Run(object[] args)
 {
     foreach (var npcTable in _cache.NPCEnmityTables.ToArray())
     {
         if (!npcTable.Value.NPCObject.IsValid)
         {
             _cache.NPCEnmityTables.Remove(npcTable.Key);
         }
     }
     for (int x = _cache.NPCBehaviours.Count - 1; x >= 0; x--)
     {
         var npcBehaviour = _cache.NPCBehaviours.ElementAt(x);
         if (!npcBehaviour.Value.IsValid)
         {
             _cache.NPCBehaviours.Remove(npcBehaviour.Key);
             _ops.UnregisterProcessingEvent(npcBehaviour.Key);
         }
     }
     foreach (var customData in _cache.CustomObjectData.ToArray())
     {
         NWObject owner = customData.Value.Owner;
         if (!owner.IsValid)
         {
             _cache.CustomObjectData.Remove(customData.Key);
         }
     }
 }
コード例 #2
0
        public void OnModuleLoad()
        {
            _ops.RegisterProcessingEvent(() =>
            {
                foreach (var npcTable in _state.NPCEnmityTables.ToArray())
                {
                    if (!npcTable.Value.NPCObject.IsValid)
                    {
                        _state.NPCEnmityTables.Remove(npcTable.Key);
                    }
                }
                for (int x = _state.NPCBehaviours.Count - 1; x >= 0; x--)
                {
                    var npcBehaviour = _state.NPCBehaviours.ElementAt(x);
                    if (!npcBehaviour.Value.IsValid)
                    {
                        _state.NPCBehaviours.Remove(npcBehaviour.Key);
                        _ops.UnregisterProcessingEvent(npcBehaviour.Key);
                    }
                }
                foreach (var customData in _state.CustomObjectData.ToArray())
                {
                    NWObject owner = customData.Value.Owner;
                    if (!owner.IsValid)
                    {
                        _state.CustomObjectData.Remove(customData.Key);
                    }
                }

                //int count = NWModule.Get().GetLocalInt("current_count") + 1;
                //if (count >= 20)
                //{
                //    Console.WriteLine("******************");

                //    Console.WriteLine("PlayerDialogs: " + _state.PlayerDialogs.Count);
                //    Console.WriteLine("DialogFilesInUse: " + _state.DialogFilesInUse.Count);
                //    Console.WriteLine("EffectTicks: " + _state.EffectTicks.Count);
                //    Console.WriteLine("CreatureSkillRegistrations: " + _state.CreatureSkillRegistrations.Count);
                //    Console.WriteLine("NPCEffects: " + _state.NPCEffects.Count);
                //    Console.WriteLine("EffectsToRemove: " + _state.EffectsToRemove.Count);
                //    Console.WriteLine("ProcessingEvents: " + _state.ProcessingEvents.Count);
                //    Console.WriteLine("UnregisterProcessingEvents: " + _state.UnregisterProcessingEvents.Count);
                //    Console.WriteLine("NPCEnmityTables: " + _state.NPCEnmityTables.Count);
                //    Console.WriteLine("CustomObjectData: " + _state.CustomObjectData.Count);
                //    Console.WriteLine("NPCBehaviours: " + _state.NPCBehaviours.Count);

                //    Console.WriteLine("******************");
                //    count = 0;
                //}
                //NWModule.Get().SetLocalInt("current_count", count);
            });
        }
コード例 #3
0
 public void UnregisterBehaviour(string behaviourID)
 {
     _objProc.UnregisterProcessingEvent(behaviourID);
 }