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); } }
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); }
public object SetObjectData(object obj, SerializationInfo info, StreamingContext context, ISurrogateSelector selector) { return(HoloNetPlayer.FindPlayer(info.GetInt32("uniqueId"))); }