public virtual void LeaveRoom(IMobileObject mob, Directions.Direction direction) { //do nothing unless overrode }
public virtual string EnqueueMessage(IMobileObject mob, string message) { //do nothing unless overrode return(message); }
public virtual void EnterRoom(IMobileObject mob) { //do nothing unless overrode }
public virtual void ProcessedCommunication(IMobileObject performer, string communication) { throw new NotImplementedException(); }
public virtual void ReturnedMessage(IMobileObject performer, string message) { throw new NotImplementedException(); }
public List <IItem> FindHeldItemsOnMob(IMobileObject mob, string keyword) { List <IItem> heldItems = mob.Items.Where(i => i.KeyWords.Contains(keyword, StringComparer.OrdinalIgnoreCase)).ToList(); return(heldItems); }
private static IResult RunAway(IMobileObject performer, List <IParameter> parameter) { IResult result = performer.Room.CheckFlee(performer); if (result == null) { bool redirect = false; List <Direction> exitDirections = GetRoomExits(performer); bool directionChoosen = false; Direction chosenDirection = Direction.Down; if (parameter.Count > 0) { Direction?localDirection = null; string direction = parameter[0].ParameterValue; switch (direction.ToUpper()) { case "N": case "NORTH": localDirection = Direction.North; break; case "E": case "EAST": localDirection = Direction.East; break; case "S": case "SOUTH": localDirection = Direction.South; break; case "W": case "WEST": localDirection = Direction.West; break; case "U": case "UP": localDirection = Direction.Up; break; case "D": case "DOWN": localDirection = Direction.Down; break; } if (localDirection != null) { if (exitDirections.Contains((Direction)localDirection)) { directionChoosen = true; chosenDirection = (Direction)localDirection; } else { redirect = true; chosenDirection = PickDirection(exitDirections); GlobalReference.GlobalValues.Notify.Mob(performer, new TranslationMessage($"You tried to flee {localDirection} but were unable to instead fled {chosenDirection}.")); } } else { chosenDirection = PickDirection(exitDirections); } } if (!directionChoosen) { chosenDirection = PickDirection(exitDirections); } IRoom proposedRoom = GetProposedRoom(performer.Room, chosenDirection); if (performer.Room.Leave(performer, chosenDirection, false)) { performer.Room = proposedRoom; proposedRoom.Enter(performer); if (!redirect) { GlobalReference.GlobalValues.Notify.Mob(performer, new TranslationMessage($"You flee {chosenDirection}.")); } return(GlobalReference.GlobalValues.CommandList.PcCommandsLookup["LOOK"].PerformCommand(performer, new Command())); } //the character was moved before they could move to the desired room. return(new Result("", false)); } else { return(result); } }
public void Close(IMobileObject performer, IItem item) { //do nothing unless overrode }
public virtual void Put(IMobileObject performer, IItem item, IContainer container) { //do nothing unless overrode }
public virtual void Cast(IMobileObject performer, string spellName) { //do nothing unless overrode }
public virtual void Perform(IMobileObject performer, string skillName) { //do nothing unless overrode }
public virtual void AttemptToFollow(Directions.Direction direction, IMobileObject performer, IMobileObject mob) { //do nothing unless overrode }
public virtual int ToHit(IMobileObject performer, int rolledValue) { //do nothing unless overrode return(rolledValue); }
private static void VerifyMob(IMobileObject mob) { string type = "MOB"; VerifyIds(mob, type); VerifyDescriptions(mob, type); foreach (IEnchantment enchantment in mob.Enchantments) { VerifyEnchantment(enchantment); } foreach (IItem item in mob.Items) { VerifyItem(item); } foreach (IItem item in mob.EquipedEquipment) { VerifyItem(item); } foreach (ISpell spell in mob.SpellBook.Values) { if (spell.PerformerNotificationSuccess == null) { ThrowConfigException(null, type, string.Format("Spell {0} performer success notification is null.", spell.SpellName)); } if (spell.RoomNotificationSuccess == null) { ThrowConfigException(null, type, string.Format("Spell {0} room success notification is null.", spell.SpellName)); } if (spell.TargetNotificationSuccess == null) { ThrowConfigException(null, type, string.Format("Spell {0} target success notification is null.", spell.SpellName)); } } foreach (ISkill skill in mob.KnownSkills.Values) { if (skill.PerformerNotificationSuccess == null) { ThrowConfigException(null, type, string.Format("Skill {0} performer success notification is null.", skill.SkillName)); } if (skill.RoomNotificationSuccess == null) { ThrowConfigException(null, type, string.Format("Skill {0} room success notification is null.", skill.SkillName)); } if (skill.TargetNotificationSuccess == null) { ThrowConfigException(null, type, string.Format("Skill {0} target success notification is null.", skill.SkillName)); } if (skill.PerformerNotificationFailure == null) { ThrowConfigException(null, type, string.Format("Skill {0} performer failure notification is null.", skill.SkillName)); } if (skill.RoomNotificationFailure == null) { ThrowConfigException(null, type, string.Format("Skill {0} room failure notification is null.", skill.SkillName)); } if (skill.TargetNotificationFailure == null) { ThrowConfigException(null, type, string.Format("Skill {0} target failure notification is null.", skill.SkillName)); } } }
public virtual void DamageAfterDefense(IMobileObject attacker, IMobileObject defender, int damageAmount, string attackerDescription = null) { //do nothing unless overrode }
public virtual void Stand(IMobileObject performer) { //do nothing unless overrode }
public virtual void DamageReceivedBeforeDefense(IMobileObject attacker, IMobileObject defender, int damageAmount) { //do nothing unless overrode }
public virtual void Unequip(IMobileObject performer, IItem item) { //do nothing unless overrode }
public bool AreFighting(IMobileObject mob) { return(GlobalReference.GlobalValues.Engine.Combat.AreFighting(this, mob)); }
/// <summary> /// Deserialize an object from DTO graph. /// </summary> ///<param name="deserialized">DTO group to deserialize</param> /// <returns></returns> public object DeserializeAsDTO(List <SerializationInfo> deserialized) { _deserializationReferences = new Dictionary <int, IMobileObject>(); foreach (SerializationInfo info in deserialized) { var typeName = AssemblyNameTranslator.GetAssemblyQualifiedName(info.TypeName); Type type = GetTypeFromCache(typeName); if (type == null) { throw new SerializationException(string.Format( Resources.MobileFormatterUnableToDeserialize, typeName)); } else if (type == typeof(NullPlaceholder)) { _deserializationReferences.Add(info.ReferenceId, null); } else { if (type.Equals(typeof(Security.CslaClaimsPrincipal))) { var state = info.GetValue <byte[]>("s"); using (var buffer = new System.IO.MemoryStream(state)) { using (var reader = new System.IO.BinaryReader(buffer)) { IMobileObject mobile = (IMobileObject) new Security.CslaClaimsPrincipal(reader); _deserializationReferences.Add(info.ReferenceId, mobile); } } } else { IMobileObject mobile = (IMobileObject)Activator.CreateInstance(type); _deserializationReferences.Add(info.ReferenceId, mobile); ConvertEnumsFromIntegers(info); mobile.SetState(info); } } } foreach (SerializationInfo info in deserialized) { IMobileObject mobile = _deserializationReferences[info.ReferenceId]; if (mobile != null) { mobile.SetChildren(info, this); } } foreach (SerializationInfo info in deserialized) { ISerializationNotification notifiable = _deserializationReferences[info.ReferenceId] as ISerializationNotification; if (notifiable != null) { notifiable.Deserialized(); } } return(_deserializationReferences.Count > 0 ? _deserializationReferences[1] : null); }