Пример #1
0
        public void UpdateWeaponRotation(UpdateEvent e, WeaponNode weapon, [JoinByTank] TankNode tank)
        {
            WeaponVisualRootComponent weaponVisualRoot = weapon.weaponVisualRoot;
            WeaponInstanceComponent   weaponInstance   = weapon.weaponInstance;

            weaponVisualRoot.transform.SetLocalRotationSafe(weaponInstance.WeaponInstance.transform.localRotation);
            weaponVisualRoot.transform.SetLocalPositionSafe(Vector3.zero);
        }
Пример #2
0
        public void AttachDetachedWeapon(NodeRemoveEvent e, TankNode tank, [JoinByTank, Context] TankIncarnationNode incornation, [JoinByTank] DetachedWeaponNode weapon)
        {
            this.StopCollide(weapon.weaponDetachCollider);
            WeaponVisualRootComponent weaponVisualRoot = weapon.weaponVisualRoot;

            weaponVisualRoot.transform.SetParent(tank.visualMountPoint.MountPoint, false);
            weaponVisualRoot.transform.localRotation = Quaternion.identity;
            weaponVisualRoot.transform.localPosition = Vector3.zero;
            this.StopCollide(weapon.weaponDetachCollider);
            weaponVisualRoot.VisualTriggerMarker.VisualTriggerMeshCollider.enabled = true;
            weapon.Entity.RemoveComponentIfPresent <DetachedWeaponComponent>();
        }
        public void LocateWeaponVisualRootUnderMountPoint(NodeAddedEvent evt, TankGraphicsNode tank, [Context, JoinByTank] WeaponGraphicsNode weaponGraphics)
        {
            WeaponVisualRootComponent weaponVisualRoot = weaponGraphics.weaponVisualRoot;

            weaponVisualRoot.transform.parent = tank.tankVisualRoot.transform;
            Transform  mountPoint = tank.mountPoint.MountPoint;
            GameObject obj2       = new GameObject("VisualMountPoint");

            obj2.transform.SetParent(tank.tankVisualRoot.transform, false);
            obj2.transform.localPosition = mountPoint.localPosition;
            obj2.transform.localRotation = mountPoint.localRotation;
            VisualMountPointComponent component = new VisualMountPointComponent {
                MountPoint = obj2.transform
            };

            tank.Entity.AddComponent(component);
            weaponVisualRoot.transform.SetParent(obj2.transform, false);
            weaponVisualRoot.transform.localPosition = Vector3.zero;
            weaponVisualRoot.transform.localRotation = Quaternion.identity;
            this.InitCharacterShadowSystem(tank.Entity, tank.tankVisualRoot.transform, weaponGraphics.weaponVisualRoot.transform);
            base.NewEvent <ContinueAssembleTankEvent>().Attach(tank).ScheduleDelayed(0.3f);
        }
Пример #4
0
        private Rigidbody DetachWeapon(TankNode tank, UnblockedWeaponNode weapon)
        {
            Rigidbody rigidbody = tank.rigidbody.Rigidbody;
            WeaponVisualRootComponent     weaponVisualRoot     = weapon.weaponVisualRoot;
            WeaponDetachColliderComponent weaponDetachCollider = weapon.weaponDetachCollider;
            GameObject gameObject = weapon.weaponVisualRoot.gameObject;

            if (weapon.Entity.HasComponent <DetachedWeaponComponent>())
            {
                return(rigidbody);
            }
            gameObject.transform.parent = tank.assembledTank.AssemblyRoot.transform;
            gameObject.layer            = Layers.TANK_AND_STATIC;
            weaponVisualRoot.VisualTriggerMarker.VisualTriggerMeshCollider.enabled = false;
            MeshCollider collider = weaponDetachCollider.Collider;

            collider.enabled = true;
            Rigidbody rigidbody2 = weaponDetachCollider.Rigidbody;
            Bounds    bounds     = collider.sharedMesh.bounds;
            Vector3   center     = bounds.center;

            center.z = 0f;
            this.SetInertiaTensor(rigidbody2, bounds.size, center);
            rigidbody2.mass = rigidbody.mass / 10f;
            rigidbody2.maxAngularVelocity       = rigidbody.maxAngularVelocity;
            rigidbody2.maxDepenetrationVelocity = 0f;
            rigidbody2.angularDrag = 2f;
            rigidbody2.drag        = 0f;
            rigidbody2.SetVelocitySafe(rigidbody.velocity);
            rigidbody2.SetAngularVelocitySafe(rigidbody.angularVelocity);
            rigidbody2.interpolation    = RigidbodyInterpolation.Interpolate;
            rigidbody2.isKinematic      = false;
            rigidbody2.detectCollisions = true;
            weapon.Entity.AddComponent <DetachedWeaponComponent>();
            return(rigidbody2);
        }