simplify MoveSkeletonMessage

This commit is contained in:
JohnCorby 2022-01-11 19:31:54 -08:00
parent 5729ea78ff
commit e62330e337
3 changed files with 16 additions and 28 deletions

View File

@ -6,28 +6,22 @@ namespace QSB.QuantumSync.Messages
{
internal class MoveSkeletonMessage : QSBWorldObjectMessage<QSBQuantumSkeletonTower>
{
private int _pointingIndex, _towerIndex;
private int _index;
public MoveSkeletonMessage(int pointingIndex, int towerIndex)
{
_pointingIndex = pointingIndex;
_towerIndex = towerIndex;
}
public MoveSkeletonMessage(int index) => _index = index;
public override void Serialize(QNetworkWriter writer)
{
base.Serialize(writer);
writer.Write(_pointingIndex);
writer.Write(_towerIndex);
writer.Write(_index);
}
public override void Deserialize(QNetworkReader reader)
{
base.Deserialize(reader);
_pointingIndex = reader.ReadInt32();
_towerIndex = reader.ReadInt32();
_index = reader.ReadInt32();
}
public override void OnReceiveRemote() => WorldObject.MoveSkeleton(_pointingIndex, _towerIndex);
public override void OnReceiveRemote() => WorldObject.MoveSkeleton(_index);
}
}

View File

@ -499,26 +499,20 @@ namespace QSB.QuantumSync.Patches
if (__instance._index < __instance._towerSkeletons.Length)
{
var pointingIndex = -1;
for (var i = 0; i < __instance._pointingSkeletons.Length; i++)
{
if (__instance._pointingSkeletons[i].gameObject.activeInHierarchy &&
(!__instance._pointingSkeletons[i].IsVisible() || !__instance._pointingSkeletons[i].IsIlluminated()))
{
__instance._pointingSkeletons[i].gameObject.SetActive(false);
pointingIndex = i;
break;
}
}
if (pointingIndex != -1)
{
qsbQuantumSkeletonTower.SendMessage(new MoveSkeletonMessage(pointingIndex, __instance._index));
__instance._towerSkeletons[__instance._index].SetActive(true);
__instance._index++;
__instance._waitForPlayerToLookAtTower = true;
__result = true;
return false;
__instance._towerSkeletons[__instance._index].SetActive(true);
__instance._index++;
__instance._waitForPlayerToLookAtTower = true;
qsbQuantumSkeletonTower.SendMessage(new MoveSkeletonMessage(i));
__result = true;
return false;
}
}
}

View File

@ -6,12 +6,12 @@
+ $"{AttachedObject._index} {AttachedObject._waitForPlayerToLookAtTower}\n"
+ $"{AttachedObject._waitForFlicker} {AttachedObject._flickering}";
public void MoveSkeleton(int pointingIndex, int towerIndex)
public void MoveSkeleton(int index)
{
AttachedObject._pointingSkeletons[pointingIndex].gameObject.SetActive(false);
AttachedObject._pointingSkeletons[index].gameObject.SetActive(false);
AttachedObject._towerSkeletons[towerIndex].SetActive(true);
AttachedObject._index = towerIndex + 1;
AttachedObject._towerSkeletons[AttachedObject._index].SetActive(true);
AttachedObject._index++;
AttachedObject._waitForPlayerToLookAtTower = true;
}
}