Skip to content

Commit

Permalink
"layer" for "lockOnPoints"
Browse files Browse the repository at this point in the history
  • Loading branch information
toasterparty committed Mar 20, 2024
1 parent 78a9c6b commit c5fdfad
Show file tree
Hide file tree
Showing 3 changed files with 22 additions and 14 deletions.
6 changes: 6 additions & 0 deletions schema/randomprime.schema.json
Original file line number Diff line number Diff line change
Expand Up @@ -3172,6 +3172,12 @@
"description": "Position of the point",
"$ref": "#/$defs/vector3"
},
"layer": {
"description": "Layer # to place the lockOnPoint at",
"type": "integer",
"minimum": 0,
"maximum": 63
},
"isGrapple": {
"description": "If true, adds grapple functionality to this point.",
"type": "boolean",
Expand Down
29 changes: 15 additions & 14 deletions src/add_modify_obj_patches.rs
Original file line number Diff line number Diff line change
Expand Up @@ -2444,6 +2444,7 @@ pub fn patch_lock_on_point<'r>(
let is_grapple = config.is_grapple.unwrap_or(false);
let no_lock = config.no_lock.unwrap_or(false);
let position = config.position;
let layer = config.layer.unwrap_or(0) as usize;

if is_grapple {
let deps = vec![
Expand All @@ -2467,7 +2468,7 @@ pub fn patch_lock_on_point<'r>(
area.add_dependencies(game_resources, 0, deps_iter);
}

let actor_id = config.id1.unwrap_or(area.new_object_id_from_layer_name("Default"));
let actor_id = config.id1.unwrap_or(area.new_object_id_from_layer_id(layer));
let mut grapple_point_id = 0;
let mut special_function_id = 0;
let mut timer_id = 0;
Expand All @@ -2477,20 +2478,20 @@ pub fn patch_lock_on_point<'r>(
let mut add_scan_point = false;

if is_grapple {
grapple_point_id = config.id2.unwrap_or(area.new_object_id_from_layer_name("Default"));
grapple_point_id = config.id2.unwrap_or(area.new_object_id_from_layer_id(layer));
add_scan_point = true; // We don't actually need the scan points, just their assets. Could save on objects by making this false via config
if add_scan_point {
special_function_id = area.new_object_id_from_layer_name("Default");
timer_id = area.new_object_id_from_layer_name("Default");
poi_pre_id = area.new_object_id_from_layer_name("Default");
poi_post_id = area.new_object_id_from_layer_name("Default");
special_function_id = area.new_object_id_from_layer_id(layer);
timer_id = area.new_object_id_from_layer_id(layer);
poi_pre_id = area.new_object_id_from_layer_id(layer);
poi_post_id = area.new_object_id_from_layer_id(layer);
}
} else if !no_lock {
damageable_trigger_id = config.id2.unwrap_or(area.new_object_id_from_layer_name("Default"));
damageable_trigger_id = config.id2.unwrap_or(area.new_object_id_from_layer_id(layer));
}

let layers = area.mrea().scly_section_mut().layers.as_mut_vec();
layers[0].objects.as_mut_vec().push(
layers[layer].objects.as_mut_vec().push(
structs::SclyObject {
instance_id: actor_id,
property_data: structs::Actor {
Expand Down Expand Up @@ -2569,7 +2570,7 @@ pub fn patch_lock_on_point<'r>(
);

if is_grapple {
layers[0].objects.as_mut_vec().push(
layers[layer].objects.as_mut_vec().push(
structs::SclyObject {
instance_id: grapple_point_id,
property_data: structs::GrapplePoint {
Expand Down Expand Up @@ -2598,7 +2599,7 @@ pub fn patch_lock_on_point<'r>(
);

if add_scan_point {
layers[0].objects.as_mut_vec().push(
layers[layer].objects.as_mut_vec().push(
structs::SclyObject {
instance_id: special_function_id,
connections: vec![
Expand Down Expand Up @@ -2636,7 +2637,7 @@ pub fn patch_lock_on_point<'r>(
}
);

layers[0].objects.as_mut_vec().push(
layers[layer].objects.as_mut_vec().push(
structs::SclyObject {
instance_id: timer_id,
connections: vec![
Expand All @@ -2657,7 +2658,7 @@ pub fn patch_lock_on_point<'r>(
}
);

layers[0].objects.as_mut_vec().push(
layers[layer].objects.as_mut_vec().push(
structs::SclyObject {
instance_id: poi_pre_id,
connections: vec![].into(),
Expand All @@ -2676,7 +2677,7 @@ pub fn patch_lock_on_point<'r>(
}
);

layers[0].objects.as_mut_vec().push(
layers[layer].objects.as_mut_vec().push(
structs::SclyObject {
instance_id: poi_post_id,
connections: vec![].into(),
Expand All @@ -2696,7 +2697,7 @@ pub fn patch_lock_on_point<'r>(
);
}
} else if !no_lock {
layers[0].objects.as_mut_vec().push(
layers[layer].objects.as_mut_vec().push(
structs::SclyObject {
instance_id: damageable_trigger_id,
property_data: structs::DamageableTrigger {
Expand Down
1 change: 1 addition & 0 deletions src/patch_config.rs
Original file line number Diff line number Diff line change
Expand Up @@ -347,6 +347,7 @@ pub struct CameraHintConfig
pub struct LockOnPoint
{
pub id1: Option<u32>,
pub layer: Option<u32>,
pub active1: Option<bool>,
pub id2: Option<u32>,
pub active2: Option<bool>,
Expand Down

0 comments on commit c5fdfad

Please sign in to comment.