Ejemplo n.º 1
0
        public int AddEntity(NetEntity entity, bool setIndex = true)
        {
            if (Entities.Contains(entity))
            {
                return(-1);
            }

            if (entity.Started)
            {
                return(-1);
            }

            Entities.Add(entity);

            if (setIndex)
            {
                entity.EntityId = NextEntityIndex;

                // do this so clients can create their own client-side entities
                // and its id wont overlap with server-side entities
                if (!Game.IsHost)
                {
                    entity.EntityId *= -1;
                }
            }

            entity.Start();

            OnEntityAdded?.Invoke(entity);

            return(entity.EntityId);
        }
Ejemplo n.º 2
0
 public void OnInteract(NetEntity interactee)
 {
     if (Human == null)
     {
         HumanId = interactee.EntityId;
     }
 }
Ejemplo n.º 3
0
 public bool TryFindEntity(int entityId, out NetEntity entity)
 {
     entity = FindEntity(entityId);
     return(entity != null);
 }
Ejemplo n.º 4
0
 public CameraController(NetEntity viewer, Camera camera)
 {
     Viewer = viewer;
     Camera = camera;
 }