public override void OnReceiveRemote(bool server, SocketItemMessage message)
        {
            var socketWorldObject = QSBWorldSync.GetWorldFromId <IQSBOWItemSocket>(message.SocketId);
            var itemWorldObject   = QSBWorldSync.GetWorldFromId <IQSBOWItem>(message.ItemId);

            switch (message.SocketType)
            {
            case SocketEventType.Socket:
                socketWorldObject.PlaceIntoSocket(itemWorldObject);
                return;

            case SocketEventType.StartUnsocket:
                if (!socketWorldObject.IsSocketOccupied())
                {
                    DebugLog.ToConsole($"Warning - Trying to start unsocket on socket that is unoccupied! Socket:{(socketWorldObject as IWorldObject).Name}");
                    return;
                }
                socketWorldObject.RemoveFromSocket();
                return;

            case SocketEventType.CompleteUnsocket:
                itemWorldObject.OnCompleteUnsocket();
                return;
            }
        }
Exemplo n.º 2
0
 public override void OnReceiveRemote(bool server, SetAsTranslatedMessage message)
 {
     if (!QSBCore.HasWokenUp)
     {
         return;
     }
     if (message.EnumValue == NomaiTextType.WallText)
     {
         var obj = QSBWorldSync.GetWorldFromId <QSBWallText>(message.ObjectId);
         obj.HandleSetAsTranslated(message.TextId);
     }
     else if (message.EnumValue == NomaiTextType.Computer)
     {
         var obj = QSBWorldSync.GetWorldFromId <QSBComputer>(message.ObjectId);
         obj.HandleSetAsTranslated(message.TextId);
     }
     else if (message.EnumValue == NomaiTextType.VesselComputer)
     {
         var obj = QSBWorldSync.GetWorldFromId <QSBVesselComputer>(message.ObjectId);
         obj.HandleSetAsTranslated(message.TextId);
     }
     else
     {
         throw new System.NotImplementedException($"TextType <{message.EnumValue}> not implemented.");
     }
 }
        public override void OnReceiveRemote(bool server, WorldObjectMessage message)
        {
            var       player     = QSBPlayerManager.GetPlayer(message.AboutId);
            var       itemObject = QSBWorldSync.GetWorldFromId <IQSBOWItem>(message.ObjectId);
            var       itemType   = itemObject.GetItemType();
            Transform itemSocket = null;

            switch (itemType)
            {
            case ItemType.Scroll:
                itemSocket = player.ScrollSocket;
                break;

            case ItemType.SharedStone:
                itemSocket = player.SharedStoneSocket;
                break;

            case ItemType.WarpCore:
                itemSocket = ((QSBWarpCoreItem)itemObject).IsVesselCoreType()
                                                ? player.VesselCoreSocket
                                                : player.WarpCoreSocket;
                break;

            default:
                itemSocket = player.ItemSocket;
                break;
            }
            itemObject.PickUpItem(itemSocket, message.AboutId);
        }
Exemplo n.º 4
0
		public override void OnReceiveLocal(bool server, MultiStateChangeMessage message)
		{
			if (!QSBCore.DebugMode)
			{
				return;
			}
			var qsbObj = QSBWorldSync.GetWorldFromId<QSBMultiStateQuantumObject>(message.ObjectId);
			qsbObj.DebugBoxText.text = message.StateIndex.ToString();
		}
Exemplo n.º 5
0
        public override void OnReceiveRemote(bool server, BoolWorldObjectMessage message)
        {
            if (!QSBCore.HasWokenUp)
            {
                return;
            }
            var geyser = QSBWorldSync.GetWorldFromId <QSBGeyser>(message.ObjectId);

            geyser?.SetState(message.State);
        }
        public override void Deserialize(QNetworkReader reader)
        {
            base.Deserialize(reader);
            ObjectId = reader.ReadInt32();
            Position = reader.ReadVector3();
            Normal   = reader.ReadVector3();
            var sectorId = reader.ReadInt32();

            Sector = QSBWorldSync.GetWorldFromId <QSBSector>(sectorId).AttachedObject;
        }
Exemplo n.º 7
0
        public override void OnReceiveRemote(bool server, QuantumShuffleMessage message)
        {
            if (!QSBCore.HasWokenUp)
            {
                return;
            }
            var obj = QSBWorldSync.GetWorldFromId <QSBQuantumShuffleObject>(message.ObjectId);

            obj.ShuffleObjects(message.IndexArray);
        }
Exemplo n.º 8
0
        public override void OnReceiveRemote(bool server, EnumWorldObjectMessage <Campfire.State> message)
        {
            if (!QSBSceneManager.IsInUniverse)
            {
                return;
            }

            var campfireObj = QSBWorldSync.GetWorldFromId <QSBCampfire>(message.ObjectId);

            campfireObj.SetState(message.EnumValue);
        }
        public override void OnReceiveRemote(bool server, QuantumAuthorityMessage message)
        {
            var obj = QSBWorldSync.GetWorldFromId <IQSBQuantumObject>(message.ObjectId);

            obj.ControllingPlayer = message.AuthorityOwner;
            if (obj.ControllingPlayer == 0 && obj.IsEnabled)
            {
                // object has no owner, but is still active for this player. request ownership
                QSBEventManager.FireEvent(EventNames.QSBQuantumAuthority, message.ObjectId, QSBPlayerManager.LocalPlayerId);
            }
        }
        public override void OnReceiveRemote(bool server, WorldObjectMessage message)
        {
            var player = QSBPlayerManager.GetPlayer(message.AboutId);

            if (message.ObjectId == -1)
            {
                player.EntangledObject = null;
                return;
            }
            var quantumObject = QSBWorldSync.GetWorldFromId <IQSBQuantumObject>(message.ObjectId);

            player.EntangledObject = quantumObject;
        }
Exemplo n.º 11
0
		public override void OnReceiveRemote(bool server, MultiStateChangeMessage message)
		{
			if (!QSBCore.HasWokenUp)
			{
				return;
			}
			var qsbObj = QSBWorldSync.GetWorldFromId<QSBMultiStateQuantumObject>(message.ObjectId);
			if (qsbObj.ControllingPlayer != message.FromId)
			{
				DebugLog.ToConsole($"Error - Got MultiStateChangeEvent for {qsbObj.Name} from {message.FromId}, but it's currently controlled by {qsbObj.ControllingPlayer}!", MessageType.Error);
				return;
			}
			qsbObj.ChangeState(message.StateIndex);
		}
Exemplo n.º 12
0
        public override void OnReceiveRemote(bool server, SocketStateChangeMessage message)
        {
            if (!QSBCore.HasWokenUp)
            {
                return;
            }
            var obj = QSBWorldSync.GetWorldFromId <QSBSocketedQuantumObject>(message.ObjectId);

            if (obj.ControllingPlayer != message.FromId)
            {
                DebugLog.ToConsole($"Error - Got SocketStateChangeEvent for {obj.Name} from {message.FromId}, but it's currently controlled by {obj.ControllingPlayer}!", MessageType.Error);
                return;
            }
            obj.MoveToSocket(message);
        }
        public override void OnReceiveRemote(bool server, WorldObjectMessage message)
        {
            if (!QSBSceneManager.IsInUniverse)
            {
                return;
            }
            var sector = QSBWorldSync.GetWorldFromId <QSBSector>(message.ObjectId);

            if (sector == null)
            {
                DebugLog.ToConsole($"Sector with index id {message.ObjectId} not found!", MessageType.Warning);
                return;
            }

            var transformSync = QSBPlayerManager.GetSyncObject <TransformSync.TransformSync>(message.AboutId);

            QSBCore.UnityEvents.RunWhen(() => transformSync?.SyncedTransform != null,
                                        () => transformSync?.SetReferenceSector(sector));
        }
        public override bool CheckMessage(bool isServer, QuantumAuthorityMessage message)
        {
            if (!QuantumManager.Instance.IsReady)
            {
                return(false);
            }

            var obj = QSBWorldSync.GetWorldFromId <IQSBQuantumObject>(message.ObjectId);

            // Deciding if to change the object's owner
            //		  Message
            //	   | = 0 | > 0 |
            // = 0 | No  | Yes |
            // > 0 | Yes | No  |
            // if Obj==Message then No
            // Obj

            return((obj.ControllingPlayer == 0 || message.AuthorityOwner == 0) &&
                   (obj.ControllingPlayer != message.AuthorityOwner));
        }
        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;
            }
        }
Exemplo n.º 16
0
        public override void OnReceiveRemote(bool server, BoolWorldObjectMessage message)
        {
            if (!QSBCore.HasWokenUp)
            {
                return;
            }
            if (message.State && message.ObjectId == -1)
            {
                DebugLog.ToConsole($"Error - Null campfire supplied for start roasting event!", OWML.Common.MessageType.Error);
                return;
            }
            var player = QSBPlayerManager.GetPlayer(message.AboutId);

            player.RoastingStick.SetActive(message.State);
            if (message.State)
            {
                player.Campfire = QSBWorldSync.GetWorldFromId <QSBCampfire>(message.ObjectId);
            }
            else
            {
                player.Campfire = null;
            }
        }
Exemplo n.º 17
0
        public void OnGUI()
        {
            if (!DebugMode)
            {
                return;
            }

            var offset = 10f;

            GUI.Label(new Rect(220, 10, 200f, 20f), $"FPS : {Mathf.Round(1f / Time.smoothDeltaTime)}");
            offset += _debugLineSpacing;
            GUI.Label(new Rect(220, offset, 200f, 20f), $"HasWokenUp : {HasWokenUp}");
            offset += _debugLineSpacing;
            if (WakeUpSync.LocalInstance != null)
            {
                GUI.Label(new Rect(220, offset, 200f, 20f), $"Time Difference : {WakeUpSync.LocalInstance.GetTimeDifference()}");
                offset += _debugLineSpacing;
                GUI.Label(new Rect(220, offset, 200f, 20f), $"Timescale : {OWTime.GetTimeScale()}");
                offset += _debugLineSpacing;
            }

            if (!HasWokenUp)
            {
                return;
            }

            var offset3 = 10f;

            GUI.Label(new Rect(420, offset3, 200f, 20f), $"Current synced sector :");
            offset3 += _debugLineSpacing;
            var sector = PlayerTransformSync.LocalInstance.ReferenceSector;
            var text   = sector == null
                                ? "NULL SECTOR"
                                : $"{sector.AttachedObject.name} : {sector.IsFakeSector}";

            GUI.Label(new Rect(420, offset3, 400f, 20f), $"- {text}");
            offset3 += _debugLineSpacing;

            var offset2 = 10f;

            GUI.Label(new Rect(620, offset2, 200f, 20f), $"Owned Objects :");
            offset2 += _debugLineSpacing;
            foreach (var obj in QSBWorldSync.GetWorldObjects <IQSBQuantumObject>().Where(x => x.ControllingPlayer == QSBPlayerManager.LocalPlayerId))
            {
                GUI.Label(new Rect(620, offset2, 200f, 20f), $"- {(obj as IWorldObject).Name}, {obj.ControllingPlayer}, {obj.IsEnabled}");
                offset2 += _debugLineSpacing;
            }

            if (QSBSceneManager.CurrentScene != OWScene.SolarSystem)
            {
                return;
            }

            GUI.Label(new Rect(220, offset, 200f, 20f), $"QM Illuminated : {Locator.GetQuantumMoon().IsIlluminated()}");
            offset += _debugLineSpacing;
            GUI.Label(new Rect(220, offset, 200f, 20f), $"Shrine player in dark? : {QuantumManager.Instance.Shrine.IsPlayerInDarkness()}");
            offset += _debugLineSpacing;
            GUI.Label(new Rect(220, offset, 200f, 20f), $"QM Visible by :");
            offset += _debugLineSpacing;
            var tracker = Locator.GetQuantumMoon().GetValue <ShapeVisibilityTracker>("_visibilityTracker");

            foreach (var player in QSBPlayerManager.GetPlayersWithCameras())
            {
                GUI.Label(new Rect(220, offset, 200f, 20f), $"	- {player.PlayerId} : {tracker.GetType().GetMethod("IsInFrustum", BindingFlags.NonPublic | BindingFlags.Instance).Invoke(tracker, new object[] { player.Camera.GetFrustumPlanes() })}");
                offset += _debugLineSpacing;
            }

            if (SocketedObjToDebug == -1)
            {
                return;
            }

            // Used for diagnosing specific socketed objects.
            // 110 = Cave Twin entanglement shard
            // 342 = Timber Hearth museum shard
            var socketedObject = QSBWorldSync.GetWorldFromId <QSBSocketedQuantumObject>(SocketedObjToDebug);

            GUI.Label(new Rect(220, offset, 200f, 20f), $"{SocketedObjToDebug} Controller : {socketedObject.ControllingPlayer}");
            offset += _debugLineSpacing;
            GUI.Label(new Rect(220, offset, 200f, 20f), $"{SocketedObjToDebug} Illuminated : {socketedObject.AttachedObject.IsIlluminated()}");
            offset += _debugLineSpacing;
            var socketedTrackers = socketedObject.AttachedObject.GetComponentsInChildren <ShapeVisibilityTracker>();

            if (socketedTrackers == null || socketedTrackers.Length == 0)
            {
                GUI.Label(new Rect(220, offset, 200f, 20f), $"- List is null or empty.");
                return;
            }
            if (socketedTrackers.Any(x => x is null))
            {
                GUI.Label(new Rect(220, offset, 200f, 20f), $"- Uses a null.");
                return;
            }
            GUI.Label(new Rect(220, offset, 200f, 20f), $"Visible by :");
            offset += _debugLineSpacing;
            foreach (var player in QSBPlayerManager.GetPlayersWithCameras())
            {
                GUI.Label(new Rect(220, offset, 200f, 20f), $"	- {player.PlayerId} : {socketedTrackers.Any(x => (bool)x.GetType().GetMethod("IsInFrustum", BindingFlags.NonPublic | BindingFlags.Instance).Invoke(x, new object[] { player.Camera.GetFrustumPlanes() }))}");
                offset += _debugLineSpacing;
            }
            GUI.Label(new Rect(220, offset, 200f, 20f), $"Entangled Players :");
            offset += _debugLineSpacing;
            foreach (var player in QuantumManager.GetEntangledPlayers(socketedObject.AttachedObject))
            {
                GUI.Label(new Rect(220, offset, 200f, 20f), $"	- {player.PlayerId}");
                offset += _debugLineSpacing;
            }
            var sockets = socketedObject.AttachedObject.GetValue <List <QuantumSocket> >("_socketList");

            foreach (var socket in sockets)
            {
                GUI.Label(new Rect(220, offset, 200f, 20f), $"- {socket.name} :");
                offset += _debugLineSpacing;
                GUI.Label(new Rect(220, offset, 200f, 20f), $"	- Visible:{socket.GetVisibilityObject().IsVisible()}");
                offset += _debugLineSpacing;
                GUI.Label(new Rect(220, offset, 200f, 20f), $"	- Illuminated:{socket.GetVisibilityObject().IsIlluminated()}");
                offset += _debugLineSpacing;
                GUI.Label(new Rect(220, offset, 200f, 20f), $"	- Occupied?:{socket.IsOccupied()}");
                offset += _debugLineSpacing;
            }
        }
Exemplo n.º 18
0
        public override void OnReceiveRemote(bool server, DropItemMessage message)
        {
            var worldObject = QSBWorldSync.GetWorldFromId <IQSBOWItem>(message.ObjectId);

            worldObject.DropItem(message.Position, message.Normal, message.Sector);
        }
Exemplo n.º 19
0
        public override void OnReceiveRemote(bool server, OrbSlotMessage message)
        {
            var orbSlot = QSBWorldSync.GetWorldFromId <QSBOrbSlot>(message.SlotId);

            orbSlot?.SetState(message.SlotState, message.OrbId);
        }
Exemplo n.º 20
0
        public override void OnReceiveRemote(bool server, BoolWorldObjectMessage message)
        {
            var elevator = QSBWorldSync.GetWorldFromId <QSBElevator>(message.ObjectId);

            elevator?.RemoteCall(message.State);
        }
        public override void OnReceiveLocal(bool server, QuantumAuthorityMessage message)
        {
            var obj = QSBWorldSync.GetWorldFromId <IQSBQuantumObject>(message.ObjectId);

            obj.ControllingPlayer = message.AuthorityOwner;
        }