mirror of
https://github.com/misternebula/quantum-space-buddies.git
synced 2025-01-25 15:35:22 +00:00
filter events better (dont do anything when equal)
This commit is contained in:
parent
2db1f33ca7
commit
61866c6367
@ -36,13 +36,13 @@ namespace QSB.QuantumSync.Events
|
||||
// Deciding if to change the object's owner
|
||||
// Message
|
||||
// | = 0 | > 0 |
|
||||
// = 0 | Yes*| Yes |
|
||||
// = 0 | No | Yes |
|
||||
// > 0 | Yes | No |
|
||||
// if Obj==Message then No
|
||||
// Obj
|
||||
// *Doesn't change anything,
|
||||
// so can be yes or no
|
||||
|
||||
return obj.ControllingPlayer == 0 || message.AuthorityOwner == 0;
|
||||
return (obj.ControllingPlayer == 0 || message.AuthorityOwner == 0)
|
||||
&& (obj.ControllingPlayer != message.AuthorityOwner);
|
||||
}
|
||||
|
||||
public override void OnReceiveLocal(bool server, QuantumAuthorityMessage message)
|
||||
@ -56,10 +56,6 @@ namespace QSB.QuantumSync.Events
|
||||
{
|
||||
var objects = QSBWorldSync.GetWorldObjects<IQSBQuantumObject>();
|
||||
var obj = objects.ToList()[message.ObjectId];
|
||||
if (obj.ControllingPlayer != 0 && message.AuthorityOwner != 0)
|
||||
{
|
||||
DebugLog.ToConsole($"Warning - object {(obj as IWorldObject).Name} already has owner {obj.ControllingPlayer}, but trying to be replaced by {message.AuthorityOwner}!", MessageType.Warning);
|
||||
}
|
||||
obj.ControllingPlayer = message.AuthorityOwner;
|
||||
if (obj.ControllingPlayer == 0 && obj.IsEnabled)
|
||||
{
|
||||
|
@ -109,18 +109,11 @@ namespace QSB.QuantumSync
|
||||
*/
|
||||
|
||||
offset = 10f;
|
||||
GUI.Label(new Rect(440, offset, 200f, 20f), $"Players in QM :");
|
||||
GUI.Label(new Rect(440, offset, 200f, 20f), $"Owned Objects :");
|
||||
offset += 30f;
|
||||
foreach (var player in QSBPlayerManager.PlayerList.Where(x => x.IsInMoon))
|
||||
foreach (var obj in QSBWorldSync.GetWorldObjects<IQSBQuantumObject>().Where(x => x.ControllingPlayer == QSBPlayerManager.LocalPlayerId))
|
||||
{
|
||||
GUI.Label(new Rect(440, offset, 200f, 20f), $"- {player.PlayerId}");
|
||||
offset += 30f;
|
||||
}
|
||||
GUI.Label(new Rect(440, offset, 200f, 20f), $"Players in Shrine :");
|
||||
offset += 30f;
|
||||
foreach (var player in QSBPlayerManager.PlayerList.Where(x => x.IsInShrine))
|
||||
{
|
||||
GUI.Label(new Rect(440, offset, 200f, 20f), $"- {player.PlayerId}");
|
||||
GUI.Label(new Rect(440, offset, 200f, 20f), $"- {(obj as IWorldObject).Name}");
|
||||
offset += 30f;
|
||||
}
|
||||
}
|
||||
|
Loading…
x
Reference in New Issue
Block a user