Exemplo n.º 1
0
        public HoloNetObject GetObject(HoloNetObjectId oid)
        {
            HoloNetObject result;

            _netObjects.TryGetValue(oid, out result);
            return(result);
        }
Exemplo n.º 2
0
 public void LocalInit(HoloNetObjectId oid, int pid, HoloNetPlayer owner)
 {
     this.oid   = oid;
     this.pid   = pid;
     this.owner = owner;
     Debug.Log($"[HOLONET] HNO - initializing new HNO {gameObject.name}");
     PopulateNetComponents();
 }
Exemplo n.º 3
0
        public void SetState(HoloNetObjectState state)
        {
            oid   = state.oid;
            pid   = state.pid;
            owner = HoloNetPlayer.FindPlayer(state.ownerId);

            foreach (var componentState in state.componentStates)
            {
                //TODO add cache for observables
                var observable = _observables.FirstOrDefault(o => o.id == componentState.componentId);
                observable?.stateSyncable?.ApplySyncState(componentState);
            }
        }
Exemplo n.º 4
0
        public HoloNetObject SpawnObjectLocal(HoloNetObjectId oid, int prefabId, int ownerId,
                                              Vector3 position    = new Vector3(),
                                              Quaternion rotation = new Quaternion())
        {
            var prefab = GetPrefabById(prefabId);
            var result = Object.Instantiate(prefab, position, rotation).GetComponent <HoloNetObject>();

            result.transform.position = position;
            result.transform.rotation = rotation;

            RegisterObject(oid, result);
            result.LocalInit(oid, prefabId, HoloNetPlayer.FindPlayer(ownerId));

            return(result);
        }
Exemplo n.º 5
0
 public bool IsObjectRegistered(HoloNetObjectId oid)
 {
     return(_netObjects.ContainsKey(oid));
 }
Exemplo n.º 6
0
 private void RegisterObject(HoloNetObjectId oid, HoloNetObject obj)
 {
     _netObjects.Add(oid, obj);
 }
Exemplo n.º 7
0
 public bool Equals(HoloNetObjectId other)
 {
     return(authorId == other.authorId && objectId == other.objectId);
 }