mirror of
https://github.com/misternebula/quantum-space-buddies.git
synced 2025-02-04 03:39:55 +00:00
bool remote = false
This commit is contained in:
parent
bc297df104
commit
4f3dd79f77
@ -1,11 +1,6 @@
|
||||
using QSB.EchoesOfTheEye.Ghosts.WorldObjects;
|
||||
using QSB.Messaging;
|
||||
using QSB.Utility;
|
||||
using System;
|
||||
using System.Collections.Generic;
|
||||
using System.Linq;
|
||||
using System.Text;
|
||||
using System.Threading.Tasks;
|
||||
|
||||
namespace QSB.EchoesOfTheEye.Ghosts.Messages;
|
||||
|
||||
@ -16,6 +11,6 @@ internal class ChangeActionMessage : QSBWorldObjectMessage<QSBGhostBrain, GhostA
|
||||
public override void OnReceiveRemote()
|
||||
{
|
||||
DebugLog.DebugWrite($"{WorldObject.AttachedObject._name} Change action to {Data}");
|
||||
WorldObject.ChangeAction(WorldObject.GetAction(Data));
|
||||
WorldObject.ChangeAction(WorldObject.GetAction(Data), true);
|
||||
}
|
||||
}
|
||||
|
@ -2,11 +2,6 @@
|
||||
using QSB.Messaging;
|
||||
using QSB.Player;
|
||||
using QSB.Utility;
|
||||
using System;
|
||||
using System.Collections.Generic;
|
||||
using System.Linq;
|
||||
using System.Text;
|
||||
using System.Threading.Tasks;
|
||||
|
||||
namespace QSB.EchoesOfTheEye.Ghosts.Messages;
|
||||
|
||||
|
@ -20,6 +20,6 @@ internal class PathfindLocalPositionMessage : QSBWorldObjectMessage<QSBGhostCont
|
||||
}
|
||||
|
||||
DebugLog.DebugWrite($"{WorldObject.AttachedObject.name} Pathfind to local position {Data.localPosition} with speed:{Data.speed}, acceleration:{Data.acceleration}");
|
||||
WorldObject.AttachedObject.PathfindToLocalPosition(Data.localPosition, Data.speed, Data.acceleration);
|
||||
WorldObject.PathfindToLocalPosition(Data.localPosition, Data.speed, Data.acceleration, true);
|
||||
}
|
||||
}
|
||||
|
@ -3,19 +3,14 @@ using QSB.Messaging;
|
||||
using QSB.Utility;
|
||||
using QSB.WorldSync;
|
||||
using System;
|
||||
using System.Collections.Generic;
|
||||
using System.Diagnostics;
|
||||
using System.Linq;
|
||||
using System.Text;
|
||||
using System.Threading.Tasks;
|
||||
using UnityEngine;
|
||||
|
||||
namespace QSB.EchoesOfTheEye.Ghosts.Messages;
|
||||
|
||||
internal class PathfindNodeMessage : QSBWorldObjectMessage<QSBGhostController, (int mapId, int nodeIndex, float speed, float acceleration)>
|
||||
{
|
||||
public PathfindNodeMessage(GhostNode node, float speed, float acceleration) : base(Process(node, speed, acceleration)) { }
|
||||
|
||||
|
||||
private static (int mapId, int nodeIndex, float speed, float acceleration) Process(GhostNode node, float speed, float acceleration)
|
||||
{
|
||||
(int mapId, int nodeId, float speed, float acceleration) ret = new();
|
||||
@ -36,15 +31,15 @@ internal class PathfindNodeMessage : QSBWorldObjectMessage<QSBGhostController, (
|
||||
{
|
||||
if (QSBCore.IsHost)
|
||||
{
|
||||
DebugLog.ToConsole($"Error - Received PathfindNodeMessage on host. Something has gone horribly wrong!", OWML.Common.MessageType.Error);
|
||||
DebugLog.ToConsole("Error - Received PathfindNodeMessage on host. Something has gone horribly wrong!", OWML.Common.MessageType.Error);
|
||||
return;
|
||||
}
|
||||
|
||||
DebugLog.DebugWrite($"{WorldObject.AttachedObject.name} Pathfind to node {Data.nodeIndex} on map {Data.mapId} with speed:{Data.speed}, acceleration:{Data.acceleration}");
|
||||
|
||||
var map = QSBWorldSync.GetWorldObject<QSBGhostNodeMap>(Data.mapId);
|
||||
var map = Data.mapId.GetWorldObject<QSBGhostNodeMap>();
|
||||
var node = map.AttachedObject._nodes[Data.nodeIndex];
|
||||
|
||||
WorldObject.AttachedObject.PathfindToNode(node, Data.speed, Data.acceleration);
|
||||
WorldObject.PathfindToNode(node, Data.speed, Data.acceleration, true);
|
||||
}
|
||||
}
|
||||
|
@ -447,7 +447,6 @@ public class QSBGhostBrain : WorldObject<GhostBrain>, IGhostObject
|
||||
|
||||
if (_pendingAction != null && AttachedObject._pendingActionTimer <= 0f)
|
||||
{
|
||||
this.SendMessage(new ChangeActionMessage(_pendingAction.GetName()));
|
||||
ChangeAction(_pendingAction);
|
||||
}
|
||||
|
||||
@ -457,8 +456,13 @@ public class QSBGhostBrain : WorldObject<GhostBrain>, IGhostObject
|
||||
}
|
||||
}
|
||||
|
||||
public void ChangeAction(QSBGhostAction action)
|
||||
public void ChangeAction(QSBGhostAction action, bool remote = false)
|
||||
{
|
||||
if (remote)
|
||||
{
|
||||
this.SendMessage(new ChangeActionMessage(_data.currentAction));
|
||||
}
|
||||
|
||||
DebugLog.DebugWrite($"{AttachedObject._name} Change action to {action?.GetName()}");
|
||||
|
||||
if (_currentAction != null)
|
||||
@ -542,7 +546,6 @@ public class QSBGhostBrain : WorldObject<GhostBrain>, IGhostObject
|
||||
{
|
||||
AttachedObject.enabled = false;
|
||||
AttachedObject._controller.GetDreamLanternController().enabled = false;
|
||||
this.SendMessage(new ChangeActionMessage(GhostAction.Name.None));
|
||||
ChangeAction(null);
|
||||
_data.OnPlayerExitDreamWorld();
|
||||
}
|
||||
|
@ -131,14 +131,18 @@ public class QSBGhostController : WorldObject<GhostController>, IGhostObject
|
||||
this.PathfindToLocalPosition(localPosition, GhostConstants.GetMoveSpeed(moveType), GhostConstants.GetMoveAcceleration(moveType));
|
||||
}
|
||||
|
||||
public void PathfindToLocalPosition(Vector3 localPosition, float speed, float acceleration = 10f)
|
||||
public void PathfindToLocalPosition(Vector3 localPosition, float speed, float acceleration = 10f, bool remote = false)
|
||||
{
|
||||
if (!QSBCore.IsHost)
|
||||
if (!remote)
|
||||
{
|
||||
return;
|
||||
if (!QSBCore.IsHost)
|
||||
{
|
||||
return;
|
||||
}
|
||||
|
||||
this.SendMessage(new PathfindLocalPositionMessage(localPosition, speed, acceleration));
|
||||
}
|
||||
|
||||
this.SendMessage(new PathfindLocalPositionMessage(localPosition, speed, acceleration));
|
||||
AttachedObject.PathfindToLocalPosition(localPosition, speed, acceleration);
|
||||
}
|
||||
|
||||
@ -147,11 +151,16 @@ public class QSBGhostController : WorldObject<GhostController>, IGhostObject
|
||||
this.PathfindToNode(node, GhostConstants.GetMoveSpeed(moveType), GhostConstants.GetMoveAcceleration(moveType));
|
||||
}
|
||||
|
||||
public void PathfindToNode(GhostNode node, float speed, float acceleration = 10f)
|
||||
public void PathfindToNode(GhostNode node, float speed, float acceleration = 10f, bool remote = false)
|
||||
{
|
||||
if (!QSBCore.IsHost)
|
||||
if (!remote)
|
||||
{
|
||||
return;
|
||||
if (!QSBCore.IsHost)
|
||||
{
|
||||
return;
|
||||
}
|
||||
|
||||
this.SendMessage(new PathfindNodeMessage(node, speed, acceleration));
|
||||
}
|
||||
|
||||
AttachedObject.PathfindToNode(node, speed, acceleration);
|
||||
|
Loading…
x
Reference in New Issue
Block a user