Esempio n. 1
0
        public unsafe void DroneMovement(FixedUpdateEvent e, DroneNode drone)
        {
            DroneOwnerComponent      droneOwner      = drone.droneOwner;
            Rigidbody                body            = drone.rigidbody.Rigidbody;
            DroneMoveConfigComponent droneMoveConfig = drone.droneMoveConfig;

            if (droneOwner.Incarnation.Alive && droneOwner.Rigidbody)
            {
                this.ApplyMovingForce(body, droneMoveConfig, droneOwner);
            }
            Rigidbody rigidbody = drone.rigidbody.Rigidbody;

            this.ApplyStabilization(rigidbody);
            Rigidbody rigidbody3 = null;

            if (drone.Entity.HasComponent <UnitTargetComponent>())
            {
                Entity target = drone.Entity.GetComponent <UnitTargetComponent>().Target;
                if (target.HasComponent <RigidbodyComponent>())
                {
                    rigidbody3 = target.GetComponent <RigidbodyComponent>().Rigidbody;
                }
            }
            if (rigidbody3 != null)
            {
                Vector3  position   = rigidbody3.position;
                Vector3 *vectorPtr1 = &position;
                vectorPtr1->y += 0.5f;
                this.ApplyTargetingForce(rigidbody, (position - rigidbody.position).normalized);
            }
            else if (droneOwner.Incarnation.Alive && droneOwner.Rigidbody)
            {
                this.ApplyTargetingForce(rigidbody, (droneOwner.Rigidbody.transform.forward - (Vector3.up * 0.5f)).normalized);
            }
        }
Esempio n. 2
0
        public void Instantiate(NodeAddedEvent e, SingleNode <PreloadedModuleEffectsComponent> mapEffect, SingleNode <MapInstanceComponent> map, [Combine] DroneLoadedNode drone, [Context, JoinByUser] TankNode tank, [JoinByTank] SingleNode <TankIncarnationComponent> incarnation, [JoinByUser] Optional <SingleNode <UserAvatarComponent> > avatar)
        {
            string     str      = (!avatar.IsPresent() || (avatar.Get().component.Id != "457e8f5f-953a-424c-bd97-67d9e116ab7a")) ? "drone" : "droneHolo";
            GameObject original = mapEffect.component.PreloadedEffects[str];

            if (original)
            {
                GameObject gameObject = Object.Instantiate <GameObject>(original, null);
                gameObject.SetActive(true);
                Rigidbody          rigidbody = gameObject.GetComponent <Rigidbody>();
                RigidbodyComponent component = new RigidbodyComponent {
                    Rigidbody = rigidbody
                };
                drone.Entity.AddComponent(component);
                rigidbody.GetComponent <EntityBehaviour>().BuildEntity(drone.Entity);
                DroneOwnerComponent component2 = new DroneOwnerComponent {
                    Incarnation = incarnation.Entity,
                    Rigidbody   = tank.rigidbody.Rigidbody
                };
                drone.Entity.AddComponent(component2);
                drone.Entity.AddComponent(new EffectInstanceComponent(gameObject));
            }
        }
Esempio n. 3
0
        private void ApplyMovingForce(Rigidbody body, DroneMoveConfigComponent config, DroneOwnerComponent owner)
        {
            Vector3 vector3   = (owner.Rigidbody.transform.position + config.FlyPosition) - body.position;
            float   magnitude = vector3.magnitude;
            Vector3 vector4   = vector3 / magnitude;

            if (magnitude > 1f)
            {
                body.AddForceSafe(vector4 * Mathf.Clamp(magnitude * config.Acceleration, 0f, config.MoveSpeed));
            }
        }