Example #1
0
        private void LootContainer_ItemsRemoved(object sender, PropStoreEventArgs e)
        {
            var container = (IPropContainer)sender;

            if (!container.Content.CalcActualItems().Any())
            {
                var staticObject =
                    StaticObjectManager.Items.Single(x =>
                                                     ReferenceEquals(x.GetModuleSafe <IPropContainer>(), container));
                StaticObjectManager.Remove(staticObject);
            }
        }
Example #2
0
        private void LootContainer_ItemsRemoved(object?sender, PropStoreEventArgs e)
        {
            if (sender is null)
            {
                throw new InvalidOperationException("The handler can work only for instance. Sender can't be null.");
            }

            var container = (IPropContainer)sender;

            if (!container.Content.CalcActualItems().Any())
            {
                var staticObject =
                    StaticObjectManager.Items.Single(x =>
                                                     ReferenceEquals(x.GetModuleSafe <IPropContainer>(), container));
                StaticObjectManager.Remove(staticObject);
            }
        }