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); }
public void OnInteract(NetEntity interactee) { if (Human == null) { HumanId = interactee.EntityId; } }
public bool TryFindEntity(int entityId, out NetEntity entity) { entity = FindEntity(entityId); return(entity != null); }
public CameraController(NetEntity viewer, Camera camera) { Viewer = viewer; Camera = camera; }