mirror of
https://github.com/misternebula/quantum-space-buddies.git
synced 2025-02-21 09:39:56 +00:00
fixes
This commit is contained in:
parent
6c30b536cb
commit
a1b5744adf
@ -6,15 +6,21 @@ namespace QSB.Animation
|
||||
{
|
||||
private Animator _attachedAnimator;
|
||||
private Transform _lookBase;
|
||||
private bool _isSetUp;
|
||||
|
||||
public void Init(Transform lookBase)
|
||||
{
|
||||
_attachedAnimator = GetComponent<Animator>();
|
||||
_lookBase = lookBase;
|
||||
_isSetUp = true;
|
||||
}
|
||||
|
||||
private void LateUpdate()
|
||||
{
|
||||
if (!_isSetUp)
|
||||
{
|
||||
return;
|
||||
}
|
||||
var bone = _attachedAnimator.GetBoneTransform(HumanBodyBones.Head);
|
||||
// Get the camera's local rotation with respect to the player body
|
||||
var lookLocalRotation = Quaternion.Inverse(_attachedAnimator.transform.rotation) * _lookBase.rotation;
|
||||
|
@ -5,28 +5,28 @@ using QSB.WorldSync.Events;
|
||||
|
||||
namespace QSB.OrbSync.Events
|
||||
{
|
||||
public class OrbSlotEvent : QSBEvent<BoolWorldObjectMessage>
|
||||
public class OrbSlotEvent : QSBEvent<OrbSlotMessage>
|
||||
{
|
||||
public override EventType Type => EventType.OrbSlot;
|
||||
|
||||
public override void SetupListener() => GlobalMessenger<int, bool>.AddListener(EventNames.QSBOrbSlot, Handler);
|
||||
public override void SetupListener() => GlobalMessenger<int, int, bool>.AddListener(EventNames.QSBOrbSlot, Handler);
|
||||
|
||||
public override void CloseListener() => GlobalMessenger<int, bool>.RemoveListener(EventNames.QSBOrbSlot, Handler);
|
||||
public override void CloseListener() => GlobalMessenger<int, int, bool>.RemoveListener(EventNames.QSBOrbSlot, Handler);
|
||||
|
||||
private void Handler(int id, bool state) => SendEvent(CreateMessage(id, state));
|
||||
private void Handler(int slotId, int orbId, bool slotState) => SendEvent(CreateMessage(slotId, orbId, slotState));
|
||||
|
||||
private BoolWorldObjectMessage CreateMessage(int id, bool state) => new BoolWorldObjectMessage
|
||||
private OrbSlotMessage CreateMessage(int slotId, int orbId, bool slotState) => new OrbSlotMessage
|
||||
{
|
||||
AboutId = LocalPlayerId,
|
||||
ObjectId = id,
|
||||
State = state
|
||||
SlotId = slotId,
|
||||
OrbId = orbId,
|
||||
SlotState = slotState
|
||||
};
|
||||
|
||||
public override void OnReceiveRemote(BoolWorldObjectMessage message)
|
||||
public override void OnReceiveRemote(OrbSlotMessage message)
|
||||
{
|
||||
DebugLog.DebugWrite($"receive slot {message.ObjectId} to {message.State}");
|
||||
var orbSlot = WorldRegistry.GetObject<QSBOrbSlot>(message.ObjectId);
|
||||
orbSlot?.SetState(message.State);
|
||||
var orbSlot = WorldRegistry.GetObject<QSBOrbSlot>(message.SlotId);
|
||||
orbSlot?.SetState(message.SlotState, message.OrbId);
|
||||
}
|
||||
}
|
||||
}
|
32
QSB/OrbSync/Events/OrbSlotMessage.cs
Normal file
32
QSB/OrbSync/Events/OrbSlotMessage.cs
Normal file
@ -0,0 +1,32 @@
|
||||
using QSB.Messaging;
|
||||
using QuantumUNET;
|
||||
using System;
|
||||
using System.Collections.Generic;
|
||||
using System.Linq;
|
||||
using System.Text;
|
||||
|
||||
namespace QSB.OrbSync.Events
|
||||
{
|
||||
public class OrbSlotMessage : PlayerMessage
|
||||
{
|
||||
public int SlotId { get; set; }
|
||||
public int OrbId { get; set; }
|
||||
public bool SlotState { get; set; }
|
||||
|
||||
public override void Deserialize(QSBNetworkReader reader)
|
||||
{
|
||||
base.Deserialize(reader);
|
||||
SlotId = reader.ReadInt32();
|
||||
OrbId = reader.ReadInt32();
|
||||
SlotState = reader.ReadBoolean();
|
||||
}
|
||||
|
||||
public override void Serialize(QSBNetworkWriter writer)
|
||||
{
|
||||
base.Serialize(writer);
|
||||
writer.Write(SlotId);
|
||||
writer.Write(OrbId);
|
||||
writer.Write(SlotState);
|
||||
}
|
||||
}
|
||||
}
|
@ -27,10 +27,6 @@ namespace QSB.OrbSync.Events
|
||||
public override void OnServerReceive(WorldObjectMessage message)
|
||||
{
|
||||
var fromPlayer = QSBNetworkServer.connections.First(x => x.GetPlayer().PlayerId == message.FromId);
|
||||
foreach (var item in QSBNetworkServer.connections)
|
||||
{
|
||||
DebugLog.DebugWrite(item.GetPlayer().PlayerId.ToString());
|
||||
}
|
||||
if (WorldRegistry.OrbSyncList.Count == 0)
|
||||
{
|
||||
DebugLog.ToConsole($"Error - OrbSyncList is empty. (ID {message.ObjectId})", MessageType.Error);
|
||||
@ -55,10 +51,8 @@ namespace QSB.OrbSync.Events
|
||||
}
|
||||
if (orbIdentity.ClientAuthorityOwner != null && orbIdentity.ClientAuthorityOwner != fromPlayer)
|
||||
{
|
||||
DebugLog.DebugWrite($"Removed authority of orb {message.ObjectId} from {orbIdentity.ClientAuthorityOwner.GetPlayer().PlayerId}");
|
||||
orbIdentity.RemoveClientAuthority(orbIdentity.ClientAuthorityOwner);
|
||||
}
|
||||
DebugLog.DebugWrite($"Assigned authority of orb {message.ObjectId} to player {message.FromId}.");
|
||||
orbIdentity.AssignClientAuthority(fromPlayer);
|
||||
orb.enabled = true;
|
||||
}
|
||||
|
@ -1,4 +1,5 @@
|
||||
using QSB.EventsCore;
|
||||
using OWML.ModHelper.Events;
|
||||
using QSB.EventsCore;
|
||||
using QSB.WorldSync;
|
||||
|
||||
namespace QSB.OrbSync
|
||||
@ -18,20 +19,22 @@ namespace QSB.OrbSync
|
||||
WorldRegistry.AddObject(this);
|
||||
}
|
||||
|
||||
public void HandleEvent(bool state)
|
||||
public void HandleEvent(bool state, int orbId)
|
||||
{
|
||||
if (QSB.HasWokenUp)
|
||||
{
|
||||
GlobalMessenger<int, bool>.FireEvent(EventNames.QSBOrbSlot, ObjectId, state);
|
||||
GlobalMessenger<int, int, bool>.FireEvent(EventNames.QSBOrbSlot, ObjectId, orbId, state);
|
||||
}
|
||||
}
|
||||
|
||||
public void SetState(bool state)
|
||||
public void SetState(bool state, int orbId)
|
||||
{
|
||||
if (!_initialized)
|
||||
{
|
||||
return;
|
||||
}
|
||||
var occOrb = state ? WorldRegistry.OldOrbList[orbId] : null;
|
||||
InterfaceSlot.SetValue("_occupyingOrb", occOrb);
|
||||
var ev = state ? "OnSlotActivated" : "OnSlotDeactivated";
|
||||
WorldRegistry.RaiseEvent(InterfaceSlot, ev);
|
||||
Activated = state;
|
||||
|
@ -150,6 +150,7 @@
|
||||
<Compile Include="Instruments\InstrumentsManager.cs" />
|
||||
<Compile Include="MessagesCore\EnumMessage.cs" />
|
||||
<Compile Include="MessagesCore\FloatMessage.cs" />
|
||||
<Compile Include="OrbSync\Events\OrbSlotMessage.cs" />
|
||||
<Compile Include="OrbSync\OrbManager.cs" />
|
||||
<Compile Include="OrbSync\Events\OrbSlotEvent.cs" />
|
||||
<Compile Include="OrbSync\OrbPatches.cs" />
|
||||
|
@ -18,8 +18,6 @@ namespace QSB.Utility
|
||||
var warpCore = GameObject.Find("Prefab_NOM_WarpCoreVessel").GetComponent<WarpCoreItem>();
|
||||
var socket = GameObject.Find("Interactibles_VesselBridge").GetComponentInChildren<WarpCoreSocket>();
|
||||
socket.PlaceIntoSocket(warpCore);
|
||||
|
||||
GetComponent<NomaiCoordinateInterface>().SetPillarRaised(true, true);
|
||||
}
|
||||
|
||||
private void Update()
|
||||
|
@ -55,7 +55,7 @@ namespace QSB.WorldSync
|
||||
orbSync = OrbSyncList.First(x => x.AttachedOrb == affectingOrb);
|
||||
if (orbSync.HasAuthority)
|
||||
{
|
||||
qsbSlot.HandleEvent(state);
|
||||
qsbSlot.HandleEvent(state, OldOrbList.IndexOf(affectingOrb));
|
||||
}
|
||||
}
|
||||
catch
|
||||
|
Loading…
x
Reference in New Issue
Block a user