public void RestoreSafe() { if (this.TrapTrigger) { this.TrapTrigger.SendMessage("releaseTrapped", SendMessageOptions.DontRequireReceiver); } else { trapTrigger componentInChildren = base.transform.root.GetComponentInChildren <trapTrigger>(); if (componentInChildren != null) { componentInChildren.releaseTrapped(); } } if (!BoltNetwork.isRunning) { GameObject gameObject = UnityEngine.Object.Instantiate <GameObject>(this.Built, this.Ghost.transform.position, this.Ghost.transform.rotation); BuildingHealth componentInParent = base.GetComponentInParent <BuildingHealth>(); quickBuild component = gameObject.GetComponent <quickBuild>(); if (componentInParent && componentInParent.Hp < componentInParent._maxHP && component) { component.newBuildingDamage = componentInParent._maxHP - componentInParent.Hp; } TreeStructure component2 = this.Ghost.GetComponent <TreeStructure>(); if (component2 && component) { component.TreeId = component2.TreeId; } if (this.Ghost) { UnityEngine.Object.Destroy(this.Ghost); } } }
public static void TestEditorMeshPartRenderDataSimple() { XNAGame game = new XNAGame(); ColladaShader shader = null; game.InitializeEvent += delegate { TreeStructure struc; TreeEngine.EngineTreeRenderDataGenerater gen = new TreeEngine.EngineTreeRenderDataGenerater(20); struc = TreeStructure.GetTestTreeStructure(game); TreeEngine.EngineTreeRenderData renderData = gen.GetRenderData(struc, game, 0); //List<TangentVertex> vertices = new List<TangentVertex>(); //vertices.Add(new TangentVertex(new Vector3(-1, 2.5f, 0), new Vector2(0, 0), new Vector3(0, 0, 1), new Vector3(1, 0, 0))); //vertices.Add(new TangentVertex(new Vector3(-1, 0, 0), new Vector2(0, 1), new Vector3(0, 0, 1), new Vector3(1, 0, 0))); //vertices.Add(new TangentVertex(new Vector3(1, 0, 0), new Vector2(1, 1), new Vector3(0, 0, 1), new Vector3(1, 0, 0))); //vertices.Add(new TangentVertex(new Vector3(-1, 2.5f, 0), new Vector2(0, 0), new Vector3(0, 0, 1), new Vector3(1, 0, 0))); //vertices.Add(new TangentVertex(new Vector3(1, 2.5f, 0), new Vector2(1, 0), new Vector3(0, 0, 1), new Vector3(1, 0, 0))); //vertices.Add(new TangentVertex(new Vector3(1, 0, 0), new Vector2(1, 1), new Vector3(0, 0, 1), new Vector3(1, 0, 0))); ObjExporter exp = new ObjExporter(); exp.ExportToObj("testExportNoFlipNormals.obj", renderData); }; game.Run(); }
void Start() { mesh = GetComponent<MeshFilter>().mesh; tree = new TreeStructure(); this.RenderTree(); }
public void mibbrowser_OnMibNode(object sender, nsoftware.IPWorksSNMP.MibbrowserMibNodeEventArgs e) { string[] subids = e.NodeOid.Split(".".ToCharArray()); string oid = ""; TreeNodeCollection treeNodeCollection = tvwMibNodes.Nodes; foreach (string subid in subids) { MyTreeNode matchingTreeNode = null; foreach (MyTreeNode treeNode in treeNodeCollection) { if (treeNode.subid == subid) { matchingTreeNode = treeNode; break; } } oid += "." + subid; if (matchingTreeNode == null) { MibTreeInformation tree = new MibTreeInformation(); tree.Name = e.NodeLabel; tree.OID = e.NodeOid; tree.Mib = e.NodeModuleName; tree.Syntax = e.NodeSyntaxString; tree.Description = e.NodeDescription; tree.Access = e.NodeAccess.ToString(); tree.Status = e.NodeTypeString; tree.Indexes = e.NodeIndex; tree.MibID = id; tree.DefVal = ""; tree.DeviceID = DeviceID; tree.ParentName = e.NodeParentName; TreeMibList.Add(tree); TreeStructure childparent = new TreeStructure(); var parrent = TreeMibList.Where(m => m.Name == e.NodeParentName).FirstOrDefault(); if (parrent == null) { TreeMibList[TreeMibList.Count - 1].ParrentID = 0; } else { TreeMibList[TreeMibList.Count - 1].ParrentID = parrent.MibID; } id++; matchingTreeNode = new MyTreeNode(oid, e.NodeLabel, subid, e.NodeTypeString); treeNodeCollection.Add(matchingTreeNode); } treeNodeCollection = matchingTreeNode.ChildNodes; } }
/// <summary> /// This is the method that actually does the work. /// </summary> /// <param name="DA">The DA object is used to retrieve from inputs and store in outputs.</param> protected override void SolveInstance(IGH_DataAccess DA) { DA.GetDataTree(1, out GH_Structure <GH_Integer> tpt); var names = new List <string>(); DA.GetDataList(0, names); var tree = new TreeStructure(names, TreeStructure.ToListStruct(tpt)); DA.SetData(0, tree); }
protected override bool?DoGetExpanded(int row, int column) { TreeStructure ts = tree.GetVisibleChildData(row); if (ts != null && ts.Count != 0) { return(ts.Expanded); } return(base.DoGetExpanded(row, column)); }
/// <summary> /// This is the method that actually does the work. /// </summary> /// <param name="DA">The DA object is used to retrieve from inputs and store in outputs.</param> protected override void SolveInstance(IGH_DataAccess DA) { var names = new List <string>(); var parents = new List <int>(); DA.GetDataList(0, names); DA.GetDataList(1, parents); var tree = new TreeStructure(names, parents); DA.SetData(0, tree); }
public void Visit(TreeStructure <T> tree) { if (tree is SpecialTree <T> ) { count += 2; } else { count++; } }
internal T GetVisibleChild(int row) { TreeStructure ch = GetVisibleChildData(row); if (ch == null) { return(default(T)); } else { return(ch.data); } }
/// <summary> /// This is the method that actually does the work. /// </summary> /// <param name="DA">The DA object is used to retrieve from inputs and store in outputs.</param> protected override void SolveInstance(IGH_DataAccess DA) { var typeid = 0; var ss = new List <string>(); // DA.GetData(1, ref typeid); DA.GetDataList(0, ss); TreeStructure tree; ss.RemoveAll(i => Regex.IsMatch(i, "^\\s+$")); tree = TreeStructure.FromOutlineHrdCore(ss); DA.SetData(0, tree); }
/// <summary> /// This is the method that actually does the work. /// </summary> /// <param name="DA">The DA object is used to retrieve from inputs and store in outputs.</param> protected override void SolveInstance(IGH_DataAccess DA) { TreeStructure t = null; int n = 1; DA.GetData(0, ref t); DA.GetData(1, ref n); for (int i = 0; i < n; i++) { t = t.Trim(); } DA.SetData(0, t); }
protected override int DoGetIdent(int row, int column) { if (column != 0) { return(0); } TreeStructure node = tree.GetVisibleChildData(row); if (node != null) { return(node.Level * LevelIdent); } return(base.DoGetIdent(row, column)); }
protected override void DoExpandCollapse(int row) { TreeStructure ts = tree.GetVisibleChildData(row); if (ts == null) { return; } if (ts.Count != 0) { ts.Expanded = !ts.Expanded; } realGrid.RowCount = tree.VisibleCount; realGrid.Invalidate(); base.DoExpandCollapse(row); }
private void ParseAllExpressions(ref string fileContents, Token token) { // If there is anything in fileContents, that means we are parsing the next expression within the file. while (fileContents.Any()) { try { List <Token> tokens = new List <Token>(); ParseExpression(ref fileContents, tokens); if (tokens.Count == 2 && tokens[0].Type == TokenType.LeftParen && tokens[1].Type == TokenType.RightParen) { throw new InvalidDataException(string.Format("Parse error! Production rules do not allow S->epsilon.")); } allParsedTokens.AddRange(tokens); builtExpressions.Add(new Tuple <string, ExpressionParseSucces>(expressionBuilder.ToString(), ExpressionParseSucces.PASS)); TreeStructure tree = new TreeStructure(); foreach (var t in tokens .Where(tkn => tkn.Type != TokenType.LeftParen) .Where(tkn => tkn.Type != TokenType.RightParen)) { tree.AddToken(t); } tree.PrintTreePostTraversal(); } catch (InvalidDataException ide) { Console.WriteLine(ide.Message.ToString() == string.Empty ? "\\ " + expressionBuilder.ToString() : "\\ " + ide.Message.ToString()); builtExpressions.Add(new Tuple <string, ExpressionParseSucces>(expressionBuilder.ToString(), ExpressionParseSucces.FAIL)); fileContents = string.Empty; } catch (InvalidOperationException ioe) { Console.WriteLine("\\ " + ioe.Message.ToString()); builtExpressions.Add(new Tuple <string, ExpressionParseSucces>(ioe.Message.ToString(), ExpressionParseSucces.FAIL)); fileContents = string.Empty; } expressionBuilder.Clear(); scanner.ClearScannedTokens(); } //builtExpressions.ForEach(list => // Console.WriteLine(list.Item1 + string.Format("\t{0}", list.Item2.ToString()))); //Console.WriteLine("\n"); }
/// <summary> /// This is the method that actually does the work. /// </summary> /// <param name="DA">The DA object is used to retrieve from inputs and store in outputs.</param> protected override void SolveInstance(IGH_DataAccess DA) { treeGoo treeg = new treeGoo(); DA.GetData(0, ref treeg); TreeStructure t = null; double tn, sn, an, pie; tn = sn = an = pie = 0; Point3d cen = new Point3d(); DA.GetData(0, ref t); DA.GetData("Center", ref cen); DA.GetData("Domain", ref pie); DA.GetData("TN", ref tn); DA.GetData("AN", ref sn); DA.GetData("SN", ref an); var dom = new Interval((pie - 1) * Math.PI / 2, (3 - pie) * Math.PI / 2); var arcs = Enumerable.Range(0, t.Depth + 1).Select(i => new Arc(new Circle(cen, sn * Math.Pow(i, tn) + an), dom)).ToList(); var layers = treeg.Value.GetLayers(arcs.Select(i => i.ToNurbsCurve())); var Pointset = new DataTree <GeoNode>(); var TigSet = new DataTree <Curve>(); foreach (var gLayer in layers) { var path = new GH_Path(gLayer.Level); Pointset.AddRange(gLayer.ToList(), path); TigSet.AddRange(gLayer.Draw(), path); } TigSet.RemovePath(TigSet.Paths.Last()); DA.SetDataTree(0, TigSet); DA.SetDataTree(1, Pointset); var m = layers.ByOuterMosts(); DA.SetDataList(2, m[GLayerSet.dets.Outermodes]); DA.SetDataList(3, m[GLayerSet.dets.InMiddles]); DA.SetDataList(4, m[GLayerSet.dets.Invalid]); }
/// <summary> /// This is the method that actually does the work. /// </summary> /// <param name="DA">The DA object is used to retrieve from inputs and store in outputs.</param> protected override void SolveInstance(IGH_DataAccess DA) { TreeStructure t = null; double tn, sn, an, pie; tn = sn = an = pie = 0; Point3d cen = new Point3d(); DA.GetData(0, ref t); DA.GetData("Center", ref cen); DA.GetData("Domain", ref pie); DA.GetData("TN", ref tn); DA.GetData("AN", ref sn); DA.GetData("SN", ref an); var dom = new Interval((pie - 1) * Math.PI / 2, (3 - pie) * Math.PI / 2); var arcs = Enumerable.Range(0, t.Depth).Select(i => new Arc(new Circle(cen, sn * Math.Pow(i, tn) + an), dom)).ToList(); DA.SetDataList(0, arcs); }
public void Visit(TreeStructure <T> tree) { GenericVisit(tree); }
void GenericVisit(TreeStructure <T> tree) { //.. do whatever }
public void Visit(TreeStructure <T> tree) { count++; }
public void Initialize(float _delay) { delay = _delay; tree = GetComponent <TreeStructure> (); tree.Initialize(); }
public TreeStructure(decimal id, TreeStructure parent) { Id = id; Parent = parent; }
/// <summary> /// This is the method that actually does the work. /// </summary> /// <param name="DA">The DA object is used to retrieve from inputs and store in outputs.</param> protected override void SolveInstance(IGH_DataAccess DA) { var typeid = 0; var ss = new List <string>(); // DA.GetData(1, ref typeid); DA.GetDataList(0, ss); /* ss = s.Split("\n\r".ToCharArray(), StringSplitOptions.RemoveEmptyEntries).Where(i => i != "").ToList(); * List<string> lines = new List<string>( * input.Split(new string[] { "\r\n" }, * StringSplitOptions.RemoveEmptyEntries)); */ TreeStructure tree; if (TreeStructure.TryGetFromXML(ss[0], out tree)) { DA.SetData(0, tree); Message = "XML"; return; } var s = string.Join("\n\r", ss); ss = s.Split("\n\r".ToCharArray(), StringSplitOptions.RemoveEmptyEntries).Where(i => i != "").ToList(); typeid = match(ss, R_Outline) ? 1 : match(ss, R_MarkDown) ? 0 : R_JSON.IsMatch(s) ? 2 : R_SJSON.IsMatch(s) ? 3 : match(ss, R_Pointer) ? 4: match(ss, R_CSVOL) ? 5 : 6; Message = types[typeid]; try { switch (typeid) { case 0: tree = TreeStructure.FromMarkDown(ss); break; case 1: tree = TreeStructure.FromOutline(ss); break; case 2: tree = TreeStructure.FromJSON(s); break; case 3: tree = TreeStructure.FromSJSON(s); break; case 4: tree = TreeStructure.FromPointerCSV(ss); break; case 5: tree = TreeStructure.FromOutlineCSV(ss); break; default: throw new Exception(); } } catch (Exception e) { AddRuntimeMessage(GH_RuntimeMessageLevel.Error, e.ToString() + "\nCouldn't recognize the string format\n" + e.Message); return; } DA.SetData(0, tree); }
private void Build() { if (this._type != BuildingTypes.None) { EventRegistry.Player.Publish(TfEvent.BuiltStructure, this._type); this._type = BuildingTypes.None; } if (BoltNetwork.isClient) { if (base.enabled) { base.enabled = false; this.AllOff(false); } return; } if (!this._ghost) { this._ghost = base.transform.parent.gameObject; } GameObject gameObject; if (BoltNetwork.isServer) { if (base.entity.attachToken != null) { if (base.entity.attachToken is CoopWallChunkToken) { (base.entity.attachToken as CoopWallChunkToken).Additions = base.entity.GetComponent <WallChunkArchitect>().Addition; } gameObject = BoltNetwork.Instantiate(this.Built, base.entity.attachToken, this._ghost.transform.position, this._ghost.transform.rotation).gameObject; } else { gameObject = BoltNetwork.Instantiate(this.Built, base.entity.attachToken, this._ghost.transform.position, this._ghost.transform.rotation).gameObject; BoltEntity component = gameObject.GetComponent <BoltEntity>(); if (component && component.isAttached && component.StateIs <IMultiHolderState>()) { component.GetState <IMultiHolderState>().IsReal = true; } BoltEntity component2 = gameObject.GetComponent <BoltEntity>(); if (component2 && component.isAttached && component2.StateIs <IRaftState>()) { component2.GetState <IRaftState>().IsReal = true; } } } else { gameObject = UnityEngine.Object.Instantiate <GameObject>(this.Built, this._ghost.transform.position, this._ghost.transform.rotation); } TreeStructure component3 = this._ghost.GetComponent <TreeStructure>(); if (component3) { TreeStructure treeStructure = gameObject.GetComponent <TreeStructure>(); if (!treeStructure) { treeStructure = gameObject.AddComponent <TreeStructure>(); } treeStructure.TreeId = component3.TreeId; } ropeSetGroundHeight component4 = gameObject.GetComponent <ropeSetGroundHeight>(); if (component4) { gameObject.SendMessage("setGroundTriggerHeight", SendMessageOptions.DontRequireReceiver); } if (this._ghost.transform.parent != null) { gameObject.transform.parent = this._ghost.transform.parent; DynamicBuilding componentInParent = gameObject.GetComponentInParent <DynamicBuilding>(); if (componentInParent != null) { IgnoreCollisionInChildren componentInChildren = componentInParent.GetComponentInChildren <IgnoreCollisionInChildren>(); if (componentInChildren != null) { componentInChildren.startDisableChildren(); } } } this.OnBuilt(gameObject); this.OnBuilt = null; base.enabled = false; this._initialized = false; if (this._ghost) { base.StartCoroutine(this.DelayedDestroy()); } else { this.AllOff(true); } if (this._playTwinkle && LocalPlayer.Sfx) { LocalPlayer.Sfx.PlayBuildingComplete(gameObject, true); } else if (SteamDSConfig.isDedicatedServer) { FmodOneShot fmodOneShot = FmodOneShot.Create(GlobalTargets.Others, ReliabilityModes.Unreliable); fmodOneShot.EventPath = CoopAudioEventDb.FindId("event:/ui/ingame/ui_complete"); fmodOneShot.Position = gameObject.transform.position; fmodOneShot.Send(); } }
public void SwapToNextGhost() { if (LocalPlayer.Sfx) { LocalPlayer.Sfx.PlayWhoosh(); } if (BoltNetwork.isRunning && !base.entity.isOwner) { SwapGhost swapGhost = SwapGhost.Create(base.entity.source); swapGhost.GhostEntity = base.entity; swapGhost.Send(); } else { GameObject gameObject = UnityEngine.Object.Instantiate <GameObject>(this._swapTo, this._ghost.transform.position, this._ghost.transform.rotation); if (this._ghost.transform.parent) { gameObject.transform.parent = this._ghost.transform.parent; } Craft_Structure componentInChildren = gameObject.GetComponentInChildren <Craft_Structure>(); if (componentInChildren) { componentInChildren._presentIngredients = new ReceipeIngredient[componentInChildren._requiredIngredients.Count]; for (int i = 0; i < this._presentIngredients.Length; i++) { bool flag = false; for (int j = 0; j < componentInChildren._presentIngredients.Length; j++) { if (componentInChildren._presentIngredients[j] == null) { componentInChildren._presentIngredients[j] = new ReceipeIngredient { _itemID = this._presentIngredients[i]._itemID, _amount = 0 }; } if (this._presentIngredients[i]._itemID == componentInChildren._presentIngredients[j]._itemID) { int num = this._requiredIngredients[i]._amount - this._presentIngredients[i]._amount; BuildMission.AddNeededToBuildMission(this._presentIngredients[i]._itemID, -num, true); componentInChildren._presentIngredients[j]._amount = this._presentIngredients[i]._amount; flag = true; break; } } if (!flag) { this.SpawnBackIngredients(i); } } componentInChildren.manualLoading = false; TreeStructure component = this._ghost.GetComponent <TreeStructure>(); if (component) { TreeStructure treeStructure = gameObject.GetComponent <TreeStructure>(); if (!treeStructure) { treeStructure = gameObject.AddComponent <TreeStructure>(); } treeStructure.TreeId = component.TreeId; } if (BoltNetwork.isRunning && !gameObject.GetComponent <BoltEntity>().isAttached) { BoltNetwork.Attach(gameObject); } this.AllOff(false); if (BoltNetwork.isRunning) { BoltNetwork.Destroy(this._ghost); } else { UnityEngine.Object.Destroy(this._ghost); } } else { Debug.Log("Swap target isn't a ghost, aborting"); UnityEngine.Object.Destroy(gameObject); } } }
/// <summary> private TreeNode SearchTreeView(string p_sSearchTerm, TreeNodeCollection p_Nodes, int DeviceID) { int ss = 0; MibTreeInformation treeid = new MibTreeInformation(); son SonParent = new son(); foreach (TreeNode node in p_Nodes) { if (node.Text == p_sSearchTerm || (string)node.Target == p_sSearchTerm) { Expand = 1; SonParent.name = node.Text; SonParent.numb = IDid - 1; Par.Add(SonParent); //TreeStructure parent = new TreeStructure(); //parent.ID = 1; //parent.Child = 1; //parent.Parrent = 1; //parent.OIDName = MibSave[0].Name; //ParentChild.Add(parent); DeviceTreeID = db.TreeStructure.Select(s => s.DeviceID).ToList().LastOrDefault(); for (int j = 0; j < MibSave.Count; j++) { TreeStructure parent = new TreeStructure(); if (j == 0) { //parent.ID = 1; parent.Child = 1; parent.Parrent = 1; DeviceTreeID++; parent.TreeID = DeviceTreeID; parent.DeviceID = DeviceID; parent.OIDName = MibSave[0].Name; ParentChild.Add(parent); } else { var response = Par.Where(r => r.name == MibSave[j].Name).FirstOrDefault(); //parent.ID = j + 1; parent.Child = j + 1; parent.OIDName = response.name; parent.Parrent = response.numb; DeviceTreeID++; parent.TreeID = DeviceTreeID; parent.DeviceID = DeviceID; ParentChild.Add(parent); } db.TreeStructure.Add(parent); //db.SaveChanges(); // shenaxva bazasHi } return(node); } if (node.ChildNodes.Count > 0) { ss++; var expandTree = node; if (ID >= 1) { for (int i = 0; i < node.ChildNodes.Count; i++) { var nodeID = node.ChildNodes[i].Parent; if (nodeID != null) { treeid = MibSave.Where(t => t.Name == nodeID.Text).FirstOrDefault(); SonParent.name = node.ChildNodes[i].Text; SonParent.numb = treeid.ID; Par.Add(SonParent); } } } IDid++; TreeNode child = SearchTreeView(p_sSearchTerm, node.ChildNodes, DeviceID); if (child != null) { return(child); } } else { if (IDid == 0) { IDid = 1; } } } return(null); }
private IEnumerator PlaceGhostRoutine(bool chain) { BuildingTypes bType = this.CurrentBlueprint._type; yield return(null); if (this.CreateMode) { this.ShownPlace = false; this.CreateMode = false; if (!this.ToolsShown) { base.SendMessage("BuildToolsTut"); this.ToolsShown = true; } TreeStructure ts = this._currentGhost.GetComponentInChildren <TreeStructure>(); if (ts && this.TargetTree) { if (this.TargetTree.CompareTag("conTree")) { ts.TreeId = this.TargetTree.parent.GetComponent <TreeHealth>().LodTree.GetComponentInChildren <CoopTreeId>().Id; } else { ts.TreeId = this.TargetTree.GetComponent <TreeHealth>().LodTree.GetComponentInChildren <CoopTreeId>().Id; } ts.enabled = true; if (!BoltNetwork.isRunning) { Scene.ActiveMB.StartCoroutine(ts.OnDeserialized()); } } CoopConstructionEx coopEx = this._currentGhost.GetComponent <CoopConstructionEx>(); WallArchitect wallArch = this.CurrentGhost.GetComponent <WallArchitect>(); ICoopTokenConstruction tokenConstruction = this._currentGhost.GetComponent <ICoopTokenConstruction>(); this.ParentEntity = this.GetParentEntity(this._currentGhost); if (BoltNetwork.isRunning && !wallArch) { BoltEntity component = this._currentGhost.GetComponent <BoltEntity>(); if (tokenConstruction != null) { PlaceFoundationEx placeFoundationEx = PlaceFoundationEx.Create(GlobalTargets.OnlyServer); placeFoundationEx.Position = this._currentGhost.transform.position; placeFoundationEx.Rotation = this._currentGhost.transform.rotation; placeFoundationEx.Prefab = component.prefabId; placeFoundationEx.Token = tokenConstruction.CustomToken; placeFoundationEx.Parent = this.ParentEntity; placeFoundationEx.Send(); UnityEngine.Object.Destroy(this._currentGhost); } else if (coopEx) { coopEx.SendMessage("OnSerializing"); CoopConstructionExToken coopConstructionExToken = this.GetCoopConstructionExToken(coopEx, this.ParentEntity); PlaceFoundationEx placeFoundationEx2 = PlaceFoundationEx.Create(GlobalTargets.OnlyServer); placeFoundationEx2.Parent = this.ParentEntity; placeFoundationEx2.Position = this._currentGhost.transform.position; placeFoundationEx2.Rotation = this._currentGhost.transform.rotation; placeFoundationEx2.Prefab = component.prefabId; placeFoundationEx2.Token = coopConstructionExToken; placeFoundationEx2.Send(); UnityEngine.Object.Destroy(this._currentGhost); } else if (!this._currentGhost.GetComponent(typeof(IAnchorableStructure)) && component) { this._currentGhost.AddComponent <CoopDestroyPredictedGhost>(); this._currentGhost.AddComponent <destroyAfter>().destroyTime = 2f; PlaceConstruction placeConstruction = PlaceConstruction.Create(GlobalTargets.OnlyServer); placeConstruction.Parent = this.ParentEntity; placeConstruction.PrefabId = component.prefabId; placeConstruction.Position = this._currentGhost.transform.position; placeConstruction.Rotation = this._currentGhost.transform.rotation; if (ts) { placeConstruction.TreeIndex = ts.TreeId; } placeConstruction.Send(); this._currentGhost.SendMessage("OnPlacingRemotely", SendMessageOptions.DontRequireReceiver); } else { this._currentGhost.SendMessage("OnPlaced", false, SendMessageOptions.DontRequireReceiver); } } else { this._currentGhost.SendMessage("OnPlaced", false, SendMessageOptions.DontRequireReceiver); this._currentGhost.transform.Find("Trigger").gameObject.SetActive(true); Transform transform = this._currentGhost.transform.Find("LastBuiltLocation"); if (transform) { transform.gameObject.SetActive(true); } if (this.ParentEntity) { DynamicBuilding component2 = this.ParentEntity.GetComponent <DynamicBuilding>(); this._currentGhost.transform.parent = ((!component2 || !component2._parentOverride) ? this.ParentEntity.transform : component2._parentOverride); } } this.ClearReferences(!chain); LocalPlayer.Sfx.PlayPlaceGhost(); this.RefreshGrabber(); yield return(YieldPresets.WaitPointFiveSeconds); if (chain) { this.MultiPlaceAction(bType); } } yield break; }
Dictionary <string, CalculationResult> ICalculator.Calculator(TreeStructure treeStructure) { Dictionary <string, CalculationResult> result = new Dictionary <string, CalculationResult>(); // Register intermidiate results in this dictionary (keyed by node id). // I could have stored this result with the actual tree nodes, but didn't want to "polute" the // tree node class with data that is only relevant to this calculation. Hence put it in a local // dictionary. Dictionary <Guid, ResultPerNode> resultsByNodeIds = new Dictionary <Guid, ResultPerNode>(); // Iterate through the tree structure, starting at the root node. // Iterate through each lines and determine suitable candidates. for (int i = 0; i < treeStructure.Lines.Count; i++) { var line = treeStructure.Lines[i]; foreach (var node in line) { if (node.Parent1OrNull == null && node.Parent2OrNull == null) { // If no parent, then we must be the root ResultPerNode rpn = new ResultPerNode() { NodeId = node.Id, TotalSumSoFar = node.Value, PathSoFar = node.Value.ToString() }; resultsByNodeIds[rpn.NodeId] = rpn; } else { bool didGetValueFromFirstParent = TryGetValueFromParent(node, node.Parent1OrNull, resultsByNodeIds, out var resultFromFirstParent); bool didGetValueFromSecondParent = TryGetValueFromParent(node, node.Parent2OrNull, resultsByNodeIds, out var resultFromSecondParent); ResultPerNode previousResultPerNode = null; if (didGetValueFromFirstParent && didGetValueFromSecondParent) { // There is a good result from both parents, so pick the one with the greatets total value so far. previousResultPerNode = resultFromFirstParent.TotalSumSoFar > resultFromSecondParent.TotalSumSoFar ? resultFromFirstParent : resultFromSecondParent; } else if (didGetValueFromFirstParent) { previousResultPerNode = resultFromFirstParent; } else if (didGetValueFromSecondParent) { previousResultPerNode = resultFromSecondParent; } // This is a good candidate, so let us build a result for this one. if (previousResultPerNode != null) { ResultPerNode rpn = new ResultPerNode() { NodeId = node.Id, TotalSumSoFar = node.Value + previousResultPerNode.TotalSumSoFar, PathSoFar = previousResultPerNode.PathSoFar + " " + node.Value }; resultsByNodeIds[rpn.NodeId] = rpn; } } } } // If there are any results, then it should be found in the last line with the greatest value of TotalSumSoFar. ResultPerNode bestCandidate = null; foreach (var treeNode in treeStructure.Lines[treeStructure.Lines.Count - 1]) { if (resultsByNodeIds.TryGetValue(treeNode.Id, out var candidate)) { #if DEBUG System.Console.WriteLine("Final candidate: " + candidate); #endif if (bestCandidate == null) { bestCandidate = candidate; } else if (candidate.TotalSumSoFar > bestCandidate.TotalSumSoFar) { bestCandidate = candidate; } } } if (bestCandidate != null) { result.Add("Max sum", new CalculationResultInt("Max sum", bestCandidate.TotalSumSoFar)); result.Add("Path", new CalculationResultString("Path", bestCandidate.PathSoFar)); } return(result); }
private void Build() { if (this._type != Create.BuildingTypes.None) { EventRegistry.Player.Publish(TfEvent.BuiltStructure, this._type); this._type = Create.BuildingTypes.None; } if (BoltNetwork.isClient) { if (base.enabled) { base.enabled = false; this.AllOff(); } return; } if (!this._ghost) { this._ghost = base.transform.parent.gameObject; } GameObject gameObject; if (BoltNetwork.isServer) { if (this.entity.attachToken != null) { if (this.entity.attachToken is CoopWallChunkToken) { (this.entity.attachToken as CoopWallChunkToken).Additions = this.entity.GetComponent <WallChunkArchitect>().Addition; } gameObject = BoltNetwork.Instantiate(this.Built, this.entity.attachToken, this._ghost.transform.position, this._ghost.transform.rotation).gameObject; } else { gameObject = BoltNetwork.Instantiate(this.Built, this.entity.attachToken, this._ghost.transform.position, this._ghost.transform.rotation).gameObject; BoltEntity component = gameObject.GetComponent <BoltEntity>(); if (component && component.isAttached && component.StateIs <IMultiHolderState>()) { component.GetState <IMultiHolderState>().IsReal = true; } BoltEntity component2 = gameObject.GetComponent <BoltEntity>(); if (component2 && component.isAttached && component2.StateIs <IRaftState>()) { component2.GetState <IRaftState>().IsReal = true; } } } else { gameObject = (GameObject)UnityEngine.Object.Instantiate(this.Built, this._ghost.transform.position, this._ghost.transform.rotation); } TreeStructure component3 = this._ghost.GetComponent <TreeStructure>(); if (component3) { TreeStructure treeStructure = gameObject.GetComponent <TreeStructure>(); if (!treeStructure) { treeStructure = gameObject.AddComponent <TreeStructure>(); } treeStructure.TreeId = component3.TreeId; } ropeSetGroundHeight component4 = gameObject.GetComponent <ropeSetGroundHeight>(); if (component4) { gameObject.SendMessage("setGroundTriggerHeight", SendMessageOptions.DontRequireReceiver); } if (this._ghost.transform.parent != null) { gameObject.transform.parent = this._ghost.transform.parent; } this.OnBuilt(gameObject); this.OnBuilt = null; base.enabled = false; this._initialized = false; if (this._ghost) { base.StartCoroutine(this.DelayedDestroy()); } else { this.AllOff(); } if (this._playTwinkle && LocalPlayer.Sfx) { LocalPlayer.Sfx.PlayBuildingComplete(gameObject, true); } }