add osSetPathLineData
parent
362a49c0ed
commit
06495ab3e6
|
@ -110,16 +110,18 @@ namespace OpenSim.Modules.PathFinding
|
|||
{
|
||||
m_scriptModule.RegisterScriptInvocation(this, "osGeneratePathEnv");
|
||||
m_scriptModule.RegisterScriptInvocation(this, "osKeepAlivePathEnv");
|
||||
m_scriptModule.RegisterScriptInvocation(this, "osSetPositionData");
|
||||
m_scriptModule.RegisterScriptInvocation(this, "osSetPathPositionData");
|
||||
m_scriptModule.RegisterScriptInvocation(this, "osSetPathLineData");
|
||||
m_scriptModule.RegisterScriptInvocation(this, "osGeneratePath");
|
||||
|
||||
m_scriptModule.RegisterScriptInvocation(this, "osGetObjectsList");
|
||||
m_scriptModule.RegisterScriptInvocation(this, "osGetSearchableObjectList");
|
||||
|
||||
m_scriptModule.RegisterScriptInvocation(this, "osGenerateDebugImage");
|
||||
|
||||
m_scriptModule.RegisterConstant("PATH_ENV_SUCCESSFUL", 19850);
|
||||
m_scriptModule.RegisterConstant("PATH_ENV_NOT_FOUND", 19851);
|
||||
m_scriptModule.RegisterConstant("PATH_ENV_OUT_OF_RANGE", 19852);
|
||||
m_scriptModule.RegisterConstant("PATH_ENV_ERR_NOT_FOUND", 19851);
|
||||
m_scriptModule.RegisterConstant("PATH_ENV_ERR_OUT_OF_RANGE", 19852);
|
||||
m_scriptModule.RegisterConstant("PATH_ENV_ERR_NOT_IN_LINE", 19853);
|
||||
}
|
||||
catch (Exception e)
|
||||
{
|
||||
|
@ -217,6 +219,76 @@ namespace OpenSim.Modules.PathFinding
|
|||
m_scriptModule.DispatchReply(requestData.ScriptID, 19851, "", requestData.RequestID.ToString());
|
||||
}
|
||||
|
||||
private void setLineData(ScriptRequestData requestData, Vector3 start, Vector3 target, int walkable)
|
||||
{
|
||||
Environment _env = m_environments.Find(X => X.ID == requestData.EnvironmentID);
|
||||
|
||||
if (_env != null)
|
||||
{
|
||||
if ((int)start.X == (int)target.X || (int)start.Y == (int)target.Y)
|
||||
{
|
||||
if ((int)start.X == (int)target.X && (int)start.Y == (int)target.Y)
|
||||
{
|
||||
m_scriptModule.DispatchReply(requestData.ScriptID, 19850, "", requestData.RequestID.ToString());
|
||||
return;
|
||||
}
|
||||
|
||||
if ((int)start.X != (int)target.X)
|
||||
{
|
||||
int difference = (int)start.X - (int)target.X;
|
||||
|
||||
while (difference != 0)
|
||||
{
|
||||
Vector3 _position = start;
|
||||
if (difference < 0)
|
||||
{
|
||||
_position.X = _position.X - 1;
|
||||
setPositionData(requestData, _position, walkable, 0);
|
||||
difference++;
|
||||
}
|
||||
else
|
||||
{
|
||||
_position.X = _position.X + 1;
|
||||
setPositionData(requestData, _position, walkable, 0);
|
||||
difference--;
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
if ((int)start.Y != (int)target.Y)
|
||||
{
|
||||
int difference = (int)start.Y - (int)target.Y;
|
||||
|
||||
while (difference != 0)
|
||||
{
|
||||
Vector3 _position = start;
|
||||
if (difference < 0)
|
||||
{
|
||||
_position.Y = _position.Y - 1;
|
||||
setPositionData(requestData, _position, walkable, 0);
|
||||
difference++;
|
||||
}
|
||||
else
|
||||
{
|
||||
_position.Y = _position.Y + 1;
|
||||
setPositionData(requestData, _position, walkable, 0);
|
||||
difference--;
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
m_scriptModule.DispatchReply(requestData.ScriptID, 19850, "", requestData.RequestID.ToString());
|
||||
return;
|
||||
}
|
||||
}
|
||||
else
|
||||
{
|
||||
m_scriptModule.DispatchReply(requestData.ScriptID, 19851, "", requestData.RequestID.ToString());
|
||||
}
|
||||
|
||||
m_scriptModule.DispatchReply(requestData.ScriptID, 19853, "", requestData.RequestID.ToString());
|
||||
}
|
||||
|
||||
private void generatePath(ScriptRequestData requestData)
|
||||
{
|
||||
|
||||
|
@ -277,12 +349,19 @@ namespace OpenSim.Modules.PathFinding
|
|||
}
|
||||
|
||||
[ScriptInvocation]
|
||||
public void osSetPositionData(UUID hostID, UUID scriptID, String environmentID, Vector3 position, int walkable, int isTarget)
|
||||
public void osSetPathPositionData(UUID hostID, UUID scriptID, String environmentID, Vector3 position, int walkable, int isTarget)
|
||||
{
|
||||
SceneObjectGroup _host = m_scene.GetSceneObjectGroup(hostID);
|
||||
(new Thread(delegate () { setPositionData(new ScriptRequestData(hostID, scriptID, environmentID), position, walkable, isTarget); })).Start();
|
||||
}
|
||||
|
||||
[ScriptInvocation]
|
||||
public void osSetPathLineData(UUID hostID, UUID scriptID, String environmentID, Vector3 start, Vector3 target, int walkable)
|
||||
{
|
||||
SceneObjectGroup _host = m_scene.GetSceneObjectGroup(hostID);
|
||||
(new Thread(delegate () { setLineData(new ScriptRequestData(hostID, scriptID, environmentID), start, target, walkable); })).Start();
|
||||
}
|
||||
|
||||
[ScriptInvocation]
|
||||
public string osGeneratePath(UUID hostID, UUID scriptID, String environmentID)
|
||||
{
|
||||
|
|
|
@ -7,7 +7,7 @@ using System.Threading.Tasks;
|
|||
|
||||
namespace OpenSim.Modules.PathFinding
|
||||
{
|
||||
class ScriptRequestData
|
||||
public class ScriptRequestData
|
||||
{
|
||||
public UUID HostID = UUID.Zero;
|
||||
public UUID ScriptID = UUID.Zero;
|
||||
|
|
Loading…
Reference in New Issue