Exemple #1
0
    public override void _Ready()
    {
        Target = GetNode(ActivatableTargetNodePath) as IActivatable;            // Note: Could be null!

        CSGBox = GetNode <CSGBox>(CSGNodePath);
        SetColour(NotPressedColor);
    }
 private void _initialize(float _totalTime = 0.0f)
 {
     timePassed = 0.0f;
     if (_totalTime >= 0.1f)
     {
         this.totalTime = _totalTime;
     }
     startPosition = this.GetNodeOrNull <Spatial>("StartPosition");
     endPosition   = this.GetNodeOrNull <Spatial>("EndPosition");
     geometryModel = this.GetNodeOrNull <CSGBox>("Geometry");
     startVector   = startPosition.Translation;
     endVector     = endPosition.Translation;
     GD.Print($"Platform, _initialize() called, geometry={geometryModel}");
     if (geometryModel != null)
     {
         geometryModel.Visible = true;
         if (currentTarget == Target.end)
         {
             directionVector           = endVector - startVector;
             geometryModel.Translation = startVector;
         }
         else
         {
             directionVector           = startVector - endVector;
             geometryModel.Translation = endVector;
         }
         initialPosition = geometryModel.Translation;
     }
 }
 // Called when the node enters the scene tree for the first time.
 public override void _Ready()
 {
     desksound                = Globals.engine.loadSound("sounds/desk.ogg");
     surface                  = GetNode <CSGBox>("surface");
     deskinstance             = desksound.play3d(Transform.origin.x, Transform.origin.y, Transform.origin.z, loopMode.simpleLoop);
     deskinstance.maxDistance = 50;
     deskinstance.minDistance = 0.1f;
 }
Exemple #4
0
    // Called when the node enters the scene tree for the first time.
    public override void _Ready()
    {
        Spatial spatial = GetTree().Root.GetChild(0) as Spatial;

        if (spatial is null)
        {
            throw new NullReferenceException("Failed to find Spatial node");
        }

        List <CSGSphere>  spheres      = new List <CSGSphere>();
        ImmediateGeometry lineRenderer = null;

        foreach (Node node in spatial.GetChildren())
        {
            Type   type = node.GetType();
            string name = node.Name;

            if (type == typeof(CSGSphere) && name.StartsWith("Sphere"))
            {
                spheres.Add(node as CSGSphere);
            }
            else if (type == typeof(CSGBox) && name.Equals("Cube"))
            {
                cube = node as CSGBox;
            }
            else if (type == typeof(ImmediateGeometry) && name.Equals("LineRenderer"))
            {
                lineRenderer = node as ImmediateGeometry;
            }
        }

        if (spheres.Count < 2)
        {
            throw new NullReferenceException("Failed to find at least two Spheres");
        }

        if (cube is null)
        {
            throw new NullReferenceException("Failed to find Cube");
        }

        if (lineRenderer is null)
        {
            throw new NullReferenceException("Failed to find LineRenderer");
        }

        List <Vector3> sphereOrigins = spheres.Select(sphere => sphere.Transform.origin).ToList();

        if (doLoop)
        {
            sphereOrigins.Add(sphereOrigins[0]);
        }

        points = sphereOrigins.ToArray();

        lineRenderer.Set("globalCoords", false);
        lineRenderer.Set("points", points);
    }
        public void OnSceneGUI(SceneView sceneView, Rect dragArea)
        {
            Bounds    bounds;
            CSGModel  modelBeneathCursor;
            Matrix4x4 transformation;
            float     height;

            var flags = (generateFromCenterXZ ? BoxExtrusionFlags.GenerateFromCenterXZ : BoxExtrusionFlags.None);

            switch (BoxExtrusionHandle.Do(dragArea, out bounds, out height, out modelBeneathCursor, out transformation, flags, Axis.Y))
            {
            case BoxExtrusionState.Create:
            {
                box = BrushMeshAssetFactory.Create <CSGBox>("Box",
                                                            BrushMeshAssetFactory.GetModelForNode(modelBeneathCursor),
                                                            transformation);
                box.Operation = forceOperation ?? CSGOperationType.Additive;
                box.Bounds    = bounds;
                box.UpdateGenerator();
                break;
            }

            case BoxExtrusionState.Modified:
            {
                box.Operation = forceOperation ??
                                ((height < 0 && modelBeneathCursor) ?
                                 CSGOperationType.Subtractive :
                                 CSGOperationType.Additive);
                box.Bounds = bounds;
                break;
            }

            case BoxExtrusionState.Commit:
            {
                UnityEditor.Selection.activeGameObject = box.gameObject;
                Reset();
                CSGEditModeManager.EditMode = CSGEditMode.ShapeEdit;
                break;
            }

            case BoxExtrusionState.Cancel:
            {
                Reset();
                Undo.RevertAllInCurrentGroup();
                EditorGUIUtility.ExitGUI();
                break;
            }

            case BoxExtrusionState.BoxMode:
            case BoxExtrusionState.SquareMode:      { CSGOutlineRenderer.VisualizationMode = VisualizationMode.SimpleOutline; break; }

            case BoxExtrusionState.HoverMode:       { CSGOutlineRenderer.VisualizationMode = VisualizationMode.Outline; break; }
            }

            HandleRendering.RenderBox(transformation, bounds);
        }
Exemple #6
0
 public override void OnSetup()
 {
     base.OnSetup();
     target = GetParent() as CSGBox;
 }
Exemple #7
0
 public override void _Ready() // Called when the node enters the scene tree for the first time.
 {
     global         = GetNode <Global>("/root/Global");
     collisionShape = GetNode <CollisionShape>("CollisionShape");
     box            = GetNode <CSGBox>("CSGBox");
 }
Exemple #8
0
 public override void OnSetup()
 {
     base.OnSetup();
     body            = GetParent() as CSGBox;
     initialPosition = body.Translation;
 }
 public override void _Ready()
 {
     box             = GetNodeOrNull <CSGBox>("LagTest");
     start_pos       = box.Translation;
     ProcessPriority = 1;
 }
Exemple #10
0
 public LineFollow3D(Node parent = default, slice <Vector3> points = default, bool doLoop = default, CSGBox cube = default, float speed = default, float currentDistance = default, slice <float> lineDistances = default)
 {
     this.parent          = parent;
     this.points          = points;
     this.doLoop          = doLoop;
     this.cube            = cube;
     this.speed           = speed;
     this.currentDistance = currentDistance;
     this.lineDistances   = lineDistances;
 }