// Construct public FrameBuffer(NetworkSyncTransform _nst, NSTElementsEngine _nstElementsEngine, int _size, Vector3 _pos, Quaternion _rot) { nst = _nst; nstElementsEngine = _nstElementsEngine; bufferSize = _size; halfBufferSize = (bufferSize - 1) / 2; quaterBufferSize = bufferSize / 3; frames = new Frame[bufferSize]; CompressedElement compPos = _pos.CompressToWorld(); for (int i = 0; i < bufferSize; i++) { frames[i] = new Frame(nst, nstElementsEngine, i, _pos, compPos, _rot); } currentFrame = frames[0]; prevAppliedFrame = frames[0]; frames[0].ModifyFrame(UpdateType.Regular, RootSendType.Full, _pos, _rot, Time.time); jumpForwardThreshold = (int)(nst.desiredBufferMS / nst.frameUpdateInterval) + 1; }
public override void OnEnable() { headerName = HeaderElementAddonName; headerColor = HeaderElementAddonColor; base.OnEnable(); _target = (NSTElementComponent)target; _target.nstElementsEngine = NSTElementsEngine.EnsureExistsOnRoot(_target.transform, false); nstElementsEngine = _target.nstElementsEngine; // First make sure this is unique for this gameobject MakeAllNamesUnique(_target.gameObject); }
private void AddAllDependencies(bool silence = false) { headerName = HeaderNSTName; headerColor = HeaderNSTColor; base.OnEnable(); nst = (NetworkSyncTransform)target; // Add this NST to the prefab spawn list (and as player prefab if none exists yet) as an idiot prevention if (!Application.isPlaying) { MasterNetAdapter.AddAsRegisteredPrefab(nst.gameObject, silence); } // If user tried to put NST where it shouldn't be... remove it and all of the required components it added. if (nst.transform.parent != null) { Debug.LogError("NetworkSyncTransform must be on the root of an prefab object."); nst.nstElementsEngine = nst.transform.GetComponent <NSTElementsEngine>(); NSTNetAdapter.RemoveAdapter(nst); DestroyImmediate(nst); if (nst.nstElementsEngine != null) { DestroyImmediate(nst.nstElementsEngine); } return; } nst.na = NSTNetAdapter.EnsureNstAdapterExists(nst.gameObject); nst.nstSettings = NSTSettings.EnsureExistsInScene(NSTSettings.DEFAULT_GO_NAME); nst.nstElementsEngine = NSTElementsEngine.EnsureExistsOnRoot(nst.transform, false); NSTMaster.EnsureExistsInScene("NST Master"); }
// Construct public Frame(NetworkSyncTransform _nst, NSTElementsEngine _nstElementsEngine, int index, Vector3 _pos, CompressedElement _compPos, Quaternion _rot) //, PositionElement[] positionElements, RotationElement[] rotationElements) { nst = _nst; nstElementsEngine = _nstElementsEngine; rootPos = _pos; compPos = _compPos; int numbOfElements = nstElementsEngine.transformElements.Length; elements = new List <XElement>(numbOfElements); for (int eid = 0; eid < numbOfElements; eid++) { elements.Add(new XElement( nstElementsEngine.transformElements[eid].Localized, nstElementsEngine.transformElements[eid].Compress(), false, nstElementsEngine.transformElements[eid] )); } frameid = index; customData = new byte[128]; //TODO: Make this size a user setting }
/// <summary> /// Ensure all required dependencies are added for this NST to work. Can be called often in edit mode, and should be. Returns false /// if a DestroyImmediate was invoked. /// </summary> /// <param name="nst"></param> /// <param name="silence"></param> public static void EnsureAllNSTDependencies(this NetworkSyncTransform nst, SerializedObject serializedObject, bool silence = false) { EnsureSceneNetLibDependencies(); if (Application.isPlaying) { return; } // If user tried to put NST where it shouldn't be... remove it and all of the required components it added. if (nst.transform.parent != null) { DebugX.LogError("NetworkSyncTransform must be on the root of an prefab object."); nst.nstElementsEngine = nst.transform.GetComponent <NSTElementsEngine>(); NSTNetAdapter.RemoveAdapter(nst); Object.DestroyImmediate(nst); if (nst.nstElementsEngine != null) { Object.DestroyImmediate(nst.nstElementsEngine); EditorUtility.SetDirty(nst.gameObject); } return; } nst.nstElementsEngine = NSTElementsEngine.EnsureExistsOnRoot(nst.transform, false); nst.na = EditorUtils.EnsureRootComponentExists <NSTNetAdapter>(nst.gameObject, false); AddRewindEngine(nst); //// Add this NST to the prefab spawn list (and as player prefab if none exists yet) as an idiot prevention NSTNetAdapter.AddAsRegisteredPrefab(nst.gameObject, true); //NSTNetAdapter.AddAsRegisteredPrefab(nst.gameObject, silence); return; }
public virtual void Initialize(NetworkSyncTransform _nst) { nst = _nst; nstElementsEngine = nst.nstElementsEngine; }
public override void OnNstPostAwake() { base.OnNstPostAwake(); nstElementsEngine = nst.nstElementsEngine; }