Esempio n. 1
0
        public override void Initialize()
        {
            single = this;
            base.Initialize();

            if (initialized)
            {
                return;
            }

            initialized = true;

            // populate the lookup dictionary
            for (int i = 0; i < hitGroupTags.Count; i++)
            {
                if (rewindLayerTagToId.ContainsKey(hitGroupTags[i]))
                {
                    DebugX.LogError(!DebugX.logErrors ? null : ("The tag '" + hitGroupTags[i] + "' is used more than once in NSTRewindSettings. Repeats will be discarded, which will likely break some parts of rewind until they are removed."));
                }
                else
                {
                    rewindLayerTagToId.Add(hitGroupTags[i], i);
                }
            }

            DebugX.Log(!DebugX.logInfo ? null : ("Initialized HitGroupMasterSettings - Total Layer Tags Count: " + hitGroupTags.Count));
        }
Esempio n. 2
0
        /// <summary>
        /// Finds UI Elements. If none found will create them and return false to indicate that placeholders are being used.
        /// </summary>
        /// <returns></returns>
        public bool FindUIElement()
        {
            // First see if this is on a canvas, if so note it
            if (!canvas)
            {
                canvas = GetComponent <Canvas>();
            }

            // Is this a placeholder canvas we just created for another bar?
            if (canvas && canvas.gameObject.name == PLACEHOLDER_CANVAS_NAME)
            {
                // This means another HealthUI created a placeholder, so we will use that canvas.
            }
            // If we have a canvas then search for the text/images
            else if (canvas)
            {
                if (canvas.gameObject.name != PLACEHOLDER_CANVAS_NAME)
                {
                    if (!UIText)
                    {
                        UIText = (searchChildren) ? canvas.GetComponentInChildren <Text>() : canvas.GetComponent <Text>();
                    }

                    if (!UIImage)
                    {
                        UIImage = (searchChildren) ? canvas.GetComponentInChildren <Image>() : canvas.GetComponent <Image>();
                    }
                }
            }
            // No canvas, so this may be the UI Element itself this is attached to
            else
            {
                if (!UIText)
                {
                    UIText = (searchChildren) ? GetComponentInChildren <Text>() : GetComponent <Text>();
                }

                if (!UIImage)
                {
                    UIImage = (searchChildren) ? GetComponentInChildren <Image>() : GetComponent <Image>();
                }
            }

            // If nothing was found after all of that - we need to make a canvas and UI elements.
            if (!UIText && !UIImage)
            {
                DebugX.LogWarning(!DebugX.logWarnings ? null : ("NSTSampleHealthUI on gameobject '" + name + "' cannot find any UI Canvas, Text or Image. Will create some placeholders until you supply them."), nst);
                DebugX.LogError(!DebugX.logErrors ? null : ("NSTSampleHealthUI on gameobject '" + name + "' cannot find a NetworkSyncTransform, UI Text, or UI Image component. Be sure the object we are attaching to conains one of those."), !nst);

                // Put some bars of this things head if it is an NST - Otherwise they won't make much sense on other objects.
                if (nst)
                {
                    CreatePlaceholderVitalBar(monitoredVitalId);
                }

                return(false);
            }
            return(true);
        }
Esempio n. 3
0
        public NSTElementsEngine Initialize()
        {
            if (initialized)
            {
                return(this);
            }

            initialized = true;

            // Collect all of the transform elements
            INSTTransformElement[] iTransElement = GetComponentsInChildren <INSTTransformElement>(true);
            elementIdLookup = new Dictionary <string, int>(iTransElement.Length);
            elementLookup   = new Dictionary <string, TransformElement>(iTransElement.Length);

            transformElements = new TransformElement[iTransElement.Length];
            for (int i = 0; i < iTransElement.Length; i++)
            {
                if (elementIdLookup.ContainsKey(iTransElement[i].TransElement.name))
                {
                    DebugX.LogError(!DebugX.logErrors ? "" :
                                    ("Multiple child elements with the same name on '" + nst.name + "'. Check the names of Rotation and Positon elements for any repeats and be sure they all have unique names."));
                }
                else
                {
                    elementIdLookup.Add(iTransElement[i].TransElement.name, i);
                    elementLookup.Add(iTransElement[i].TransElement.name, iTransElement[i].TransElement);
                }

                // Make note of which of the transforms belongs to the NST root rotation
                if (transformElements[i] == nst.rootRotationElement)
                {
                    rootRotId            = i;
                    transformElements[0] = transformElements[i];
                }

                transformElements[i]       = iTransElement[i].TransElement;
                transformElements[i].index = i;

                if (transformElements[i].gameobject == null)
                {
                    transformElements[i].gameobject = iTransElement[i].GameObject;
                }

                transformElements[i].Initialize(nst);
            }

            // init the list
            history = new GenericX[NSTSettings.single.frameCount][];
            for (int frameid = 0; frameid < history.Length; frameid++)
            {
                history[frameid] = new GenericX[transformElements.Length];
                for (int elementid = 0; elementid < transformElements.Length; elementid++)
                {
                    history[frameid][elementid] = new GenericX();
                }
            }
            return(this);
        }
Esempio n. 4
0
        IEnumerator Co_TestReset()
        {
            DebugX.LogError("SCORE = " + gameState.score);
            yield return(new WaitForSeconds(0.5f));

            GameDataMgr.G.UpdateLevel();
            yield return(new WaitForSeconds(0.5f));

            GameStart();
            isGameEnd = false;
        }
Esempio n. 5
0
        /// <summary>
        /// Compress and bitpack the enabled vectors into a generic unsigned int.
        /// </summary>
        public CompressedElement Compress(Quaternion quat)
        {
            if (!cached)
            {
                CacheValues();
            }

            DebugX.LogError("You seem to be trying to compress a Quaternion with a crusher that is set up for " +
                            System.Enum.GetName(typeof(TRSType), TRSType) + ".", TRSType != TRSType.Quaternion, true);

            return(cache_xEnabled ? new CompressedElement(this, qcrusher.Compress(quat), cache_qBits) : CompressedElement.Empty);
        }
Esempio n. 6
0
        public CompressedElement Write(Quaternion quat, byte[] bytes, ref int bitposition, BitCullingLevel bcl = BitCullingLevel.NoCulling)
        {
            if (!cached)
            {
                CacheValues();
            }

            DebugX.LogError("You seem to be trying to compress a Quaternion with a crusher that is set up for " +
                            System.Enum.GetName(typeof(TRSType), TRSType) + ".", TRSType != TRSType.Quaternion, true);

            return(new CompressedElement(this, qcrusher.Write(quat, bytes, ref bitposition), cache_qBits));
        }
Esempio n. 7
0
        public override void OnNstPostAwake()
        {
            base.OnNstPostAwake();

            // Remove if this is not on the root
            if (transform != transform.root)
            {
                DebugX.LogError(!DebugX.logErrors ? null :
                                ("Removing '" + typeof(T) + "' from child '" + name + "' of gameobject " + transform.root.name +
                                 ". This component should only exist on the root of a networked object with a NetworkSyncTranform component."));

                Destroy(this);
            }
        }
Esempio n. 8
0
        //// Use this for initialization
        void Awake()
        {
            if (projCollider == null)
            {
                projCollider = transform.root.GetComponentInChildren <Collider>();
            }

            // Disable this if there is no collider, and warn the developer.
            if (projCollider == null)
            {
                DebugX.LogError(!DebugX.logErrors ? null :
                                (name + " is a projectile, but it has no collider - be sure to add one (or collisions can't be detected) or remove this " + this.GetType() + " component."));

                enabled = false;
            }
        }
Esempio n. 9
0
        //public static void EnsureNSTMasterConforms()
        //{
        //	GameObject nstMasterPrefab = Resources.Load("NST Master", typeof(GameObject)) as GameObject;
        //	nstMasterPrefab.EnsureRootComponentExists<NSTMaster>();
        //	nstMasterPrefab.EnsureRootComponentExists<MasterNetAdapter>();

        //	if (MasterNetAdapter.NetLib == NetworkLibrary.UNET)
        //		nstMasterPrefab.EnsureRootComponentExists<NetworkIdentity>();
        //	else
        //	{
        //		NetworkIdentity ni = nstMasterPrefab.GetComponent<NetworkIdentity>();
        //		if (ni)
        //			Object.DestroyImmediate(ni);
        //	}
        //}

        //public static T EnsureContainsComponent<T>(this GameObject go) where T : Component
        //{
        //	T comp = go.GetComponent<T>();
        //	if (!comp)
        //		comp = go.AddComponent<T>();
        //	return comp;
        //}

        /// <summary>
        /// Return true if that library successfully was activated, or was already activated. False indicates a fail, to notify the enum
        /// selector to not make the change and stay in the current mode.
        /// </summary>
        /// <param name="netlib"></param>
        /// <returns></returns>
        public static bool OverwriteAdapters(NetworkLibrary newLib)
        {
            // Test to see if this library is already what is active
            if (MasterNetAdapter.NetworkLibrary != newLib)
            {
                // Don't try to change to PUN if the PUN classes are missing (not installed)
                if (newLib == NetworkLibrary.PUN)
                {
                    if (!PUN_Exists)
                    {
                        DebugX.LogError("Photon PUN does not appear to exist in this project. You will need to download Photon PUN from the Unity Asset Store and import it into this project in order to have this option.", true, true);
                        return(false);
                    }
                }
            }

            return(CopyUncompiledAdapters(newLib));
        }
        private void SetUpRewindLayer()
        {
            if (useRewindColliders)
            {
                // First see if there is a name layer the user has set up
                rewindLayer     = LayerMask.NameToLayer("NSTRewind");
                rewindLayerMask = LayerMask.GetMask("NSTRewind");

                // If not, find the first empty layer
                if (rewindLayer.value == -1)
                {
                    for (int i = 8; i < 32; i++)
                    {
                        DebugX.Log(" Testing " + i + " '" + LayerMask.LayerToName(i) + "'");
                        if (LayerMask.LayerToName(i) == "")
                        {
                            rewindLayer = i;
                            //rewindLayerMask =
                            BitToolsUtils.BitTools.SetBitInMask(i, ref rewindLayerMask, true);
                            DebugX.Log("Rewind will use empty physics layer " + rewindLayer.value + " with a mask of " + rewindLayerMask + ". This was the first unused layer found. To specify the physics layer for rewind add a dedicated physics layer named <b>'NSTRewind'</b> to <b>Edit/Project Settings/Tags and Layers</b>.");
                            break;
                        }
                    }

                    // If no empty layers could be found, rewind is not possible.
                    if (rewindLayer.value == -1)
                    {
                        DebugX.LogError("No 'NSTRewind' layer found in layers and no unused physics layer could be found. You must add a dedicated physics layer named <b>'NSTRewind'</b> to <b>Edit/Project Settings/Tags and Layers</b> in order to make use of rewind ray test methods.");
                        return;
                    }
                }

                // Clear all physics layers from interacting with NSTRewind layer
                for (int i = 0; i < 32; i++)
                {
                    Physics.IgnoreLayerCollision(rewindLayer.value, i);
                }
            }
        }
Esempio n. 11
0
        public void Initialize()
        {
            if (initialized)
            {
                return;
            }

            initialized = true;

            for (int i = 0; i < hitGroupTags.Count; i++)
            {
                if (rewindLayerTagToId.ContainsKey(hitGroupTags[i]))
                {
                    DebugX.LogError(!DebugX.logErrors ? "" : ("The tag '" + hitGroupTags[i] + "' is used more than once in NSTRewindSettings. Repeats will be discarded, which will likely break some parts of rewind until they are removed."));
                }
                else
                {
                    rewindLayerTagToId.Add(hitGroupTags[i], i);
                }
            }

            DebugX.Log(!DebugX.logInfo ? "" : ("Initialized NSTHitboxSettings - Total Layer Tags Count: " + hitGroupTags.Count));
        }
Esempio n. 12
0
        /// <summary>
        /// Applies rotation using the correct localRotation/Rotation method, and only applies the axis indicated by the RotationType of the rotation. This allows you to apply an X rotation
        /// without changing the y and z values.
        /// </summary>
        /// <param name="targetTransform"></param>
        /// <param name="isLocalRotation"></param>
        public void ApplyRotation(Transform targetTransform, bool isLocalRotation = false)
        {
            if (type == XType.NULL)
            {
                DebugX.LogError(!DebugX.logErrors ? "" : ("Attempt to apply a null rotation. Skipping."));
                return;
            }
            if (type == XType.Quaternion || type == XType.XYZ)
            {
                if (isLocalRotation)
                {
                    targetTransform.localRotation = this;
                }
                else
                {
                    targetTransform.rotation = this;
                }
            }
            else
            {
                Vector3 tempvec3 = new Vector3
                                   (
                    (IsX) ? x : (isLocalRotation) ? targetTransform.localEulerAngles.x : targetTransform.eulerAngles.x,
                    (IsY) ? y : (isLocalRotation) ? targetTransform.localEulerAngles.y : targetTransform.eulerAngles.y,
                    (IsZ) ? z : (isLocalRotation) ? targetTransform.localEulerAngles.z : targetTransform.eulerAngles.z
                                   );

                if (isLocalRotation)
                {
                    targetTransform.localEulerAngles = tempvec3;
                }
                else
                {
                    targetTransform.eulerAngles = tempvec3;
                }
            }
        }
Esempio n. 13
0
        /// <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, silence);
            return;
        }
Esempio n. 14
0
        public void Start()
        {
            DebugX.LogError("You appear to have a NetworkIdentity on instantiated object '" + name + "', but that object has NOT been network spawned. " +
                            "Only use NetworkSyncTransform and NetworkIdentity on objects you intend to spawn normally from the server using NetworkServer.Spawn(). " +
                            "(Projectiles for example probably don't need to be networked objects).", ni.netId.Value == 0, true);

            // If this is an invalid NST... abort startup and shut it down.
            if (ni.netId.Value == 0)
            {
                Destroy(GetComponent <NetworkSyncTransform>());
                return;
            }


            foreach (INetEvents cb in iNetEvents)
            {
                cb.OnStart();
            }

            foreach (IOnStart cb in iOnStart)
            {
                cb.OnStart();
            }
        }
Esempio n. 15
0
 public void Apply(ulong u0, ulong u1, ulong u2, ulong u3, uint u4)
 {
     DebugX.LogError(transformMissingError, !defaultTransform, true);
     Apply(defaultTransform, u0, u1, u2, u3, u4);
 }
Esempio n. 16
0
 /// <summary>
 /// Apply the TRS matrix to a transform. Any axes not included in the Crusher are left as is.
 /// </summary>
 public void Apply(CompressedMatrix cmatrix)
 {
     DebugX.LogError(transformMissingError, !defaultTransform, true);
     Apply(defaultTransform, cmatrix);
 }
Esempio n. 17
0
 /// <summary>
 /// Apply the TRS matrix to a transform. Any axes not included in the Crusher are left as is.
 /// </summary>
 public void Apply(Matrix matrix)
 {
     DebugX.LogError(transformMissingError, !defaultTransform, true);
     Apply(defaultTransform, matrix);
 }
Esempio n. 18
0
 public void Apply(ulong cvalue)
 {
     DebugX.LogError(transformMissingError, !defaultTransform, true);
     Apply(defaultTransform, cvalue);
 }
Esempio n. 19
0
        public NSTElementsEngine Initialize()
        {
            if (initialized)
            {
                return(this);
            }

            initialized = true;

            // This is a repeat but chasing down the OOE was looking too messy so just doing it again here.
            nst = GetComponent <NetworkSyncTransform>();

            // Collect all of the transform elements
            INSTTransformElement[] iTransElement = GetComponentsInChildren <INSTTransformElement>(true);
            elementCount = iTransElement.Length;

            elementIdLookup = new Dictionary <string, int>(elementCount);
            elementLookup   = new Dictionary <string, TransformElement>(elementCount);

            transformElements = new TransformElement[elementCount];

            for (int i = 0; i < elementCount; ++i)
            {
                if (elementIdLookup.ContainsKey(iTransElement[i].TransElement.name))
                {
                    DebugX.LogError(!DebugX.logErrors ? null :
                                    ("Multiple child elements with the same name on '" + nst.name + "'. Check the names of Rotation and Positon elements for any repeats and be sure they all have unique names."));
                }
                else
                {
                    elementIdLookup.Add(iTransElement[i].TransElement.name, i);
                    elementLookup.Add(iTransElement[i].TransElement.name, iTransElement[i].TransElement);
                }

                // Make note of which of the transforms belongs to the NST root rotation
                if (transformElements[i] == nst.rootRotationElement)
                {
                    rootRotId            = i;
                    transformElements[0] = transformElements[i];
                }

                transformElements[i]       = iTransElement[i].TransElement;
                transformElements[i].index = i;

                if (transformElements[i].gameobject == null)
                {
                    transformElements[i].gameobject = iTransElement[i].SrcGameObject;
                }

                transformElements[i].Initialize(nst);
            }

            // init the list
            //history = new GenericX[frameCount + 1][];
            //for (int frameid = 0; frameid < history.Length; frameid++)
            //{
            //	history[frameid] = new GenericX[transformElements.Length];
            //	for (int elementid = 0; elementid < transformElements.Length; elementid++)
            //	{
            //		history[frameid][elementid] = new GenericX();
            //	}
            //}

            //int numbOfElements = transformElements.Length;

            //elements = new List<XElement>[frameCount + 1];
            //for (int fid = 0; fid < elements.Length; fid++)
            //{
            //	elements[fid] = new List<XElement>(numbOfElements);
            //	List<XElement> frameElements = elements[fid];

            //	for (int eid = 0; eid < numbOfElements; eid++)
            //	{
            //		frameElements.Add(new XElement(
            //			transformElements[eid].Localized,
            //			transformElements[eid].Compress(),
            //			false,
            //			transformElements[eid]
            //			));
            //	}
            //}
            //elements = new List<XElement>(numbOfElements);


            return(this);
        }
Esempio n. 20
0
        /// <summary>
        /// Finds UI Elements. If none found will create them and return false to indicate that placeholders are being used.
        /// </summary>
        /// <returns></returns>
        public bool FindUIElement()
        {
            // First see if this is on a canvas, if so note it
            if (!canvas)
            {
                canvas = GetComponent <Canvas>();
            }

            // If we have a canvas then search for the text/images
            if (canvas != null)
            {
                if (!UIText)
                {
                    UIText = (searchChildren) ? canvas.GetComponentInChildren <Text>() : canvas.GetComponent <Text>();
                }

                if (!UIImage)
                {
                    UIImage = (searchChildren) ? canvas.GetComponentInChildren <Image>() : canvas.GetComponent <Image>();
                }
            }
            // No canvas, so this may be the UI Element itself this is attached to
            else
            {
                if (!UIText)
                {
                    UIText = (searchChildren) ? GetComponentInChildren <Text>() : GetComponent <Text>();
                }

                if (!UIImage)
                {
                    UIImage = (searchChildren) ? GetComponentInChildren <Image>() : GetComponent <Image>();
                }
            }

            // If nothing was found after all of that - we need to make a canvas and UI elements.
            if (!UIText && !UIImage)
            {
                DebugX.LogWarning(!DebugX.logWarnings ? "" : ("NSTSampleHealthUI on gameobject '" + name + "' cannot find any UI Canvas, Text or Image. Will create some placeholders until you supply them."), nst);
                DebugX.LogError(!DebugX.logErrors ? "" : ("NSTSampleHealthUI on gameobject '" + name + "' cannot find a NetworkSyncTransform, UI Text, or UI Image component. Be sure the object we are attaching to conains one of those."), !nst);

                // Put some bars of this things head if it is an NST - Otherwise they won't make much sense on other objects.
                if (nst)
                {
                    CreatePlaceholderVitalBar(monitoredVitalId);
                }

                return(false);
            }

            return(true);
            //if (graphic == null)
            //	graphic = GetComponent<Graphic>();

            //bool isValid = (graphic is Text || graphic is Image);

            //if (!isValid)
            //{
            //	DebugX.LogError(!DebugX.logErrors ? "" : ("NSTSampleHealthUI on gameobject '" + name + "' is not a UI Image or UI Text."));
            //	CreatePlaceholderVitalBar(monitoredVitalId);
            //}

            //return isValid;
        }
Esempio n. 21
0
    private static int createAudioWave(AnimationCurve volume, AnimationCurve frequency, LeanAudioOptions options)
    {
        float time       = volume[volume.length - 1].time;
        int   listLength = 0;
        // List<float> list = new List<float>();

        // generatedWaveDistances = new List<float>();
        // float[] vibratoValues = new float[ vibrato.Length ];
        float passed = 0f;

        for (int i = 0; i < PROCESSING_ITERATIONS_MAX; i++)
        {
            float f = frequency.Evaluate(passed);
            if (f < MIN_FREQEUNCY_PERIOD)
            {
                f = MIN_FREQEUNCY_PERIOD;
            }
            float height = volume.Evaluate(passed + 0.5f * f);
            if (options.vibrato != null)
            {
                for (int j = 0; j < options.vibrato.Length; j++)
                {
                    float peakMulti = Mathf.Abs(Mathf.Sin(1.5708f + passed * (1f / options.vibrato[j][0]) * Mathf.PI));
                    float diff      = (1f - options.vibrato[j][1]);
                    peakMulti = options.vibrato[j][1] + diff * peakMulti;
                    height   *= peakMulti;
                }
            }


            // Debug.Log("i:"+i+" f:"+f+" passed:"+passed+" height:"+height+" time:"+time);
            if (passed + 0.5f * f >= time)
            {
                break;
            }
            if (listLength >= PROCESSING_ITERATIONS_MAX - 1)
            {
                DebugX.LogError("LeanAudio has reached it's processing cap. To avoid this error increase the number of iterations ex: LeanAudio.PROCESSING_ITERATIONS_MAX = " + (PROCESSING_ITERATIONS_MAX * 2));
                break;
            }
            else
            {
                int distPoint = listLength / 2;

                //generatedWaveDistances.Add( f );
                passed += f;

                generatedWaveDistances[distPoint] = passed;
                //Debug.Log("distPoint:"+distPoint+" passed:"+passed);

                //list.Add( passed );
                //list.Add( i%2==0 ? -height : height );

                longList[listLength]     = passed;
                longList[listLength + 1] = i % 2 == 0 ? -height : height;
            }



            listLength += 2;
        }

        listLength += -2;
        generatedWaveDistancesCount = listLength / 2;

        /*float[] wave = new float[ listLength ];
         * for(int i = 0; i < wave.Length; i++){
         *      wave[i] = longList[i];
         * }*/
        return(listLength);
    }
Esempio n. 22
0
        public NSTElementsEngine Initialize()
        {
            if (initialized)
            {
                return(this);
            }

            initialized = true;

            // This is redundant with the base class, but with initialize in Awake() rather than NSTAwake not assurance currently that it is set.
            nst = GetComponent <NetworkSyncTransform>();

            frameCount = 60 / nst.sendEveryXTick;

            // Collect all of the transform elements
            INSTTransformElement[] iTransElement = GetComponentsInChildren <INSTTransformElement>(true);
            elementCount = iTransElement.Length;

            elementIdLookup = new Dictionary <string, int>(elementCount);
            elementLookup   = new Dictionary <string, TransformElement>(elementCount);

            transformElements      = new TransformElement[elementCount];
            cache_elementIsEnabled = new bool[elementCount];

            for (int i = 0; i < elementCount; ++i)
            {
                TransformElement te = iTransElement[i].TransElement;

                cache_elementIsEnabled[i] =
                    te.sendCullMask != 0 &&
                    te.keyRate != 0 &&
                    te.crusher.Enabled;

                if (elementIdLookup.ContainsKey(te.name))
                {
                    DebugX.LogError(!DebugX.logErrors ? null :
                                    ("Multiple child elements with the same name on '" + nst.name + "'. Check the names of Rotation and Positon elements for any repeats and be sure they all have unique names."));
                }
                else
                {
                    elementIdLookup.Add(te.name, i);
                    elementLookup.Add(te.name, te);
                }


                //// Make note of which of the transforms belongs to the NST root rotation
                //if (System.Object.ReferenceEquals(te, nst.rootRotationElement))
                //{
                //	Debug.Log("ROOT NST ROTATION FOUND");
                //	//transformElements[0] = transformElements[i];
                //}

                transformElements[i]       = te;
                transformElements[i].index = i;

                if (transformElements[i].gameobject == null)
                {
                    transformElements[i].gameobject = iTransElement[i].SrcGameObject;
                }

                transformElements[i].Initialize(nst);

                //Debug.Log(nst.rootRotationElement.frames[0]);

                //// TODO: Questionable and stupid hack that replaces NST rootRotationElement with the found interface version (should be the same but arent)
                //if (iTransElement[i] is NetworkSyncTransform)
                //	nst.rootRotationElement = transformElements[i] as RotationElement;
            }


            // init the list
            //history = new GenericX[frameCount + 1][];
            //for (int frameid = 0; frameid < history.Length; frameid++)
            //{
            //	history[frameid] = new GenericX[transformElements.Length];
            //	for (int elementid = 0; elementid < transformElements.Length; elementid++)
            //	{
            //		history[frameid][elementid] = new GenericX();
            //	}
            //}

            //int numbOfElements = transformElements.Length;

            //elements = new List<XElement>[frameCount + 1];
            //for (int fid = 0; fid < elements.Length; fid++)
            //{
            //	elements[fid] = new List<XElement>(numbOfElements);
            //	List<XElement> frameElements = elements[fid];

            //	for (int eid = 0; eid < numbOfElements; eid++)
            //	{
            //		frameElements.Add(new XElement(
            //			transformElements[eid].Localized,
            //			transformElements[eid].Compress(),
            //			false,
            //			transformElements[eid]
            //			));
            //	}
            //}
            //elements = new List<XElement>(numbOfElements);


            return(this);
        }
Esempio n. 23
0
 /// <summary>
 /// Compress the transform of the default gameobject. (Only avavilable if this crusher is serialized in the editor).
 /// </summary>
 /// <returns></returns>
 public CompressedMatrix Compress()
 {
     DebugX.LogError(transformMissingError, !defaultTransform, true);
     return(Compress(defaultTransform));
 }