add comments

This commit is contained in:
yuni 2024-07-12 14:57:53 +02:00
parent 4f787c33e8
commit 90c89fc3f3

View file

@ -377,9 +377,17 @@ pub fn load_defs(mut ew_spawn: EventWriter<SpawnEvent>) {
}
}
["relativeto", id] => {
// Offsets this actor's position by the pos. of the actor with the given id.
state.relative_to = Some(id.to_string());
}
["orbitaround", object_id, radius_str] => {
// Places the actor into an orbit around the object_id so that it's position
// will be offset by the orbital distance (radius_str) and the phase will
// be set dynamically based on the current day+time.
// Unlike the "orbit" command, this position is not static, and there is no
// parameter for a phase offset, though you can set that with the
// "orbit_phase_offset" command.
// Make sure to use this with "relativeto" with the object that's being orbited.
if let Ok(r) = radius_str.parse::<f64>() {
state.orbit_distance = Some(r);
state.orbit_object_id = Some(object_id.to_string());
@ -389,6 +397,11 @@ pub fn load_defs(mut ew_spawn: EventWriter<SpawnEvent>) {
}
}
["orbit", radius_str, phase_str] => {
// Offsets the actor's position by the given distance (radius_str)
// in the direction as defined by the angle in phase_str.
// Unlike "orbitaround", the position is static though and will not
// change over time.
// Make sure to use this with "relativeto" with the object that's being orbited.
if let (Ok(r), Ok(phase)) = (radius_str.parse::<f64>(), phase_str.parse::<f64>()) {
state.orbit_distance = Some(r);
state.orbit_phase = Some(phase * PI * 2.0);
@ -398,6 +411,8 @@ pub fn load_defs(mut ew_spawn: EventWriter<SpawnEvent>) {
}
}
["orbit_phase_offset", value] => {
// When used in combination with "orbitaround", this command allows
// you to move the actor ahead (or behind) in its orbit by the given offset.
if let Ok(value_float) = value.parse::<f64>() {
let offset_radians = 2.0 * PI * value_float;
if let Some(phase_radians) = state.orbit_phase {