private void BtnOk_OnPressed(XUiController _sender, OnPressEventArgs _onPressEventArgs) { string text = this.txtPassword.Text; float code = 0f; StringParsers.TryParseFloat(text, out code); myEntity.Buffs.AddCustomVar("PathingCode", code); SphereCache.RemovePaths(myEntity.entityId); EntityUtilities.GetNewPositon(myEntity.entityId); EntityUtilities.SetCurrentOrder(myEntity.entityId, EntityUtilities.Orders.Wander); GameManager.ShowTooltip(base.xui.playerUI.entityPlayer, "Pathing Code Set"); base.xui.playerUI.windowManager.Close(base.WindowGroup.ID); }
public void SetupAutoPathingBlocks() { if (this.Buffs.HasCustomVar("PathingCode")) { return; } // Check if pathing blocks are defined. List <string> Blocks = EntityUtilities.ConfigureEntityClass(this.entityId, "PathingBlocks"); if (Blocks.Count == 0) { Blocks = new List <string>() { "PathingCube" } } ; //Scan for the blocks in the area List <Vector3> PathingVectors = ModGeneralUtilities.ScanForTileEntityInChunksListHelper(this.position, Blocks, this.entityId); if (PathingVectors == null || PathingVectors.Count == 0) { return; } // Find the nearest block, and if its a sign, read its code. Vector3 target = ModGeneralUtilities.FindNearestBlock(this.position, PathingVectors); TileEntitySign tileEntitySign = GameManager.Instance.World.GetTileEntity(0, new Vector3i(target)) as TileEntitySign; if (tileEntitySign == null) { return; } // Since signs can have multiple codes, splite with a ,, parse each one. String text = tileEntitySign.GetText(); float code = 0f; // Defined here as DMT compiler doesn't like inlining it. foreach (String temp in text.Split(',')) { if (StringParsers.TryParseFloat(temp, out code)) { this.Buffs.AddCustomVar("PathingCode", code); return; } } }