Doloro GDK 22 .1.0 Beta
by Tauri Interactive
Filters development

About

A common sense for you to create a custom filtering behaviors to adjust your sensors logic according with you features. The system allows you to make it in any easy way.

New filter creation

  1. Create a new script and inherit it from the Doloro.Sensors.ASensorFilter class.
  2. Add the component over the same object as the target FilteredSensor component.
  3. The new filter will be loaded during the sensor awaking or manually via ReloadFilters call.

Now the time to implement the filter selection logic.
The following template shows base class implementation.

using UnityEngine;
using Doloro.Sensors.Filters;
public class YourCustomSensorFilter : ASensorFilter
{
// Occurs when an object entering the filter.
// Applies filter's rules over the object and
// makes a conclusion about rules passing.
//
// invocker: sensor detected collision.
// obj: Object entered the trigger.
//
// returns: filter's rules passing result.
protected override bool FilterLogic(FilteredSensor invocker, GameObject obj)
{
// Implement your logic that concludes is the
// `obj` passing the filter's rules or not.
}
}

When you are integrates some filter customizations you have to follow next pattern.

using UnityEngine;
using Doloro.Sensors.Filters;
public class YourCustomSensorFilter : ASensorFilter
{
// Custom property to manage filter settings at runtime.
public bool Option0
{
get => _option0;
set
{
// Updating option value.
_option0 = value;
// Informing system that the filter rules has bee changed.
// That will cause selection pool reconsideration along.
OnModified();
}
}
// Serializable field available to Unity editor.
[SerializeField] private bool _option0;
... LOGIC IMPLEMENTATION HERE ...
}

Explore API:

Development rules

The filters development has several practices that have to be followed to guarantee stable embedding of the filter into the sensors ecosystem.

  • Call ASensorFilter.OnModified handler each time when you modifies core properties of your filter in case if you what to update your filtered collection along with new rules.
  • Do not involve ASensorFilter.Inverted property into your filter's logic. It will automatically applied into the ASensorFilter.CheckCollision handler calling by the sensors. Direct use into the behavior can lead to unexpected results during reverting your results.