#[no_std, cache_output] extract import "constants.spwn" type @obj_set impl @obj_set { new: #[desc("Creates a new object set") example(" my_objects = @obj_set::new() ")] ( objects: [@object] = [], #[desc("The center group to use for rotation")] group: @group = ?g ) { return { type: @obj_set, objects: objects, group: group, } }, is_empty: #[desc("Returns true if this set contains no objects, false otherwise.") example("$.assert(@obj_set::new().is_empty())")] (self) { return self.objects.is_empty(); }, // ! The append builtin is broken at the moment, mutability is not preserved push: #[desc("Add new objects to the set")] (self, object: @object) { let to_push = object; $.append(self.objects, to_push) }, add: #[desc("Add all the objects in the set to the game")] (self) { for object in self.objects { object.add() } }, copy: #[desc("Create a copy of all the objects in this set as a new set")] (self) { return self; }, rotate: #[desc("Applies a single rotation value to all of the objects in this set")] (self, deg: @number) { for i in ..self.objects.length { self.objects[i].set(obj_props.ROTATION, deg) } }, rotate_relative: #[desc("Rotates objects in a set around a centerpoint")] (self, center_group: @group, deg: @number, duration: @number, easing: @easing_type, easing_rate: @number, lock_object_rotation: @bool) { self.group.rotate(center_group, deg, duration, easing, easing_rate, lock_object_rotation) } }