/// <summary> /// Special entity subscription ///<para/> /// Special subscription that also give the subscriber "ghost" entities, that is, entities /// with no current owner. /// </summary> /// <param name="typeId">Type id of the entity to subscribe for.</param> /// <param name="includeUpdates">True => Subscription includes update, as well as create and delete. /// False => Subscription includes no updates, only create and deletion.</param> /// <param name="includeSubclasses">True => Subscription for this entity type and all its subclasses. /// False => No subclasses will be included.</param> /// <param name="restartSubscription">True => OnNewEntity callbacks are generated even if the subscription already exists. /// False => OnNewEntity callbacks are generated only for instances that are not previously subscribed.</param> /// <param name="wantsGhostDelete">True => Wants notification that an "inject new" or InitialSet was immediately deleted by owner. /// False => Normal subscription, only get deletes when an OnNew has been called.</param> /// <param name="wantsLastState">True => Guarantee OnUpdated/OnNew even if application dies immediately after set. /// False => Normal subscription, call OnDeleted only in this case.</param> /// <param name="doesntWantSourceIsPermanentStore">True => Doesnt want OnNew if only accept of an accept of an InitialSet. /// False => Normal Subscription. Gets OnNew for all states. /// (This flag is only applicable for AsynchronousPermanent types)</param> /// <param name="wantsAllStateChanges">True => Wants OnDoDispatch called for *all* state changes, even if they do not /// result in a callback. ONLY MEANT FOR DOSE_MAIN! /// False => Normal Subscription.</param> /// <param name="timestampChangeInfo">True => ChangeInfo is based on timestamps instead of contents /// False => ChangeInfo is based on object contents, as with normal subscribe.</param> /// <param name="entitySubscriber">EntitySubscriber that will receive the entities.</param> public void SubscribeEntity(System.Int64 typeId, bool includeUpdates, bool includeSubclasses, bool restartSubscription, bool wantsGhostDelete, bool wantsLastState, bool doesntWantSourceIsPermanentStore, bool wantsAllStateChanges, bool timestampChangeInfo, EntitySubscriber entitySubscriber) { byte success; Interface.DoseC_InjectorSubscribeEntity(ControllerId, typeId, Interface.ByteOf(includeUpdates), Interface.ByteOf(includeSubclasses), Interface.ByteOf(restartSubscription), Interface.ByteOf(wantsGhostDelete), Interface.ByteOf(wantsLastState), Interface.ByteOf(doesntWantSourceIsPermanentStore), Interface.ByteOf(wantsAllStateChanges), Interface.ByteOf(timestampChangeInfo), Interface.DOSE_LANGUAGE_DOTNET, ConsumerHandler.Instance.AddReference(entitySubscriber), out success); if (!Interface.BoolOf(success)) { ConsumerHandler.Instance.DropReference(entitySubscriber); Typesystem.LibraryExceptions.Instance.Throw(); } }
private void subscribeEntity(IEntity entity) { if (entity == null) { return; } EntitySubscriber subscriber = new EntitySubscriber(entity, onLayerChanged); _entitySubscribers[entity.ID] = subscriber; }