public void MoveToSocket(SocketStateChangeMessage message)
        {
            var qsbSocket = QSBWorldSync.GetWorldFromId <QSBQuantumSocket>(message.SocketId);

            if (qsbSocket == null)
            {
                DebugLog.ToConsole($"Couldn't find socket id {message.SocketId}", MessageType.Error);
                return;
            }
            var socket = qsbSocket.AttachedObject;

            if (socket == null)
            {
                DebugLog.ToConsole($"QSBSocket id {message.SocketId} has no attached socket.", MessageType.Error);
                return;
            }

            var wasEntangled = AttachedObject.IsPlayerEntangled();
            var component    = Locator.GetPlayerTransform().GetComponent <OWRigidbody>();
            var location     = new RelativeLocationData(Locator.GetPlayerTransform().GetComponent <OWRigidbody>(), AttachedObject.transform);

            AttachedObject.GetType().GetMethod("MoveToSocket", BindingFlags.Instance | BindingFlags.NonPublic).Invoke(AttachedObject, new object[] { socket });

            if (wasEntangled)
            {
                component.MoveToRelativeLocation(location, AttachedObject.transform);
            }

            if (QuantumManager.Instance.Shrine != AttachedObject)
            {
                AttachedObject.transform.localRotation = message.LocalRotation;
            }
            else
            {
                var playerToShrine = QSBPlayerManager.GetPlayer(message.FromId).Body.transform.position - AttachedObject.transform.position;
                var projectOnPlace = Vector3.ProjectOnPlane(playerToShrine, AttachedObject.transform.up);
                var angle          = OWMath.Angle(AttachedObject.transform.forward, projectOnPlace, AttachedObject.transform.up);
                angle = OWMath.RoundToNearestMultiple(angle, 120f);
                AttachedObject.transform.rotation = Quaternion.AngleAxis(angle, AttachedObject.transform.up) * AttachedObject.transform.rotation;
            }
        }
Esempio n. 2
0
        private ICommand ResolveCommand()
        {
            var command = Command;

            if (null != command)
            {
                return(command);
            }

            if (null != AttachedObject)
            {
                var type     = AttachedObject.GetType().GetTypeInfo();
                var property = type.GetDeclaredProperty(CommandName);

                if (null != property && typeof(ICommand).GetTypeInfo().IsAssignableFrom(property.PropertyType.GetTypeInfo()))
                {
                    command = (ICommand)property.GetValue(AttachedObject);
                }
            }

            return(command);
        }
 public override void Init(QuantumSocket quantumSocket, int id)
 {
     ObjectId       = id;
     AttachedObject = quantumSocket;
     AttachedObject.GetType().SetValue("_randomYRotation", false);
 }
Esempio n. 4
0
 public void StartRoasting()
 => AttachedObject
 .GetType()
 .GetMethod("StartRoasting", BindingFlags.NonPublic | BindingFlags.Instance)
 .Invoke(AttachedObject, null);