Be sure to read the user docs first. You should get familiar with the plugin before integrating with it. Creating Flags -------------- To add flags, create a new class like this: [FlagInfo("Your Flag Description", SupportsGroupValues = , SupportsEnvironmentGroupValue = )] public sealed class MyFlag : RegionFlag { } Let me explain what everything here means. T is the option type. T must be derivered from FlagOptions or ToggleableFlagOptions type. ToggleableFlagOptions automatically adds "enabled" option. [Serializable] public sealed class MyFlagOptions : ToggleableFlagOptions { [FlagOption(Description = "Some custom message", Syntax = "")] public string MyCustomValue { get; set; } } All members must be public properties with getters and setters. You can also have nested options like this: [Serializable] public sealed class MoreFlagOptions { [FlagOption(Description = "List of item ids", Syntax = "")] public List MyCustomValue3 { get; set; } // Lists are also supported } [Serializable] public sealed class MyFlagOptions : ToggleableFlagOptions { [FlagOption(Description = "Some custom message", Syntax = "")] public string MyCustomValue { get; set; } [FlagOption(Description = "Set more options")] public MoreFlagOptions MoreOptions { get; set; } // this works } Keep in mind that lists can not use classes. Only simple values (bool, int, uint, short, ushort, byte, sbyte, float, double, string and decimal) are supported. SupportsGroupValues means your flag supports values based permission groups / region groups. You must set this to true if you use GetValue(Player), GetValue(string) or GetValue(RegionGroup). SupportsEnvironmentGroupValue means your flag supports Environmental group values. Environmental values are used when a flag also applies to non players, e.g. a zombie attacking a vehicle. You must enable this if you use GetValue(RegionGroup.Environment). After creating your flag class, you can now just register it: AdvancedRegionsPlugin.Instance.RegionFlagManager.RegisterFlag(); Speaking in Unity terms, flags are components added to a regions gameobject. Although you could now use stuff like Update() inside your flag, this is not recommended or supported. Listening to Events ------------------- There are currently events: * OnAnimalEnter(Animal animal) * OnAnimalLeave(Animal animal) * OnZombieEnter(Zombie zombie) * OnZombieLeave(Zombie zombie) * OnBarricadeCreated(Barricade barricade) * OnBarricadeDestroyed(Barricade barricade) * OnStructureCreated(Structure structure) * OnStructureDestroyed(Structure structure) * OnVehicleEnter(InteractableVehicle vehicle) * OnVehicleLeave(InteractableVehicle vehicle) * OnPlayerEnter(Player player) * OnPlayerLeave(Player player) To listen to events, all you have to do is to add them to your flag class like this: [FlagInfo("YourDescription", SupportsGroupValues = true)] public sealed class MyFlag : RegionFlag { public void OnPlayerEnteredRegion(Player player) { var value = GetValue(player); if(value == null || !value.Enabled) { return; } UnturnedChat.Say(UnturnedPlayer.FromPlayer(player), "You have entered region: " + Region.RegionInfo.Name, Color.green); } } Speaking in Unity terms, events are just messages sent to all components of a region's gameobject. Example EnterMessage Flag ------------------------- [FlagInfo("Displays a message in chat when entering the region", SupportsGroupValues = true)] public sealed class EnterMessageFlag : RegionFlag { public void OnPlayerEnteredRegion(Player player) { var value = GetValue(player); var color = value.Color != null ? UnturnedChat.GetColorFromName(value.Color, Color.white) : Color.white; ChatManager.serverSendMessage(value.Message, color, null, player.channel.owner, EChatMode.SAY, value.IconUrl, value.UseRichText); } } [Serializable] public sealed class FlagMessageOptions { [FlagOption(Description = "Sets the message", Syntax = "")] public string Message { get; set; } [FlagOption(Description = "Sets the default color of the message", Syntax = "")] public string Color { get; set; } [FlagOption(Description = "Sets if rich text should be used", Syntax = "")] public bool UseRichText { get; set; } [FlagOption(Description = "Sets the icon URL of the message", Syntax = "")] public string IconUrl { get; set; } } Adding Custom Region Handlers ---------------------------- AdvancedRegions uses Region Handlers which are responsible for handling region triggers. To create one, create a class which inherits from the RegionHandler class, implement all functions and add [RegionHandler("YourHandlerName")] to it. Call an attached regions following methods once they occur: * TriggerOnAnimalEnter(Animal animal) * TriggerOnAnimalLeave(Animal animal) * TriggerOnZombieEnter(Zombie zombie) * TriggerOnZombieLeave(Zombie zombie) * TriggerOnBarricadeCreated(Barricade barricade) * TriggerOnBarricadeDestroyed(Barricade barricade) * TriggerOnStructureCreated(Structure structure) * TriggerOnStructureDestroyed(Structure structure) * TriggerOnVehicleEnter(InteractableVehicle vehicle) * TriggerOnVehicleLeave(InteractableVehicle vehicle) * TriggerOnPlayerEnter(Player player) * TriggerOnPlayerLeave(Player player) Finally register it: AdvancedRegionsPlugin.Instance.RegionHandlerManager.RegisterHandler(); Important Notes --------------- * If you want to add values to regions or execute actions based on player regions, please always register flags for that. Never keep your own list of regions (e.g. in the config) and then proceed based on that. This also the reason why no global "OnRegionEnter" event exists. * Do not call GetRegionsAtPoint to get a players regions as it is slow. Use GetRegionsForPlayer or GetRegionsForVehicle to get them as it is much faster. * If the flag supports GroupValues, always use GetValue(Player) for players and GetValue(RegionGroup.Environment) for non-players to get it's value.