Merge branch 'fix-qm-killer' into message-manager

This commit is contained in:
JohnCorby 2021-12-19 21:18:12 -08:00
commit c0e919781d
3 changed files with 30 additions and 6 deletions

View File

@ -12,6 +12,7 @@ using QSB.Tools.TranslatorTool.TranslationSync.WorldObjects;
using QSB.TornadoSync.WorldObjects;
using QSB.Utility;
using QSB.WorldSync;
using UnityEngine;
namespace QSB.Player.Events
{
@ -113,8 +114,30 @@ namespace QSB.Player.Events
=> QSBEventManager.FireEvent(EventNames.QSBTextTranslated, NomaiTextType.VesselComputer, vesselComputer.ObjectId, id));
}
QSBWorldSync.GetWorldObjects<IQSBQuantumObject>().ForEach(x
=> QSBEventManager.FireEvent(EventNames.QSBQuantumAuthority, x.ObjectId, x.ControllingPlayer));
QSBWorldSync.GetWorldObjects<IQSBQuantumObject>().ForEach(x =>
{
QSBEventManager.FireEvent(EventNames.QSBQuantumAuthority, x.ObjectId, x.ControllingPlayer);
if (x is QSBQuantumMoon qsbQuantumMoon)
{
int stateIndex;
Vector3 onUnitSphere;
int orbitAngle;
var moon = qsbQuantumMoon.AttachedObject;
var moonBody = moon._moonBody;
stateIndex = moon.GetStateIndex();
var orbit = moon._orbits.First(y => y.GetStateIndex() == stateIndex);
var orbitBody = orbit.GetAttachedOWRigidbody();
var relPos = moonBody.GetWorldCenterOfMass() - orbitBody.GetWorldCenterOfMass();
var relVel = moonBody.GetVelocity() - orbitBody.GetVelocity();
onUnitSphere = relPos.normalized;
var perpendicular = Vector3.Cross(relPos, Vector3.up).normalized;
orbitAngle = (int)OWMath.WrapAngle(OWMath.Angle(perpendicular, relVel, relPos));
QSBEventManager.FireEvent(EventNames.QSBMoonStateChange, stateIndex, onUnitSphere, orbitAngle);
}
});
QSBWorldSync.GetWorldObjects<QSBCampfire>().ForEach(campfire
=> QSBEventManager.FireEvent(EventNames.QSBCampfireState, campfire.ObjectId, campfire.GetState()));

View File

@ -1,4 +1,5 @@
using QSB.Player;
using System.Linq;
namespace QSB.QuantumSync.WorldObjects
{
@ -6,7 +7,8 @@ namespace QSB.QuantumSync.WorldObjects
{
public override void Init()
{
ControllingPlayer = QSBPlayerManager.LocalPlayerId;
// smallest player id is the host
ControllingPlayer = QSBPlayerManager.PlayerList.Min(x => x.PlayerId);
base.Init();
}
}

View File

@ -7,9 +7,8 @@ namespace QSB.QuantumSync.WorldObjects
{
public override void Init()
{
ControllingPlayer = QSBCore.IsHost
? QSBPlayerManager.LocalPlayerId
: QSBPlayerManager.PlayerList.OrderBy(x => x.PlayerId).First().PlayerId;
// smallest player id is the host
ControllingPlayer = QSBPlayerManager.PlayerList.Min(x => x.PlayerId);
base.Init();
}
}