Allow separately setting dialogue interact radius and remote trigger radius

This commit is contained in:
Nick 2022-05-04 20:18:20 -04:00
parent 1c9d6f5dce
commit 2e7fa09734
4 changed files with 20 additions and 7 deletions

View File

@ -6,7 +6,8 @@
"dialogue": [
{
"position":{"x": -0.3071011, "y": 2.741472, "z": -4.005298},
"radius":1,
"radius": 0,
"remoteTriggerRadius": 1,
"xmlFile":"AssetBundle/WarpDriveDialogue.xml",
"remoteTriggerPosition": {"x": -0.05656214, "y": 0.5362684, "z": 0.5467669},
"blockAfterPersistentCondition" : "KnowsAboutWarpDrive"

View File

@ -21,7 +21,7 @@ namespace NewHorizons.Builder.Props
if (info.blockAfterPersistentCondition != null && PlayerData._currentGameSave.GetPersistentCondition(info.blockAfterPersistentCondition)) return;
var dialogue = MakeConversationZone(go, sector, info, mod.ModHelper);
if (info.remoteTriggerPosition != null) MakeRemoteDialogueTrigger(go, sector, info, dialogue);
if (info.remoteTriggerPosition != null || info.remoteTriggerRadius != 0) MakeRemoteDialogueTrigger(go, sector, info, dialogue);
// Make the character look at the player
// Useful for dialogue replacement
@ -51,10 +51,10 @@ namespace NewHorizons.Builder.Props
remoteDialogueTrigger._activatedDialogues = new bool[1];
remoteDialogueTrigger._deactivateTriggerPostConversation = true;
sphereCollider.radius = info.radius;
sphereCollider.radius = info.remoteTriggerRadius == 0 ? info.radius : info.remoteTriggerRadius;
conversationTrigger.transform.parent = sector?.transform ?? go.transform;
conversationTrigger.transform.localPosition = info.remoteTriggerPosition;
conversationTrigger.transform.localPosition = info.remoteTriggerPosition ?? info.position;
conversationTrigger.SetActive(true);
}
@ -69,8 +69,15 @@ namespace NewHorizons.Builder.Props
sphere.radius = info.radius;
sphere.isTrigger = true;
conversationZone.AddComponent<OWCollider>();
conversationZone.AddComponent<InteractReceiver>();
var owCollider = conversationZone.AddComponent<OWCollider>();
var interact = conversationZone.AddComponent<InteractReceiver>();
if(info.radius <= 0)
{
sphere.enabled = false;
owCollider.enabled = false;
interact.enabled = false;
}
var dialogueTree = conversationZone.AddComponent<CharacterDialogueTree>();

View File

@ -79,6 +79,7 @@ namespace NewHorizons.External
{
public MVector3 position;
public float radius = 1f;
public float remoteTriggerRadius;
public string xmlFile;
public MVector3 remoteTriggerPosition;
public string blockAfterPersistentCondition;

View File

@ -646,7 +646,7 @@
"radius": {
"type": "number",
"default": 0,
"description": "Radius of the spherical collision volume where you get the \"talk to\" prompt when looking at. If you use a remoteTriggerPosition, this will instead be the size of the volume that will trigger the dialogue when you enter it."
"description": "Radius of the spherical collision volume where you get the \"talk to\" prompt when looking at. If you use a remoteTriggerPosition, you can set this to 0 to make the dialogue only trigger remotely."
},
"xmlFile": {
"type": "string",
@ -656,6 +656,10 @@
"$ref": "#/$defs/vector3",
"description": "Allows you to trigger dialogue from a distance when you walk into an area."
},
"remoteTriggerRadius": {
"type": "number",
"description": "The radius of the remote trigger volume."
},
"blockAfterPersistentCondition": {
"type": "string",
"description": "Prevents the dialogue from being created after a specific persistent condition is set. Useful for remote dialogue triggers that you want to have happen only once."