Пример #1
0
 /// <summary>
 ///
 /// </summary>
 protected override void RegisterComponent()
 {
     this.ParentEnvironment = NeodroidUtilities.MaybeRegisterNamedComponent(
         (PrototypingEnvironment)this.ParentEnvironment,
         (Configurable)this,
         this._vel_x);
     this.ParentEnvironment = NeodroidUtilities.MaybeRegisterNamedComponent(
         (PrototypingEnvironment)this.ParentEnvironment,
         (Configurable)this,
         this._vel_y);
     this.ParentEnvironment = NeodroidUtilities.MaybeRegisterNamedComponent(
         (PrototypingEnvironment)this.ParentEnvironment,
         (Configurable)this,
         this._vel_z);
     this.ParentEnvironment = NeodroidUtilities.MaybeRegisterNamedComponent(
         (PrototypingEnvironment)this.ParentEnvironment,
         (Configurable)this,
         this._ang_x);
     this.ParentEnvironment = NeodroidUtilities.MaybeRegisterNamedComponent(
         (PrototypingEnvironment)this.ParentEnvironment,
         (Configurable)this,
         this._ang_y);
     this.ParentEnvironment = NeodroidUtilities.MaybeRegisterNamedComponent(
         (PrototypingEnvironment)this.ParentEnvironment,
         (Configurable)this,
         this._ang_z);
 }
Пример #2
0
 /// <inheritdoc />
 /// <summary>
 /// </summary>
 protected override void RegisterComponent()
 {
     this.ParentEnvironment = NeodroidUtilities.RegisterComponent(
         (PrototypingEnvironment)this.ParentEnvironment,
         (Configurable)this,
         this._mesh_str);
 }
Пример #3
0
        /// <summary>
        ///
        /// </summary>
        protected override void RegisterComponent()
        {
            this.ParentActor = NeodroidUtilities.MaybeRegisterComponent((Actor)this.ParentActor, (Motor)this);

            this.ParentActor = NeodroidUtilities.MaybeRegisterNamedComponent(
                (Actor)this.ParentActor,
                (Motor)this,
                this._x);
            this.ParentActor = NeodroidUtilities.MaybeRegisterNamedComponent(
                (Actor)this.ParentActor,
                (Motor)this,
                this._y);
            this.ParentActor = NeodroidUtilities.MaybeRegisterNamedComponent(
                (Actor)this.ParentActor,
                (Motor)this,
                this._z);
            this.ParentActor = NeodroidUtilities.MaybeRegisterNamedComponent(
                (Actor)this.ParentActor,
                (Motor)this,
                this._rot_x);
            this.ParentActor = NeodroidUtilities.MaybeRegisterNamedComponent(
                (Actor)this.ParentActor,
                (Motor)this,
                this._rot_y);
            this.ParentActor = NeodroidUtilities.MaybeRegisterNamedComponent(
                (Actor)this.ParentActor,
                (Motor)this,
                this._rot_z);
        }
Пример #4
0
        /// <inheritdoc />
        /// <summary>
        /// </summary>
        protected override void Setup()
        {
            if (this._fog_density_curve == null)
            {
                this._fog_density_curve = NeodroidUtilities.DefaultAnimationCurve();
            }

            if (this._fog_gradient == null)
            {
                this._fog_gradient = NeodroidUtilities.DefaultGradient();
            }

            if (this._light_gradient == null)
            {
                this._light_gradient = NeodroidUtilities.DefaultGradient();
            }

            this._light             = this.GetComponent <Light>();
            this._sky_mat           = RenderSettings.skybox;
            this.transform.rotation = this._start_rotation;
            if (!this._particle_system)
            {
                this._particle_system = this.GetComponent <ParticleSystem>();
            }

            this._particle_system.Pause();
            if (this._particles == null || this._particles.Length < this._particle_system.main.maxParticles)
            {
                this._particles = new ParticleSystem.Particle[this._particle_system.main.maxParticles];
            }
        }
 /// <inheritdoc />
 /// <summary>
 /// </summary>
 protected override void RegisterComponent()
 {
     this.ParentEnvironment = NeodroidUtilities.RegisterComponent(
         (PrototypingEnvironment)this.ParentEnvironment,
         (Configurable)this,
         this._x);
     this.ParentEnvironment = NeodroidUtilities.RegisterComponent(
         (PrototypingEnvironment)this.ParentEnvironment,
         (Configurable)this,
         this._y);
     this.ParentEnvironment = NeodroidUtilities.RegisterComponent(
         (PrototypingEnvironment)this.ParentEnvironment,
         (Configurable)this,
         this._z);
     this.ParentEnvironment = NeodroidUtilities.RegisterComponent(
         (PrototypingEnvironment)this.ParentEnvironment,
         (Configurable)this,
         this._rx);
     this.ParentEnvironment = NeodroidUtilities.RegisterComponent(
         (PrototypingEnvironment)this.ParentEnvironment,
         (Configurable)this,
         this._ry);
     this.ParentEnvironment = NeodroidUtilities.RegisterComponent(
         (PrototypingEnvironment)this.ParentEnvironment,
         (Configurable)this,
         this._rz);
     this.ParentEnvironment = NeodroidUtilities.RegisterComponent(
         (PrototypingEnvironment)this.ParentEnvironment,
         (Configurable)this,
         this._rw);
 }
Пример #6
0
 protected override void AddToEnvironment()
 {
     this._vel_x            = this.ConfigurableIdentifier + "VelX";
     this._vel_y            = this.ConfigurableIdentifier + "VelY";
     this._vel_z            = this.ConfigurableIdentifier + "VelZ";
     this._ang_x            = this.ConfigurableIdentifier + "AngX";
     this._ang_y            = this.ConfigurableIdentifier + "AngY";
     this._ang_z            = this.ConfigurableIdentifier + "AngZ";
     this.ParentEnvironment = NeodroidUtilities.MaybeRegisterNamedComponent(
         this.ParentEnvironment,
         (ConfigurableGameObject)this,
         this._vel_x);
     this.ParentEnvironment = NeodroidUtilities.MaybeRegisterNamedComponent(
         this.ParentEnvironment,
         (ConfigurableGameObject)this,
         this._vel_y);
     this.ParentEnvironment = NeodroidUtilities.MaybeRegisterNamedComponent(
         this.ParentEnvironment,
         (ConfigurableGameObject)this,
         this._vel_z);
     this.ParentEnvironment = NeodroidUtilities.MaybeRegisterNamedComponent(
         this.ParentEnvironment,
         (ConfigurableGameObject)this,
         this._ang_x);
     this.ParentEnvironment = NeodroidUtilities.MaybeRegisterNamedComponent(
         this.ParentEnvironment,
         (ConfigurableGameObject)this,
         this._ang_y);
     this.ParentEnvironment = NeodroidUtilities.MaybeRegisterNamedComponent(
         this.ParentEnvironment,
         (ConfigurableGameObject)this,
         this._ang_z);
 }
Пример #7
0
 /// <summary>
 /// </summary>
 protected override void RegisterComponent()
 {
     this.ParentEnvironment = NeodroidUtilities.RegisterComponent(
         (PrototypingEnvironment)this.ParentEnvironment,
         (Configurable)this,
         this._quality_level);
     this.ParentEnvironment = NeodroidUtilities.RegisterComponent(
         (PrototypingEnvironment)this.ParentEnvironment,
         (Configurable)this,
         this._target_frame_rate);
     this.ParentEnvironment = NeodroidUtilities.RegisterComponent(
         (PrototypingEnvironment)this.ParentEnvironment,
         (Configurable)this,
         this._width);
     this.ParentEnvironment = NeodroidUtilities.RegisterComponent(
         (PrototypingEnvironment)this.ParentEnvironment,
         (Configurable)this,
         this._height);
     this.ParentEnvironment = NeodroidUtilities.RegisterComponent(
         (PrototypingEnvironment)this.ParentEnvironment,
         (Configurable)this,
         this._fullscreen);
     this.ParentEnvironment = NeodroidUtilities.RegisterComponent(
         (PrototypingEnvironment)this.ParentEnvironment,
         (Configurable)this,
         this._time_scale);
 }
Пример #8
0
 /// <inheritdoc />
 ///  <summary>
 ///  </summary>
 protected override void RegisterComponent()
 {
     this.ParentActor = NeodroidUtilities.MaybeRegisterComponent(
         (Actor)this.ParentActor,
         this,
         only_parents: true);
 }
Пример #9
0
 protected override void AddToEnvironment()
 {
     this._quality_level     = this.ConfigurableIdentifier + "QualityLevel";
     this._target_frame_rate = this.ConfigurableIdentifier + "TargetFrameRate";
     this._time_scale        = this.ConfigurableIdentifier + "TimeScale";
     this._width             = this.ConfigurableIdentifier + "Width";
     this._height            = this.ConfigurableIdentifier + "Height";
     this._fullscreen        = this.ConfigurableIdentifier + "Fullscreen";
     this.ParentEnvironment  = NeodroidUtilities.MaybeRegisterNamedComponent(
         this.ParentEnvironment,
         (ConfigurableGameObject)this,
         this._quality_level);
     this.ParentEnvironment = NeodroidUtilities.MaybeRegisterNamedComponent(
         this.ParentEnvironment,
         (ConfigurableGameObject)this,
         this._target_frame_rate);
     this.ParentEnvironment = NeodroidUtilities.MaybeRegisterNamedComponent(
         this.ParentEnvironment,
         (ConfigurableGameObject)this,
         this._width);
     this.ParentEnvironment = NeodroidUtilities.MaybeRegisterNamedComponent(
         this.ParentEnvironment,
         (ConfigurableGameObject)this,
         this._height);
     this.ParentEnvironment = NeodroidUtilities.MaybeRegisterNamedComponent(
         this.ParentEnvironment,
         (ConfigurableGameObject)this,
         this._fullscreen);
     this.ParentEnvironment = NeodroidUtilities.MaybeRegisterNamedComponent(
         this.ParentEnvironment,
         (ConfigurableGameObject)this,
         this._time_scale);
 }
Пример #10
0
        // Use this for initialization
        void Start()
        {
            if (!this._graspable_object)
            {
                this._graspable_object = this.GetComponent <GraspableObject>();
            }

            if (!this._gripper)
            {
                this._gripper = FindObjectOfType <ScriptedGripper>();
            }

            this._grasp            = this._graspable_object.GetOptimalGrasp(this._gripper).First;
            this._rigid_body       = this._grasp.GetComponentInParent <Rigidbody>();
            this._rigid_bodies     = this._graspable_object.GetComponentsInChildren <Rigidbody>();
            this._initial_position = this._rigid_body.transform.position;
            this._initial_rotation = this._rigid_body.transform.rotation;

            NeodroidUtilities.RegisterCollisionTriggerCallbacksOnChildren(
                this,
                this.transform,
                this.OnCollisionEnterChild,
                this.OnTriggerEnterChild,
                this.OnCollisionExitChild,
                this.OnTriggerExitChild,
                this.OnCollisionStayChild,
                this.OnTriggerStayChild,
                this._debugging);
        }
Пример #11
0
        /// <inheritdoc />
        ///  <summary>
        ///  </summary>
        protected override void RegisterComponent()
        {
            this._x = this.Identifier + "X_";
            this._y = this.Identifier + "Y_";
            this._z = this.Identifier + "Z_";
            if (this._Angular_Motors)
            {
                this._x = this.Identifier + "RotX_";
                this._y = this.Identifier + "RotY_";
                this._z = this.Identifier + "RotZ_";
            }

            this.ParentActor = NeodroidUtilities.MaybeRegisterNamedComponent(
                (Actor)this.ParentActor,
                (Motor)this,
                this._x);
            this.ParentActor = NeodroidUtilities.MaybeRegisterNamedComponent(
                (Actor)this.ParentActor,
                (Motor)this,
                this._y);
            this.ParentActor = NeodroidUtilities.MaybeRegisterNamedComponent(
                (Actor)this.ParentActor,
                (Motor)this,
                this._z);
        }
Пример #12
0
 /// <inheritdoc />
 /// <summary>
 /// </summary>
 protected override void RegisterComponent()
 {
     this.ParentEnvironment = NeodroidUtilities.RegisterComponent(
         (PrototypingEnvironment)this.ParentEnvironment,
         (Configurable)this,
         this._shadow_strength);
     this.ParentEnvironment = NeodroidUtilities.RegisterComponent(
         (PrototypingEnvironment)this.ParentEnvironment,
         (Configurable)this,
         this._color_r);
     this.ParentEnvironment = NeodroidUtilities.RegisterComponent(
         (PrototypingEnvironment)this.ParentEnvironment,
         (Configurable)this,
         this._color_b);
     this.ParentEnvironment = NeodroidUtilities.RegisterComponent(
         (PrototypingEnvironment)this.ParentEnvironment,
         (Configurable)this,
         this._color_g);
     this.ParentEnvironment = NeodroidUtilities.RegisterComponent(
         (PrototypingEnvironment)this.ParentEnvironment,
         (Configurable)this,
         this._intensity);
     this.ParentEnvironment = NeodroidUtilities.RegisterComponent(
         (PrototypingEnvironment)this.ParentEnvironment,
         (Configurable)this,
         this._indirect_multiplier);
 }
Пример #13
0
        protected override void PostSetup()
        {
            if (!this._goal)
            {
                this._goal = FindObjectOfType <EmptyCell>();
            }

            if (!this._actor)
            {
                this._actor = FindObjectOfType <Actor>();
            }

            if (this._goal)
            {
                NeodroidUtilities.RegisterCollisionTriggerCallbacksOnChildren(
                    this,
                    this._goal.transform,
                    null,
                    this.OnTriggerEnterChild,
                    debug: this.Debugging);
            }

            if (this._actor)
            {
                NeodroidUtilities.RegisterCollisionTriggerCallbacksOnChildren(
                    this,
                    this._actor.transform,
                    null,
                    this.OnTriggerEnterChild,
                    debug: this.Debugging);
            }
        }
Пример #14
0
 /// <inheritdoc />
 /// <summary>
 /// </summary>
 protected override void RegisterComponent()
 {
     if (this._Simulation_Manager != null)
     {
         this._Simulation_Manager = NeodroidUtilities.RegisterComponent(
             (PausableManager)this._Simulation_Manager,
             this);
     }
 }
Пример #15
0
        /// <inheritdoc />
        /// <summary>
        /// </summary>
        protected override void RegisterComponent()
        {
            this.ParentEnvironment = NeodroidUtilities.RegisterComponent(
                (PrototypingEnvironment)this.ParentEnvironment,
                this,
                _Cam_Obs_Identifier);

            this.ParentEnvironment = NeodroidUtilities.RegisterComponent(
                (PrototypingEnvironment)this.ParentEnvironment,
                this,
                _Seg_Obs_Identifier);
        }
Пример #16
0
 void Setup()
 {
     if (this._motors == null)
     {
         this._motors = new Dictionary <string, Motor>();
     }
     if (this._environment != null)
     {
         this._environment.UnRegisterActor(this.ActorIdentifier);
     }
     this.ParentEnvironment = NeodroidUtilities.MaybeRegisterComponent(this.ParentEnvironment, this);
 }
Пример #17
0
 void SetupEnvironment() {
   NeodroidUtilities.RegisterCollisionTriggerCallbacksOnChildren(
       this,
       this.transform,
       this.OnCollisionEnterChild,
       this.OnTriggerEnterChild,
       this.OnCollisionExitChild,
       this.OnTriggerExitChild,
       this.OnCollisionStayChild,
       this.OnTriggerStayChild,
       this._debugging);
 }
Пример #18
0
 void OnDrawGizmosSelected()
 {
     if (this.DrawNames)
     {
         if (this._current_goal)
         {
             NeodroidUtilities.DrawString(this._current_goal.name,
                                          this._current_goal.transform.position,
                                          Color.green);
         }
     }
 }
Пример #19
0
        /// <inheritdoc />
        ///  <summary>
        ///  </summary>
        protected override void RegisterComponent()
        {
            this._Parent_Environment = NeodroidUtilities.MaybeRegisterComponent(
                (PrototypingEnvironment)this._Parent_Environment,
                this);

            if (this._Parent_Environment != null)
            {
                this._Parent_Environment.PreStepEvent  += this.PreStep;
                this._Parent_Environment.StepEvent     += this.Step;
                this._Parent_Environment.PostStepEvent += this.PostStep;
            }
        }
Пример #20
0
 protected override void AddToEnvironment()
 {
     this._x                = this.ConfigurableIdentifier + "X";
     this._y                = this.ConfigurableIdentifier + "Y";
     this._z                = this.ConfigurableIdentifier + "Z";
     this._dir_x            = this.ConfigurableIdentifier + "DirX";
     this._dir_y            = this.ConfigurableIdentifier + "DirY";
     this._dir_z            = this.ConfigurableIdentifier + "DirZ";
     this._rot_x            = this.ConfigurableIdentifier + "RotX";
     this._rot_y            = this.ConfigurableIdentifier + "RotY";
     this._rot_z            = this.ConfigurableIdentifier + "RotZ";
     this.ParentEnvironment = NeodroidUtilities.MaybeRegisterComponent(
         this.ParentEnvironment,
         (ConfigurableGameObject)this);
     this.ParentEnvironment = NeodroidUtilities.MaybeRegisterNamedComponent(
         this.ParentEnvironment,
         (ConfigurableGameObject)this,
         this._x);
     this.ParentEnvironment = NeodroidUtilities.MaybeRegisterNamedComponent(
         this.ParentEnvironment,
         (ConfigurableGameObject)this,
         this._y);
     this.ParentEnvironment = NeodroidUtilities.MaybeRegisterNamedComponent(
         this.ParentEnvironment,
         (ConfigurableGameObject)this,
         this._z);
     this.ParentEnvironment = NeodroidUtilities.MaybeRegisterNamedComponent(
         this.ParentEnvironment,
         (ConfigurableGameObject)this,
         this._dir_x);
     this.ParentEnvironment = NeodroidUtilities.MaybeRegisterNamedComponent(
         this.ParentEnvironment,
         (ConfigurableGameObject)this,
         this._dir_y);
     this.ParentEnvironment = NeodroidUtilities.MaybeRegisterNamedComponent(
         this.ParentEnvironment,
         (ConfigurableGameObject)this,
         this._dir_z);
     this.ParentEnvironment = NeodroidUtilities.MaybeRegisterNamedComponent(
         this.ParentEnvironment,
         (ConfigurableGameObject)this,
         this._rot_x);
     this.ParentEnvironment = NeodroidUtilities.MaybeRegisterNamedComponent(
         this.ParentEnvironment,
         (ConfigurableGameObject)this,
         this._rot_y);
     this.ParentEnvironment = NeodroidUtilities.MaybeRegisterNamedComponent(
         this.ParentEnvironment,
         (ConfigurableGameObject)this,
         this._rot_z);
 }
Пример #21
0
        void CalcPositonsAndDrawBoxes()
        {
            foreach (var mesh_filter_object in this._mesh_filter_objects)
            {
                if (mesh_filter_object.gameObject.tag == "Target")
                {
                    GameObject liner;
                    if (!this._lines.ContainsKey(mesh_filter_object.gameObject))
                    {
                        liner = Instantiate(this._line_object, this._line_object.transform);
                        this._lines.Add(mesh_filter_object.gameObject, liner);
                    }
                    else
                    {
                        print("found Target");
                        liner = this._lines[mesh_filter_object.gameObject];
                    }

                    var bounds = mesh_filter_object.mesh.bounds;

                    //Bounds bounds;
                    //BoxCollider bc = GetComponent<BoxCollider>();
                    //if (bc != null)
                    //    bounds = bc.bounds;
                    //else
                    //return;

                    var v3Center  = bounds.center;
                    var v3Extents = bounds.extents;

                    var corners = NeodroidUtilities.ExtractCorners(v3Center, v3Extents, mesh_filter_object.transform);

                    liner.GetComponent <LineRenderer>().SetPosition(0, corners[4]);
                    liner.GetComponent <LineRenderer>().SetPosition(1, corners[5]);

                    NeodroidUtilities.DrawBox(
                        corners[0],
                        corners[1],
                        corners[2],
                        corners[3],
                        corners[4],
                        corners[5],
                        corners[6],
                        corners[7],
                        this.color);
                }
            }
        }
Пример #22
0
 void Start()
 {
     this.InnerPreStart();
     if (!this._time_simulation_manager)
     {
         this._time_simulation_manager = FindObjectOfType <NeodroidManager>();
     }
     if (!this._objective_function)
     {
         this._objective_function = FindObjectOfType <ObjectiveFunction>();
     }
     this._time_simulation_manager = NeodroidUtilities.MaybeRegisterComponent(
         this._time_simulation_manager,
         (NeodroidEnvironment)this);
     this.SaveInitialPoses();
     this.StartCoroutine(this.SaveInitialBodiesIE());
 }
Пример #23
0
        protected override void PostSetup()
        {
            if (!this._area)
            {
                this._area = FindObjectOfType <Observer>().gameObject.GetComponent <Collider>();
            }

            if (!this._actor)
            {
                this._actor = FindObjectOfType <Actor>();
            }

            if (this._obstructions.Length <= 0)
            {
                this._obstructions = FindObjectsOfType <Obstruction>();
            }

            if (!this._playable_area)
            {
                this._playable_area = FindObjectOfType <BoundingBox>();
            }

            NeodroidUtilities.RegisterCollisionTriggerCallbacksOnChildren(
                this,
                this._area.transform,
                null,
                this.OnTriggerEnterChild,
                null,
                this.OnTriggerExitChild,
                null,
                this.OnTriggerStayChild,
                this.Debugging);

            NeodroidUtilities.RegisterCollisionTriggerCallbacksOnChildren(
                this,
                this._actor.transform,
                null,
                this.OnTriggerEnterChild,
                null,
                this.OnTriggerExitChild,
                null,
                this.OnTriggerStayChild,
                this.Debugging);
            this._wait_for_seconds = new WaitForSeconds(this._resting_time);
        }
Пример #24
0
        /// <inheritdoc />
        /// <summary>
        ///
        /// </summary>
        protected override void Setup()
        {
            this._grid = new int[this._width, this._height];

            var k = 0;

            for (var i = 0; i < this._width; i++)
            {
                for (var j = 0; j < this._height; j++)
                {
                    this._grid[i, j] = k++;
                }
            }

            this._time_simulation_manager = (IManager)NeodroidUtilities.MaybeRegisterComponent(
                (NeodroidManager)this._time_simulation_manager,
                this);
        }
Пример #25
0
 void OnDrawGizmosSelected()
 {
     if (this._draw_levels)
     {
         var i   = 0;
         var len = this._curriculum.Levels.Length;
         foreach (var level in this._curriculum.Levels)
         {
             if (level.configurable_entries != null && level.configurable_entries.Length > 0)
             {
                 var frac = i++ / (float)len;
                 foreach (var entry in level.configurable_entries)
                 {
                     var configurable = GameObject.Find(entry.configurable_name);
                     if (configurable != null)
                     {
                         Gizmos.color = new Color(frac, 0, 1 - frac, 0.1F);
                         Gizmos.DrawSphere(configurable.transform.position, entry.MaxValue);
                         Gizmos.color = new Color(1, 1, 1, 0.4F);
                         Gizmos.DrawWireSphere(configurable.transform.position, entry.MaxValue);
                         var pos_up = configurable.transform.position;
                         pos_up.y += entry.MaxValue;
                         NeodroidUtilities.DrawString(i.ToString(), pos_up, new Color(1, 1, 1, 1));
                         var pos_left = configurable.transform.position;
                         pos_left.x += entry.MaxValue;
                         NeodroidUtilities.DrawString(i.ToString(), pos_left, new Color(1, 1, 1, 1));
                         var pos_forward = configurable.transform.position;
                         pos_forward.z += entry.MaxValue;
                         NeodroidUtilities.DrawString(i.ToString(), pos_forward, new Color(1, 1, 1, 1));
                         var pos_down = configurable.transform.position;
                         pos_down.y -= entry.MaxValue;
                         NeodroidUtilities.DrawString(i.ToString(), pos_down, new Color(1, 1, 1, 1));
                         var pos_right = configurable.transform.position;
                         pos_right.x -= entry.MaxValue;
                         NeodroidUtilities.DrawString(i.ToString(), pos_right, new Color(1, 1, 1, 1));
                         var pos_backward = configurable.transform.position;
                         pos_backward.z -= entry.MaxValue;
                         NeodroidUtilities.DrawString(i.ToString(), pos_backward, new Color(1, 1, 1, 1));
                     }
                 }
             }
         }
     }
 }
Пример #26
0
        /// <summary>
        /// </summary>
        void SaveInitialPoses()
        {
            var ignored_layer = LayerMask.NameToLayer("IgnoredByNeodroid");

            if (this._track_only_children)
            {
                this._tracked_game_objects =
                    NeodroidUtilities.RecursiveChildGameObjectsExceptLayer(this.transform, ignored_layer);
            }
            else
            {
                this._tracked_game_objects = NeodroidUtilities.FindAllGameObjectsExceptLayer(ignored_layer);
            }

            var length = this._tracked_game_objects.Length;

            this._reset_positions = new Vector3[length];
            this._reset_rotations = new Quaternion[length];
            this._poses           = new Transform[length];
            for (var i = 0; i < length; i++)
            {
                var go    = this._tracked_game_objects[i];
                var trans = go.transform;
                this._reset_positions[i] = trans.position;
                this._reset_rotations[i] = trans.rotation;
                this._poses[i]           = trans;
                var maybe_joint = go.GetComponent <Joint>();
                if (maybe_joint != null)
                {
                    var maybe_joint_fix = maybe_joint.GetComponent <JointFix>();
                    if (maybe_joint_fix == null)
                    {
                        // ReSharper disable once RedundantAssignment
                        maybe_joint_fix = maybe_joint.gameObject.AddComponent <JointFix>();
                    }
          #if NEODROID_DEBUG
                    if (this.Debugging)
                    {
                        Debug.Log($"Added a JointFix component to {maybe_joint_fix.name}");
                    }
          #endif
                }
            }
        }
Пример #27
0
        public override void RegisterComponent()
        {
            this._x = this.MotorIdentifier + "X";
            this._y = this.MotorIdentifier + "Y";
            this._z = this.MotorIdentifier + "Z";
            if (this._rotational_motors)
            {
                this._x = this.MotorIdentifier + "RotX";
                this._y = this.MotorIdentifier + "RotY";
                this._z = this.MotorIdentifier + "RotZ";
            }

            this.ParentActor =
                NeodroidUtilities.MaybeRegisterNamedComponent(this.ParentActor, (Motor)this, this._x);
            this.ParentActor =
                NeodroidUtilities.MaybeRegisterNamedComponent(this.ParentActor, (Motor)this, this._y);
            this.ParentActor =
                NeodroidUtilities.MaybeRegisterNamedComponent(this.ParentActor, (Motor)this, this._z);
        }
Пример #28
0
        void MaybeDestroy(Rigidbody rb, Rigidbody other = null)
        {
            var val = 0f;

            if (rb != null)
            {
                val = NeodroidUtilities.KineticEnergy(rb);
            }

            var val_other = 0f;

            if (other != null)
            {
                val_other = NeodroidUtilities.KineticEnergy(rb);
            }

            if (this.Debugging)
            {
                Debug.Log($"{val} {val_other}");
            }

            if ((val >= this._Threshold || val_other >= this._Threshold) && !this._has_exploded)
            {
                this._Actor.Kill();
                this._has_exploded = true;

                /*if (this._explosion_particle_system) {
                 * this._explosion_particle_system.Play();
                 * this._delay = this._explosion_particle_system.main.duration;
                 * }*/

                this.StartCoroutine(
                    this.SpawnBroken(
                        this._delay,
                        this._Rigidbody.transform.parent,
                        this._Rigidbody.transform.position,
                        this._Rigidbody.transform.rotation,
                        this._Rigidbody.velocity,
                        this._Rigidbody.angularVelocity));
                this._Rigidbody.gameObject.SetActive(false);
                this._Rigidbody.Sleep();
            }
        }
Пример #29
0
 /// <inheritdoc />
 /// <summary>
 /// </summary>
 protected override void RegisterComponent()
 {
     this.ParentEnvironment = NeodroidUtilities.RegisterComponent(
         (PrototypingEnvironment)this.ParentEnvironment,
         (Configurable)this,
         this._r);
     this.ParentEnvironment = NeodroidUtilities.RegisterComponent(
         (PrototypingEnvironment)this.ParentEnvironment,
         (Configurable)this,
         this._texture);
     this.ParentEnvironment = NeodroidUtilities.RegisterComponent(
         (PrototypingEnvironment)this.ParentEnvironment,
         (Configurable)this,
         this._reflection);
     this.ParentEnvironment = NeodroidUtilities.RegisterComponent(
         (PrototypingEnvironment)this.ParentEnvironment,
         (Configurable)this,
         this._smoothness);
 }
Пример #30
0
        void Start()
        {
            if (!this._rigidbody)
            {
                this._rigidbody = this.GetComponent <Rigidbody> ();
            }
            this._explosion = this.GetComponent <ParticleSystem> ();

            NeodroidUtilities.RegisterCollisionTriggerCallbacksOnChildren(
                this,
                this._rigidbody.transform,
                this.ChildOnCollisionEnter,
                this.ChildOnTriggerEnter,
                null,
                null,
                null,
                null,
                this.Debugging);
        }