private void SerializeID(ushort id) { bigIndex = (id / 8); smallIndex = (id % 8); Header.Set(bigIndex, true); Data.EnsureCapacity(bigIndex + 1); Data[bigIndex] |= (byte)(1 << smallIndex); }
/// <summary> /// Add incoming samples to the buffer /// </summary> public void AddSamples(BigArray <float> incomingSamples) { int writeIndex = samples.Count * 4; int newLength = samples.Count + incomingSamples.Length; int writeBytes = incomingSamples.Length * 4; samples.EnsureCapacity(newLength); samples.ForceCount(newLength); incomingSamples.CopyTo(0, samples.Items, writeIndex, writeBytes); //for( int i = 0; i < incomingSamples.Length; i++ ) //{ // samples[ writeIndex + i ] = incomingSamples[ i ]; //} }
/// <inheritdoc/> public override void Extract() { var renderModelObjectInfo = RootRenderFeature.RenderData.GetData(renderModelObjectInfoKey); nodeInfos.Clear(); foreach (var objectNodeReference in RootRenderFeature.ObjectNodeReferences) { var objectNode = RootRenderFeature.GetObjectNode(objectNodeReference); var renderMesh = (RenderMesh)objectNode.RenderObject; var skeleton = renderMesh.RenderModel.ModelComponent.Skeleton; var skinning = renderMesh.Mesh.Skinning; // Skip unskinned meshes if (skinning == null) { renderModelObjectInfo[objectNodeReference] = new RenderModelFrameInfo(); continue; } var bones = skinning.Bones; var boneCount = bones.Length; // Reserve space in the node buffer renderModelObjectInfo[objectNodeReference] = new RenderModelFrameInfo { NodeInfoOffset = nodeInfos.Count, NodeInfoCount = boneCount }; // Ensure buffer capacity nodeInfos.EnsureCapacity(nodeInfos.Count + boneCount); // Copy matrices for (int index = 0; index < boneCount; index++) { var nodeIndex = bones[index].NodeIndex; nodeInfos.Add(new NodeFrameInfo { LinkToMeshMatrix = bones[index].LinkToMeshMatrix, NodeTransformation = skeleton.NodeTransformations[nodeIndex].WorldMatrix }); } } }
/// <summary>Installs the simulation into the game using the specified configuration.</summary> /// <param name="config">The configuration to run with.</param> /// <returns><c>true</c> when it succeeds; otherwise, <c>false</c>.</returns> /// <exception cref="ArgumentNullException">Thrown when the argument is null.</exception> public static bool Install(RealTimeConfig config) { if (config == null) { throw new ArgumentNullException(nameof(config)); } FastList <ISimulationManager> managers = GetSimulationManagers(); if (managers == null) { Log.Error("The 'Real Time' mod failed to get the simulation managers"); return(false); } if (managers.m_size == 0) { Log.Error("The 'Real Time' mod failed to register the awake/sleep simulation - no simulation managers found"); return(false); } if (managers.m_buffer[0] is AwakeSleepSimulation) { return(true); } if (managers.m_buffer[managers.m_buffer.Length - 1] != null) { managers.EnsureCapacity(managers.m_buffer.Length + 4); } ++managers.m_size; for (int i = managers.m_size - 1; i > 0; --i) { managers.m_buffer[i] = managers.m_buffer[i - 1]; } managers.m_buffer[0] = new AwakeSleepSimulation(config); return(true); }
public UserInterface() { instance = this; UIView view = GameObject.FindObjectOfType <UIView> (); if (view == null) { return; } UIComponent bulldozerBar = UIView.Find("BulldozerBar"); if (bulldozerBar == null) { return; } try { XmlSerializer serializer = new XmlSerializer(typeof(XmlData)); using (StreamReader reader = new StreamReader("V10Bulldoze.xml")) { data = (XmlData)serializer.Deserialize(reader); reader.Close(); } } catch (FileNotFoundException) { // No options file yet data = new XmlData(); data.needSave = true; } catch (Exception e) { Debug.Log("V10Bulldoze: " + e.GetType().Name + " while reading xml file: " + e.Message + "\n" + e.StackTrace + "\n\n"); if (e.InnerException != null) { Debug.Log("Caused by: " + e.InnerException.GetType().Name + ": " + e.InnerException.Message + "\n" + e.InnerException.StackTrace); } return; } //1.X -> 1.3 if (data.version < 1.3d) { // Everything has already been setted to its default value, so let's just adjust the version and save. data.version = 1.3d; data.needSave = true; } abandonedButton = new GameObject("V10Bulldoze abandoned button"); burnedButton = new GameObject("V10Bulldoze burned button"); audioButton = new GameObject("V10Bulldoze audio button"); Transform parent = bulldozerBar.transform; abandonedButton.transform.parent = parent; burnedButton.transform.parent = parent; audioButton.transform.parent = parent; Shader shader = Shader.Find("UI/Default UI Shader"); if (shader == null) { Debug.Log("V10Bulldoze: Can't find default UI shader."); shader = new Shader(); shader.name = "V10Bulldoze dummy shader"; } UITextureAtlas atlas = ScriptableObject.CreateInstance <UITextureAtlas> (); atlas.name = "V10Bulldoze Atlas"; atlas.material = new Material(shader); atlas.material.mainTexture = new Texture2D(0, 0, TextureFormat.DXT5, false); FastList <Texture2D> list = new FastList <Texture2D> (); list.EnsureCapacity(18); UIButton button = abandonedButton.AddComponent <UIButton> (); button.relativePosition = new Vector3(7.0f, -57.0f); initButton("AbandonedButton", button, list, data.abandoned, "Demolish Abandoned", view); button.atlas = atlas; button = burnedButton.AddComponent <UIButton> (); button.relativePosition = new Vector3((float)(7 + buttonSize + 7), -57.0f); initButton("BurnedButton", button, list, data.burned, "Demolish Burned", view); button.atlas = atlas; button = audioButton.AddComponent <UIButton> (); button.relativePosition = new Vector3((float)(7 + buttonSize + 7 + buttonSize + 7), -57.0f); initButton("AudioButton", button, list, !data.disableEffect, "Mute Bulldozing", view); button.atlas = atlas; atlas.AddTextures(list.ToArray()); }
/// <summary> /// Copies from original list to a new list based on treeindex values, based upon the flag sent. /// ie copies entries with 0 to 262144 only or that have 262144 to 'limit', or just all. /// </summary> /// <param name="orgBurningList">The orginal source list</param> /// <param name="bCopyFlag">0= CopyAllEntries; 1= 0 to 262144; 2= 262144 to 'limit'</param> /// <returns>a new FastList of treemanager.burningtrees, returns an empty list on none or error.</returns> public static FastList <TreeManager.BurningTree> CopyBurningTreesList(ref FastList <TreeManager.BurningTree> orgBurningList, byte bCopyFlag) { FastList <TreeManager.BurningTree> newlist = new FastList <TreeManager.BurningTree>(); newlist.Clear(); try { if (orgBurningList != null) { int orgcount = orgBurningList.m_size; newlist.EnsureCapacity(orgcount); TreeManager.BurningTree tmpTree = new TreeManager.BurningTree(); int tmpcounter = 0; int MinValue = 0; int MaxValue = 0; if (OptionsWrapper <Configuration> .Options.IsLoggingEnabled() && OptionsWrapper <Configuration> .Options.DebugLoggingLevel > 1) { Logger.dbgLog("CopyFlag = " + bCopyFlag.ToString()); } switch (bCopyFlag) { //0-262144 mainserialze() case 1: MinValue = 0; MaxValue = Mod.DEFAULT_TREE_COUNT; break; //262144 to activelimit customserialze( not packed) case 2: MinValue = Mod.DEFAULT_TREE_COUNT; MaxValue = LimitTreeManager.Helper.TreeLimit; break; //262144 to lastsavecount.count customseralize(packed)??? case 3: MinValue = Mod.DEFAULT_TREE_COUNT; MaxValue = LoadingExtension.LastSaveList.Count; break; //just copy all of them. default: MinValue = 0; MaxValue = LimitTreeManager.Helper.TreeLimit; break; } if (OptionsWrapper <Configuration> .Options.IsLoggingEnabled() && OptionsWrapper <Configuration> .Options.DebugLoggingLevel > 1) { Logger.dbgLog(string.Concat("copying from: ", MinValue.ToString(), " to ", MaxValue.ToString())); } if (OptionsWrapper <Configuration> .Options.IsLoggingEnabled() && OptionsWrapper <Configuration> .Options.DebugLoggingLevel > 1) { m_PerfMonitor.Reset(); m_PerfMonitor.Start(); } foreach (TreeManager.BurningTree orgTree in orgBurningList) { if (orgTree.m_treeIndex > 0 && (orgTree.m_treeIndex >= MinValue & orgTree.m_treeIndex < MaxValue)) { //copy tree tmpTree.m_treeIndex = orgTree.m_treeIndex; tmpTree.m_fireDamage = orgTree.m_fireDamage; tmpTree.m_fireIntensity = orgTree.m_fireIntensity; newlist.Add(tmpTree); tmpcounter++; } } newlist.Trim(); if (OptionsWrapper <Configuration> .Options.IsLoggingEnabled() && OptionsWrapper <Configuration> .Options.DebugLoggingLevel > 1) { m_PerfMonitor.Stop(); Logger.dbgLog(string.Concat("Copy time took (ticks):", m_PerfMonitor.ElapsedTicks.ToString())); } if (OptionsWrapper <Configuration> .Options.IsLoggingEnabled() && OptionsWrapper <Configuration> .Options.DebugLoggingLevel > 1) { Logger.dbgLog(string.Concat("orgCount(m_size):", orgcount.ToString(), " copycount:", tmpcounter.ToString()) + " new_msize:" + newlist.m_size.ToString()); } } else { Logger.dbgLog("orgBurningList is Null!"); return(newlist); } } catch (Exception ex) { Logger.dbgLog(ex.ToString()); } return(newlist); }
public UserInterface() { instance = this; UIView view = GameObject.FindObjectOfType<UIView> (); if (view == null) return; UIComponent bulldozerBar = UIView.Find ("BulldozerBar"); if (bulldozerBar == null) return; try { XmlSerializer serializer = new XmlSerializer (typeof(XmlData)); using (StreamReader reader = new StreamReader("V10Bulldoze.xml")) { data = (XmlData)serializer.Deserialize (reader); reader.Close (); } } catch (FileNotFoundException) { // No options file yet data = new XmlData (); data.needSave = true; } catch (Exception e) { Debug.Log ("V10Bulldoze: " + e.GetType ().Name + " while reading xml file: " + e.Message + "\n" + e.StackTrace + "\n\n"); if (e.InnerException != null) Debug.Log ("Caused by: " + e.InnerException.GetType ().Name + ": " + e.InnerException.Message + "\n" + e.InnerException.StackTrace); return; } //1.X -> 1.3 if (data.version < 1.3d) { // Everything has already been setted to its default value, so let's just adjust the version and save. data.version = 1.3d; data.needSave = true; } abandonedButton = new GameObject ("V10Bulldoze abandoned button"); burnedButton = new GameObject ("V10Bulldoze burned button"); audioButton = new GameObject ("V10Bulldoze audio button"); Transform parent = bulldozerBar.transform; abandonedButton.transform.parent = parent; burnedButton.transform.parent = parent; audioButton.transform.parent = parent; Shader shader = Shader.Find ("UI/Default UI Shader"); if (shader == null) { Debug.Log ("V10Bulldoze: Can't find default UI shader."); shader = new Shader (); shader.name = "V10Bulldoze dummy shader"; } UITextureAtlas atlas = ScriptableObject.CreateInstance<UITextureAtlas> (); atlas.name = "V10Bulldoze Atlas"; atlas.material = new Material (shader); atlas.material.mainTexture = new Texture2D (0, 0, TextureFormat.DXT5, false); FastList<Texture2D> list = new FastList<Texture2D> (); list.EnsureCapacity (18); UIButton button = abandonedButton.AddComponent<UIButton> (); button.relativePosition = new Vector3 (7.0f, -57.0f); initButton ("AbandonedButton", button, list, data.abandoned, "Demolish Abandoned", view); button.atlas = atlas; button = burnedButton.AddComponent<UIButton> (); button.relativePosition = new Vector3 ((float)(7 + buttonSize + 7), -57.0f); initButton ("BurnedButton", button, list, data.burned, "Demolish Burned", view); button.atlas = atlas; button = audioButton.AddComponent<UIButton> (); button.relativePosition = new Vector3 ((float)(7 + buttonSize + 7 + buttonSize + 7), -57.0f); initButton ("AudioButton", button, list, !data.disableEffect, "Mute Bulldozing", view); button.atlas = atlas; atlas.AddTextures (list.ToArray ()); }