public override void _Ready() { tree = GetTree(); title = GetNode <VBoxContainer>("TitleScreen"); start = GetNode <HBoxContainer>("StartGame"); options = GetNode <HBoxContainer>("Options"); }
public override void Execute(string[] args) { if (args == null || args.Length != 1) { DisplayUsage(); } else { var name = args[0]; if (name == "list") { DisplayCommandList(); } else { var command = Console.SupportedCommands.FirstOrDefault(c => c.Key == name); if (command == null) { var message = string.Format(SceneTree.Tr("console.error.command.invalid"), name); Console.Warning(message).NewLine(); } else { command.DisplayUsage(); } } } }
public override void ExecuteCmd(string szContent, ref GenContext Context, ref ArrayList Output, ref Object Tag) { base.ExecuteCmd(szContent, ref Context, ref Output, ref Tag); if (!(Tag is SceneTree)) { throw new Exception("Translate::ExecuteCmd:The last parameter must be a SceneTree instance"); } SceneTree sct = (SceneTree)Tag; int iPos = -1; string szPar1 = GenContext.GetFirstParam(szContent, ref iPos, ','); //x string szPar2 = GenContext.GetNextParam(szContent, ref iPos, ','); //y string szPar3 = GenContext.GetNextParam(szContent, ref iPos, ','); //z string szPar4 = GenContext.GetNextParam(szContent, ref iPos, ','); //keyname if (GenContext.GetNextParam(szContent, ref iPos, ',') != "") { throw new Exception("Translate:Invalid argument list."); } Object3D ob = sct.GetObject3D(Context.EvalText(szPar4)); if (ob == null) { throw new Exception("Translate:Object " + szPar4 + " does not exist!"); } float x = (float)Context.EvalFloat(szPar1); float y = (float)Context.EvalFloat(szPar2); float z = (float)Context.EvalFloat(szPar3); ob.Translate(x, y, z); }
public void InitSpawnPoints() { SceneTree st = GetTree(); object[] actorSpawns = st.GetNodesInGroup("ActorSpawnPoint"); this.actorSpawnPoints = new List <Vector3>(); for (int i = 0; i < actorSpawns.Length; i++) { Spatial spawnPoint = actorSpawns[i] as Spatial; if (spawnPoint != null) { this.actorSpawnPoints.Add(spawnPoint.GetGlobalTransform().origin); } } object[] itemSpawns = st.GetNodesInGroup("ItemSpawnPoint"); this.itemSpawnPoints = new List <Vector3>(); for (int i = 0; i < itemSpawns.Length; i++) { Spatial spawnPoint = itemSpawns[i] as Spatial; if (spawnPoint != null) { this.itemSpawnPoints.Add(spawnPoint.GetGlobalTransform().origin); } } }
public static void SetField(string[] args) { if (args.Length != 3) { Log.WriteLine("Expected field name, instance ref (uuid or path), and value"); return; } object instanceRef; ulong id = ulong.MaxValue; if (ulong.TryParse(args[1], out id)) { instanceRef = SceneTree.GetCurrent().GetNode(id); } else { instanceRef = SceneTree.GetCurrent().GetNode(args[1]); } if (instanceRef == null) { Log.WriteError("Could not find node by " + (id == ulong.MaxValue ? "name" : "id") + " '" + args[1] + "'"); return; } string objectName = instanceRef.GetType().Name; objectName = objectName.Remove(0, objectName.LastIndexOf('.') + 1); ObjectDatabase.Global.SetField(objectName, args[0], instanceRef, args[2]); Log.WriteLine(args[1] + "." + args[0] + ": value=" + args[2]); }
public static T Get(string autoload, string propertyName) //Find property of an autoload { SceneTree tree = (SceneTree)Engine.GetMainLoop(); Node root = tree.EditedSceneRoot; return((T)root.GetNode(autoload).Get(propertyName)); }
/// <summary> /// Initializes a new instance of the <see cref="LayerSceneNode"/> class. /// </summary> /// <param name="sceneTree">The <see cref="SceneTreeView"/> where the tree node will be used.</param> /// <param name="value">The layer.</param> public LayerSceneNode(SceneTreeView sceneTree, Layer value) : base(sceneTree, value) { Value.ListChanged += new ObservableList <Actor> .ListChangedEventHandler(Value_ListChanged); foreach (Actor actor in Value) { Nodes.Add(SceneTree.CreateNodeByType(actor)); } if (value.IsParallax) { if (layerParallaxIcon == null) { layerParallaxIcon = Properties.Resources.layerParallax; } Image = layerParallaxIcon; } else { if (layerIcon == null) { layerIcon = Properties.Resources.layer; } Image = layerIcon; } }
public static IEnumerable <T> GetNodesInGroup <T>([NotNull] this SceneTree sceneTree, [NotNull] string group) { Ensure.Any.IsNotNull(sceneTree, nameof(sceneTree)); Ensure.Any.IsNotNull(group, nameof(group)); return(sceneTree.GetNodesInGroup(group).OfType <T>()); }
public TestRunner(SceneTree sceneTree, bool requireTestFixture = true) { this.sceneTree = sceneTree; this.requireTestFixture = requireTestFixture; IterateThroughAssemblies(); }
public override void _Ready() { SceneTree root = GetTree(); _player = root.CurrentScene.GetNode <Player>("Player"); PlayerIsInLOS(); }
public static void LoadLevel(SceneTree tree, string levelName) { GD.Print($"Loading level {levelName}"); CurrentLevel = levelName; tree.ChangeSceneTo(LevelProxyFactory); }
public static NetObjectVariant GetNetworkVariant(this SceneTree tree, int ownerPeerId) { return(tree.GetNetworkMode() == NetworkMode.Server ? NetObjectVariant.Server : ownerPeerId == tree.GetNetworkUniqueId() ? NetObjectVariant.LocalAuthoritative : NetObjectVariant.LocalPuppet); }
public static NetworkMode GetNetworkMode(this SceneTree tree) { if (!tree.HasNetworkPeer()) { return(NetworkMode.None); } return(tree.IsNetworkServer() ? NetworkMode.Server : NetworkMode.Client); }
protected ConsoleCommand([NotNull] ICommandConsole console, SceneTree sceneTree) { Ensure.Any.IsNotNull(console, nameof(console)); Ensure.Any.IsNotNull(sceneTree, nameof(sceneTree)); Console = console; SceneTree = sceneTree; }
protected ConsoleCommand(ICommandConsole console, SceneTree sceneTree) { Ensure.That(console, nameof(console)).IsNotNull(); Ensure.That(sceneTree, nameof(sceneTree)).IsNotNull(); Console = console; SceneTree = sceneTree; }
public static Vector2 RandPosition(ref Node2D node, SceneTree sceneTree) { Vector2 resolution = sceneTree.Root.GetVisibleRect().Size; random.Randomize(); return(node.GlobalPosition = new Vector2(random.RandfRange(0f, resolution.x), random.RandfRange(0f, resolution.y))); }
// Called when the node enters the scene tree for the first time. public override void _Ready() { rand = new RandomNumberGenerator(); MainLoop loop = Engine.GetMainLoop(); SceneTree mainTree = (SceneTree)loop; RootView = mainTree.Root; }
public override void _Ready() { tree = GetTree(); crosshair = GetNode <CenterContainer>("Crosshair"); pause = GetNode <Control>("Pause"); options = GetNode <Options>("Options"); voxel_world = GetNode <VoxelWorld>("../VoxelWorld"); }
/// <summary> /// Searches the scene tree for a single node with the given group. /// </summary> public static Node GetNodeInGroup(this SceneTree tree, string name) { try { return((Node)tree.GetNodesInGroup(name)[0]); } catch (IndexOutOfRangeException) { GD.PrintErr($"Node '{name}' could not be found."); throw; } }
public void Quit() { SceneTree tree = GetTree(); if (tree != null) { tree.Quit(); } }
public override void ExecuteCmd(string szContent, ref GenContext Context, ref ArrayList Output, ref Object Tag) { base.ExecuteCmd(szContent, ref Context, ref Output, ref Tag); if (!(Tag is SceneTree)) { throw new Exception("ExtrudeZCommand::ExecuteCmd:The last parameter must be a SceneTree instance"); } SceneTree sct = (SceneTree)Tag; int iPos = -1; string szPar1 = GenContext.GetFirstParam(szContent, ref iPos, ','); //SourceKeyname string szPar2 = GenContext.GetNextParam(szContent, ref iPos, ','); //z string szPar3 = GenContext.GetNextParam(szContent, ref iPos, ','); //nLat string szPar4 = GenContext.GetNextParam(szContent, ref iPos, ','); //Type abs/rel string szPar5 = GenContext.GetNextParam(szContent, ref iPos, ','); //TargetKeyname float z = (float)Convert.ToDouble(szPar2); if (Convert.ToInt32(szPar3) < 2) { throw new Exception("ExtrudeZCommand:nLat must greater than 1 to create mayesurface"); } if (GenContext.GetNextParam(szContent, ref iPos, ',') != "") { throw new Exception("ExtrudeZCommand:Invalid argument list."); } int iCount = sct.m_Object3DList.Count + 1; if (szPar5 == "") { szPar5 = "\"ExtrudeZ" + iCount.ToString() + "\""; } Object3D ob = sct.GetObject3D(Context.EvalText(szPar1)); MayeArc arc = null; MayeSurface mayesurf = null; if (!(ob is MayeArc)) { throw new Exception("ExtrudeZCommand::ExecuteCmd:Only a MayeArc object can be extruded"); } //sct.DeleteObject3D(ref ob); Object3D tob = sct.GetObject3D(Context.EvalText(szPar5)); if (tob != null) { throw new Exception("ExtrudeZCommand:ExecuteCmd:Cannot extrude in a existing target object."); } arc = (MayeArc)ob; mayesurf = new MayeSurface(Convert.ToInt32(szPar3), arc.m_nLong, ob.m_Color, Context.EvalText(szPar5), false); // mayeLine = new Line3D(new Vector3(x1, y1, z1 ), new Vector3(x2, y2, z2), Convert.ToInt32(szPar7), System.Drawing.Color.FromArgb(Int32.Parse(szPar8, System.Globalization.NumberStyles.HexNumber)), szPar10, false); arc.ExtrudeZ(z, 0, ref mayesurf); Scene3D sc = (Scene3D)sct.m_MainSceneNode.m_Scene3DRef; sct.AddObject3D(sc.m_Keyname, mayesurf); }
public static void applyAllSettings(SceneTree tree) { var panel = tree.Root.FindNode("TouchPanel", owned: false) as TouchPanel; if (panel != null) { panel.Configure(); } }
// Declare member variables here. Examples: // private int a = 2; // private string b = "text"; // Called when the node enters the scene tree for the first time. public override void _Ready() { GD.Print(GetParent().Name); SceneTree root = GetTree(); Global.Destinations = root.CurrentScene.GetNode <Node2D>("GuardNavigation/LevelDestinations"); Global.GlobalNavigation2D = root.CurrentScene.GetNode <Navigation2D>("GuardNavigation"); Global.GlobalRandom = new Random(); }
public void Initialize(Godot.SceneTree tree) { SceneTree = tree ?? throw new ArgumentNullException(nameof(tree)); WorldRoot = new Godot.Node2D { Name = "WorldRoot" }; SceneTree.GetRoot().AddChild(WorldRoot); }
static public T FindNode <T>(SceneTree tree) where T : Node { T node = tree.Root.FindNode(typeof(T).Name, true, false) as T; if (node == null) { throw new Exception("Could not find node with name: " + typeof(T).Name); } return(node); }
public override void _Ready() { _tree = GetTree(); _playButton = GetNode <Button>("Menu/PlayButton"); _exitButton = GetNode <Button>("Menu/ExitButton"); _playButton.Connect("pressed", this, nameof(OnPlay)); _exitButton.Connect("pressed", this, nameof(OnExitGame)); }
public static void ResetGame(SceneTree tree) { var oldInstance = GameData.Instance; GameData.Instance = null; GameData newData = (GameData)((PackedScene)GD.Load("res://Nodes/GameData.tscn")).Instance(); tree.Root.AddChild(newData); }
public void InitSpawnPoints() { SceneTree st = GetTree(); playerSpawnPoints = GetSpawnPoints("PlayerSpawnPoint"); enemySpawnPoints = GetSpawnPoints("EnemySpawnPoint"); itemSpawnPoints = GetSpawnPoints("ItemSpawnPoint"); usedEnemySpawnPoints = new List <Vector3>(); }
private void deferredGoToScene(string path, string extra) { currentScene.Free(); PackedScene s = (PackedScene)ResourceLoader.Load(path, extra); currentScene = s.Instance(); SceneTree sT = GetTree(); sT.GetRoot().AddChild(currentScene); sT.SetCurrentScene(currentScene); }
/// <summary> /// Gets the peer ID from the game session, 1 for server or 0 for standalone /// </summary> /// <returns>The peer id</returns> public static int GetPeerId() { SceneTree Tree = GetTree(); if (Tree != null && Tree.HasNetworkPeer()) { return(GetTree().GetNetworkUniqueId()); } return(0); }