/// <inheritdoc /> public bool Destroy(PlayerEntityDestructionContext obj) { bool result = EntityDestructor.Destroy(obj.EntityGuid); if (result) { //To avoid major issues with previous physics based issue we're writing this horriblely slow, hacky solution\ //This actually scales O(n) which isn't bad. A quick iteration and a hashmap check basically. foreach (var ic in InterestCollections) { if (ic.Value.Contains(obj.EntityGuid)) { //We just spoof an exit to every interested collection who knows of the entity being cleaned up. InterestEventSpoofer.SpoofExitInterest(new EntityInterestChangeEventArgs(ic.Key, obj.EntityGuid, EntityInterestChangeEventArgs.ChangeType.Exit)); } } } return(result); }
/// <inheritdoc /> protected override void HandleEvent(NetworkEntityVisibilityLostEventArgs args) { //If we don't know it, we likely encountered the rare edge case that is the result //of some hacks that were added to keep the wheels from falling off. //These will eventually be fixed, but for now we should just skip ones we don't know //because we can't remove what we don't know. if (!KnownEntites.ContainsKey(args.EntityGuid)) { if (Logger.IsErrorEnabled) { Logger.Error($"Encountered {nameof(NetworkEntityVisibilityLostEventArgs)} with Guid: {args.EntityGuid.EntityType}:{args.EntityGuid.EntityId} who is not a KNOWN entity. This should never happen."); } return; } else if (Logger.IsInfoEnabled) { Logger.Info($"About to cleanup Entity: {args.EntityGuid.EntityType}:{args.EntityGuid.EntityId}"); } //TODO: This is a semi-slow process, can any of this be offloaded to the other thread? EntityDestructor.Destroy(args.EntityGuid); }