Beispiel #1
0
        /// <summary>
        ///     Remove an entity from being controlled by this peer.
        /// </summary>
        public void RevokeControlInternal(RailEntityBase entity)
        {
            RailDebug.Assert(entity.Controller == this);

            controlledEntities.Remove(entity);
            entity.AssignController(null);
        }
Beispiel #2
0
        /// <summary>
        ///     Adds an entity to be controlled by this peer.
        /// </summary>
        public void GrantControlInternal(RailEntityBase entity)
        {
            if (entity.Controller == this)
            {
                return;
            }
            RailDebug.Assert(entity.Controller == null);

            controlledEntities.Add(entity);
            entity.AssignController(this);
        }
Beispiel #3
0
        protected void RemoveEntity(RailEntityBase entity)
        {
            if (entities.ContainsKey(entity.Id))
            {
                entities.Remove(entity.Id);
                entity.RoomBase = null;
                entity.Removed();
                // TODO: Pooling entities?

                HandleRemovedEntity(entity.Id);
                EntityRemoved?.Invoke(entity);
            }
        }
Beispiel #4
0
 protected void RegisterEntity(RailEntityBase entity)
 {
     entities.Add(entity.Id, entity);
     entity.RoomBase = this;
     entity.Added();
 }