/// <summary>Add the appropriate exit context command(s) to the specified location.</summary> /// <param name="location">The location to add exit context command(s) to.</param> private void AddExitContextCommands(Thing location) { var mainExitCommand = this.GetExitCommandFrom(location); var secondExitAlias = this.GetSecondaryExitAlias(mainExitCommand); if (!string.IsNullOrEmpty(mainExitCommand)) { var contextCommand = new ContextCommand(this.commands, mainExitCommand, ContextAvailability.ToChildren, SecurityRole.all); location.Commands.Add(mainExitCommand, contextCommand); if (!string.IsNullOrEmpty(secondExitAlias)) { location.Commands.Add(secondExitAlias, contextCommand); } } }
/// <summary>Add the appropriate exit context command(s) to the specified location.</summary> /// <param name="location">The location to add exit context command(s) to.</param> private void AddExitContextCommands(Thing location) { var mainExitCommand = GetExitCommandFrom(location); var secondExitAlias = GetSecondaryExitAlias(mainExitCommand); if (!string.IsNullOrEmpty(mainExitCommand)) { var contextCommand = new ContextCommand(commands, mainExitCommand, ContextAvailability.ToChildren, SecurityRole.all); // TODO: OLC should take care to avoid duplicate exits in a room, but we might need more advanced protections to prevent needing // multiple context commands of the same alias from having to be attached to one Thing. (Try to keep fast command-finding.) Debug.Assert(!location.Commands.ContainsKey(mainExitCommand), "The Thing this ExitBehavior attached to already had command: " + mainExitCommand); location.Commands.Add(mainExitCommand, contextCommand); if (!string.IsNullOrEmpty(secondExitAlias)) { Debug.Assert(!location.Commands.ContainsKey(secondExitAlias), "The Thing this ExitBehavior attached to already had command: " + secondExitAlias); location.Commands.Add(secondExitAlias, contextCommand); } } }
/// <summary>Called when a parent has just been assigned to this behavior. (Refer to this.Parent.)</summary> public override void OnAddBehavior() { // When adding this behavior to a Thing, register relevant movement events so we can cancel // the movement of anything through our parent Thing while our parent Thing is "closed". var parent = this.Parent; if (parent != null) { parent.Eventing.MovementRequest += this.MovementRequestHandler; // Register the "open" and "close" context commands to be available to siblings of our parent, // and to the openable/closable thing's children (IE in case it can be entered itself). var contextAvailability = ContextAvailability.ToSiblings | ContextAvailability.ToChildren; var openContextCommand = new ContextCommand(this.commands, OpenString, contextAvailability, SecurityRole.all); var closeContextCommand = new ContextCommand(this.commands, CloseString, contextAvailability, SecurityRole.all); parent.Commands.Add(OpenString, openContextCommand); parent.Commands.Add(CloseString, closeContextCommand); } base.OnAddBehavior(); }
/// <summary>Called when a parent has just been assigned to this behavior. (Refer to Parent.)</summary> protected override void OnAddBehavior() { // When adding this behavior to a Thing, register relevant movement events so we can cancel // the movement of anything through our parent Thing while our parent Thing is "closed". var parent = Parent; if (parent != null) { parent.Eventing.MovementRequest += MovementRequestHandler; // Register the "open" and "close" context commands to be available to siblings of our parent, // and to the openable/closable thing's children (IE in case it can be entered itself). var contextAvailability = ContextAvailability.ToSiblings | ContextAvailability.ToChildren; var openContextCommand = new ContextCommand(commands, OpenString, contextAvailability, SecurityRole.all); var closeContextCommand = new ContextCommand(commands, CloseString, contextAvailability, SecurityRole.all); Debug.Assert(!parent.Commands.ContainsKey(OpenString), "The Thing this OpensClosesBehavior attached to already had an Open command."); Debug.Assert(!parent.Commands.ContainsKey(CloseString), "The Thing this OpensClosesBehavior attached to already had a Close command."); parent.Commands.Add(OpenString, openContextCommand); parent.Commands.Add(CloseString, closeContextCommand); } base.OnAddBehavior(); }
/// <summary> /// Called when a parent has just been assigned to this behavior. (Refer to this.Parent) /// </summary> public override void OnAddBehavior() { // When adding this behavior to a Thing, register relevant movement events so we can cancel // the movement of anything through our parent Thing while our parent Thing is "closed". var parent = this.Parent; if (parent != null) { parent.Eventing.MovementRequest += this.MovementRequestHandler; // Register the "open" and "close" context commands to be available to siblings of our parent, // and to the openable/closable thing's children (IE in case it can be entered itself). var contextAvailability = ContextAvailability.ToSiblings | ContextAvailability.ToChildren; var openContextCommand = new ContextCommand(this.commands, OpenString, contextAvailability, SecurityRole.all); var closeContextCommand = new ContextCommand(this.commands, CloseString, contextAvailability, SecurityRole.all); parent.Commands.Add(OpenString, openContextCommand); parent.Commands.Add(CloseString, closeContextCommand); } base.OnAddBehavior(); }
/// <summary> /// Called when a parent has just been assigned to this behavior. (Refer to this.Parent) /// </summary> public override void OnAddBehavior() { var parent = this.Parent; if (parent != null) { // When adding this behavior to a Thing, register relevant events so we can cancel // the opening of our parent Thing while our parent Thing is "locked". parent.Eventing.MiscellaneousRequest += this.RequestHandler; // Register the "lock" and "unlock" context commands to be available to siblings of our parent, // and to the lockable/unlockable thing's children (IE in case it can be entered itself). var contextAvailability = ContextAvailability.ToSiblings | ContextAvailability.ToChildren; var lockContextCommand = new ContextCommand(this.commands, LockString, contextAvailability, SecurityRole.all); var unlockContextCommand = new ContextCommand(this.commands, UnlockString, contextAvailability, SecurityRole.all); parent.Commands.Add(LockString, lockContextCommand); parent.Commands.Add(UnlockString, unlockContextCommand); } base.OnAddBehavior(); }
/// <summary> /// Add the appropriate exit context command(s) to the specified location. /// </summary> /// <param name="location">The location to add exit context command(s) to.</param> private void AddExitContextCommands(Thing location) { var mainExitCommand = this.GetExitCommandFrom(location); var secondExitAlias = this.GetSecondaryExitAlias(mainExitCommand); if (!string.IsNullOrEmpty(mainExitCommand)) { var contextCommand = new ContextCommand(this.commands, mainExitCommand, ContextAvailability.ToChildren, SecurityRole.all); location.Commands.Add(mainExitCommand, contextCommand); if (!string.IsNullOrEmpty(secondExitAlias)) { location.Commands.Add(secondExitAlias, contextCommand); } } }