Esempio n. 1
0
            void Awake()
            {
                entity = GetComponent <BaseVehicle>();
                bool    isMini      = entity is MiniCopter;
                bool    isHorse     = entity is RidableHorse;
                Vector3 emptyVector = new Vector3(0, 0, 0);

                if (isMini)
                {
                    _instance.LogDebug("Minicopter detected");
                }
                if (isHorse)
                {
                    _instance.LogDebug("Horse detected");
                }

                if (entity == null)
                {
                    Destroy(this); return;
                }

                BaseVehicle.MountPointInfo pilot = entity.mountPoints[0];
                //entity.mountPoints.Clear();

                if (entity is RidableHorse)
                {
                    _instance.LogDebug("Adding passenger seat");
                    Vector3 horseVector = new Vector3(0f, -0.32f, -0.5f);
                    BaseVehicle.MountPointInfo horseBack = _instance.CreateMount(horseVector, pilot, emptyVector);
                    //entity.mountPoints.Add(pilot);
                    entity.mountPoints.Add(horseBack);
                    entity.SendNetworkUpdateImmediate();
                }

                if (entity is MiniCopter)
                {
                    BaseVehicle.MountPointInfo pFront = entity.mountPoints[1];
                    Vector3 leftVector  = new Vector3(0.6f, 0.2f, -0.2f);
                    Vector3 rightVector = new Vector3(-0.6f, 0.2f, -0.2f);
                    Vector3 backVector  = new Vector3(0.0f, 0.4f, -1.2f);
                    Vector3 backVector2 = new Vector3(0.0f, 0.4f, -1.45f);

                    Vector3    playerOffsetVector = new Vector3(0f, 0f, -0.25f);
                    Quaternion backQuaternion     = Quaternion.Euler(0f, 180f, 0f);

                    if (_instance.config.EnableMiniSideSeats)
                    {
                        _instance.LogDebug("Adding side seats");
                        BaseVehicle.MountPointInfo pLeftSide  = _instance.CreateMount(leftVector, pFront, emptyVector);
                        BaseVehicle.MountPointInfo pRightSide = _instance.CreateMount(rightVector, pFront, emptyVector);
                        entity.mountPoints.Add(pLeftSide);
                        entity.mountPoints.Add(pRightSide);
                        _instance.AddSeat(entity, leftVector + playerOffsetVector, new Quaternion());
                        _instance.AddSeat(entity, rightVector + playerOffsetVector, new Quaternion());
                    }

                    if (_instance.config.EnableMiniBackSeat)
                    {
                        _instance.LogDebug("Adding back/rotor seat");
                        BaseVehicle.MountPointInfo pBackReverse = _instance.CreateMount(backVector2, pFront, new Vector3(0f, 180f, 0f));
                        entity.mountPoints.Add(pBackReverse);
                        _instance.AddSeat(entity, backVector, backQuaternion);
                    }
                }
            }