public override ComponentReplyMessage RecieveMessage(object sender, ComponentMessageType type, params object[] list) { ComponentReplyMessage reply = base.RecieveMessage(sender, type, list); if (sender == this) return ComponentReplyMessage.Empty; switch (type) { case ComponentMessageType.GetActorConnection: reply = new ComponentReplyMessage(ComponentMessageType.ReturnActorConnection, playerSession.ConnectedClient); break; case ComponentMessageType.GetActorSession: reply = new ComponentReplyMessage(ComponentMessageType.ReturnActorSession, playerSession); break; case ComponentMessageType.Die: playerSession.AddPostProcessingEffect(PostProcessingEffectType.Death, -1); IoCManager.Resolve<IRoundManager>().CurrentGameMode.PlayerDied(playerSession); // Tell the current game mode a player just died break; } return reply; }
public override ComponentReplyMessage RecieveMessage(object sender, ComponentMessageType type, params object[] list) { ComponentReplyMessage reply = base.RecieveMessage(sender, type, list); if (sender == this) //Don't listen to our own messages! return ComponentReplyMessage.Empty; switch (type) { case ComponentMessageType.ContextAdd: AddEntry((ContextMenuEntry) list[0]); break; case ComponentMessageType.ContextRemove: RemoveEntryByName((string) list[0]); break; case ComponentMessageType.ContextGetEntries: reply = new ComponentReplyMessage(ComponentMessageType.ContextGetEntries, _entries); break; } return reply; }
public override ComponentReplyMessage RecieveMessage(object sender, ComponentMessageType type, params object[] list) { ComponentReplyMessage reply = base.RecieveMessage(sender, type, list); if (sender == this) return ComponentReplyMessage.Empty; switch (type) { case ComponentMessageType.GetWearLoc: reply = new ComponentReplyMessage(ComponentMessageType.ReturnWearLoc, wearloc); break; } return reply; }
public override ComponentReplyMessage RecieveMessage(object sender, ComponentMessageType type, params object[] list) { ComponentReplyMessage reply = base.RecieveMessage(sender, type, list); if (sender == this) //Don't listen to our own messages! return ComponentReplyMessage.Empty; switch (type) { // TODO refactor me - GUI should reference component directly rather than doing this message shit case ComponentMessageType.GetCurrentLocationHealth: var location = (BodyPart) list[0]; if (DamageZones.Exists(x => x.Location == location)) { DamageLocation dmgLoc = DamageZones.First(x => x.Location == location); reply = new ComponentReplyMessage(ComponentMessageType.CurrentLocationHealth, location, dmgLoc.UpdateTotalHealth(), dmgLoc.MaxHealth); } break; } return reply; }
public override ComponentReplyMessage RecieveMessage(object sender, ComponentMessageType type, params object[] list) { ComponentReplyMessage reply = base.RecieveMessage(sender, type, list); if (sender == this) //Don't listen to our own messages! return ComponentReplyMessage.Empty; switch (type) { case ComponentMessageType.CheckSpriteClick: reply = new ComponentReplyMessage(ComponentMessageType.SpriteWasClicked, WasClicked((PointF) list[0]), DrawDepth); break; case ComponentMessageType.GetAABB: reply = new ComponentReplyMessage(ComponentMessageType.CurrentAABB, AABB); break; case ComponentMessageType.GetSprite: reply = new ComponentReplyMessage(ComponentMessageType.CurrentSprite, GetBaseSprite()); break; case ComponentMessageType.SetSpriteByKey: SetSpriteByKey((string) list[0]); break; case ComponentMessageType.SlaveAttach: SetMaster(Owner.EntityManager.GetEntity((int) list[0])); break; case ComponentMessageType.ItemUnEquipped: case ComponentMessageType.Dropped: UnsetMaster(); break; } return reply; }
public override ComponentReplyMessage RecieveMessage(object sender, ComponentMessageType type, params object[] list) { ComponentReplyMessage reply = ComponentReplyMessage.Empty; if (type != ComponentMessageType.Damage) reply = base.RecieveMessage(sender, type, list); if (sender == this) return ComponentReplyMessage.Empty; switch (type) { case ComponentMessageType.GetCurrentLocationHealth: var location = (BodyPart) list[0]; if (damageZones.Exists(x => x.location == location)) { DamageLocation dmgLoc = damageZones.First(x => x.location == location); var reply1 = new ComponentReplyMessage(ComponentMessageType.CurrentLocationHealth, location, dmgLoc.UpdateTotalHealth(), dmgLoc.maxHealth); reply = reply1; } break; case ComponentMessageType.Damage: if (list.Count() > 3) //We also have a target location ApplyDamage((Entity) list[0], (int) list[1], (DamageType) list[2], (BodyPart) list[3]); else //We dont have a target location ApplyDamage((Entity) list[0], (int) list[1], (DamageType) list[2]); break; case ComponentMessageType.Heal: if (list.Count() > 3) // We also have a target location ApplyHeal((Entity) list[0], (int) list[1], (DamageType) list[2], (BodyPart) list[3]); break; } return reply; }
public override ComponentReplyMessage RecieveMessage(object sender, ComponentMessageType type, params object[] list) { ComponentReplyMessage reply = base.RecieveMessage(sender, type, list); if (sender == this) //Don't listen to our own messages! return ComponentReplyMessage.Empty; switch (type) { case ComponentMessageType.CheckSpriteClick: reply = new ComponentReplyMessage(ComponentMessageType.SpriteWasClicked, WasClicked((PointF)list[0]), DrawDepth); break; case ComponentMessageType.GetAABB: reply = new ComponentReplyMessage(ComponentMessageType.CurrentAABB, AABB); break; case ComponentMessageType.GetSprite: reply = new ComponentReplyMessage(ComponentMessageType.CurrentSprite, sprite.GetCurrentSprite()); break; case ComponentMessageType.SlaveAttach: SetMaster(Owner.EntityManager.GetEntity((int)list[0])); break; case ComponentMessageType.ItemUnEquipped: case ComponentMessageType.Dropped: UnsetMaster(); break; case ComponentMessageType.MoveDirection: switch ((Direction)list[0]) { case Direction.North: sprite.Direction = Direction.North; break; case Direction.South: sprite.Direction = Direction.South; break; case Direction.East: sprite.Direction = Direction.East; break; case Direction.West: sprite.Direction = Direction.West; break; case Direction.NorthEast: sprite.Direction = Direction.NorthEast; break; case Direction.NorthWest: sprite.Direction = Direction.NorthWest; break; case Direction.SouthEast: sprite.Direction = Direction.SouthEast; break; case Direction.SouthWest: sprite.Direction = Direction.SouthWest; break; } break; case ComponentMessageType.EntitySaidSomething: ChatChannel channel; if (Enum.TryParse(list[0].ToString(), true, out channel)) { string text = list[1].ToString(); if (channel == ChatChannel.Ingame || channel == ChatChannel.Player || channel == ChatChannel.Radio) { (_speechBubble ?? (_speechBubble = new SpeechBubble(Owner.Name + Owner.Uid))).SetText(text); } } break; } return reply; }
public override ComponentReplyMessage RecieveMessage(object sender, ComponentMessageType type, params object[] list) { ComponentReplyMessage reply = base.RecieveMessage(sender, type, list); if (sender == this) return ComponentReplyMessage.Empty; switch (type) { /*case ComponentMessageType.ReceiveEmptyHandToItemInteraction: HandleEmptyHandToItemInteraction((Entity) list[0]); // param 0 is the actor entity, param 1 is the source actor entity break;*/ case ComponentMessageType.ReceiveItemToItemInteraction: //This message means we were clicked on by an actor with an item in hand HandleItemToItemInteraction((Entity) list[0]); // param 0 is the actor entity, param 1 is the source actor entity break; case ComponentMessageType.EnactItemToActorInteraction: ApplyTo((Entity) list[0], InteractsWith.Actor, (Entity) list[1]); break; case ComponentMessageType.EnactItemToItemInteraction: ApplyTo((Entity) list[0], InteractsWith.Item, (Entity) list[1]); break; case ComponentMessageType.EnactItemToLargeObjectInteraction: ApplyTo((Entity) list[0], InteractsWith.LargeObject, (Entity) list[1]); break; /*case ComponentMessageType.PickedUp: HandlePickedUp((Entity) list[0], (Hand) list[1]); break;*/ case ComponentMessageType.Dropped: HandleDropped(); break; case ComponentMessageType.ItemGetCapability: ItemCapability[] itemcaps = GetCapability((ItemCapabilityType) list[0]); if (itemcaps != null) reply = new ComponentReplyMessage(ComponentMessageType.ItemReturnCapability, itemcaps); break; case ComponentMessageType.ItemGetCapabilityVerbPairs: var verbpairs = new List<KeyValuePair<ItemCapabilityType, ItemCapabilityVerb>>(); foreach (ItemCapability capability in capabilities.Values) { foreach ( ItemCapabilityVerb verb in (from v in capability.verbs orderby v.Key descending select v.Value)) { verbpairs.Add( new KeyValuePair<ItemCapabilityType, ItemCapabilityVerb>(capability.CapabilityType, verb)); } } //if(verbpairs.Count > 0) reply = new ComponentReplyMessage(ComponentMessageType.ItemReturnCapabilityVerbPairs, verbpairs.ToLookup(v => v.Key, v => v.Value)); break; case ComponentMessageType.CheckItemHasCapability: reply = new ComponentReplyMessage(ComponentMessageType.ItemHasCapability, HasCapability((ItemCapabilityType) list[0])); break; case ComponentMessageType.ItemGetAllCapabilities: reply = new ComponentReplyMessage(ComponentMessageType.ItemReturnCapability, (object) GetAllCapabilities()); break; case ComponentMessageType.Activate: Activate(); break; case ComponentMessageType.ClickedInHand: Activate(); break; case ComponentMessageType.ItemEquipped: HandleDropped(); break; } return reply; }