Basic universe management, generation and simulation flow
This commit is contained in:
parent
4c078dbede
commit
78fceeb95e
29 changed files with 664 additions and 29 deletions
|
|
@ -1,41 +0,0 @@
|
|||
using System.Collections.Generic;
|
||||
using Godot;
|
||||
|
||||
public partial class VesselNode : RigidBody3D
|
||||
{
|
||||
public Vessel VesselData = new();
|
||||
public List<VesselModuleNode> Modules = [];
|
||||
|
||||
public override void _Ready()
|
||||
{
|
||||
VesselModuleNode moduleBridge = InstantiateModule("test_module_bridge");
|
||||
VesselModuleNode moduleCombined = InstantiateModule("test_module_combined");
|
||||
VesselModuleNode moduleEngine1 = InstantiateModule("test_module_engine");
|
||||
VesselModuleNode moduleEngine2 = InstantiateModule("test_module_engine");
|
||||
|
||||
CallDeferred(nameof(AttachModule), moduleBridge, moduleCombined, "TestModuleBridge_AnchorBack", "TestModuleCombined_AnchorFront");
|
||||
CallDeferred(nameof(AttachModule), moduleBridge, moduleEngine1, "TestModuleBridge_AnchorLeft", "TestModuleEngine_AnchorRight");
|
||||
CallDeferred(nameof(AttachModule), moduleBridge, moduleEngine2, "TestModuleBridge_AnchorRight", "TestModuleEngine_AnchorLeft");
|
||||
}
|
||||
|
||||
private VesselModuleNode InstantiateModule(string moduleName)
|
||||
{
|
||||
PackedScene modulePrefab = ResourceLoader.Load<PackedScene>($"res://prefabs/modules/{moduleName}.tscn");
|
||||
VesselModuleNode moduleInstance = modulePrefab.Instantiate<VesselModuleNode>();
|
||||
|
||||
CallDeferred("add_child", moduleInstance);
|
||||
|
||||
VesselData.Modules.Add(moduleInstance.ModuleData);
|
||||
Modules.Add(moduleInstance);
|
||||
|
||||
return moduleInstance;
|
||||
}
|
||||
|
||||
private void AttachModule(VesselModuleNode attachToModule, VesselModuleNode newModule, string existingAnchorName, string newAnchorName)
|
||||
{
|
||||
Node3D existingAnchor = attachToModule.GetAnchor(existingAnchorName);
|
||||
Node3D newAnchor = newModule.GetAnchor(newAnchorName);
|
||||
|
||||
newModule.GlobalTransform = existingAnchor.GlobalTransform * newAnchor.Transform.AffineInverse();
|
||||
}
|
||||
}
|
||||
Loading…
Add table
Add a link
Reference in a new issue