public bool CanShow(InterfaceMetadata meta) { switch (meta.Type) { case InterfaceType.Main: return(Main == null); case InterfaceType.Sidebar: if (!meta.Index.InRange(0, MaxSidebarInterfaces)) { return(false); } return(_sidebars[meta.Index] == null); case InterfaceType.Chat: return(Chat == null); case InterfaceType.Input: return(Input == null); case InterfaceType.None: return(!_interfaces.ContainsKey(meta.Interface.Id)); default: throw new ArgumentOutOfRangeException(); } }
public bool Show(InterfaceMetadata meta) { // make sure sidebar idx is in range if (meta.Type == InterfaceType.Sidebar) { if (!meta.Index.InRange(0, MaxSidebarInterfaces)) { return(false); } } /* multiple checks to not allow duplicate interfaces to be queued up */ if (_interfaceIdsInQueue.Contains(meta.Interface.Id)) { return(false); } if (_interfaces.ContainsKey(meta.Interface.Id)) { return(false); } _interfaceIdsInQueue.Add(meta.Interface.Id); _queue.Add(meta); return(true); }
/// <summary> /// Create an instance to wrap the COM ptr. /// </summary> /// <param name="interfaceType">The interface type.</param> /// <returns>The created instance.</returns> public static IUnknownCcw CreateInstance(Type interfaceType) { var activator = Activators.GetOrAdd(interfaceType, (ty) => { var ctor = InterfaceMetadata.GetValue(ty).CcwType.GetConstructor(Type.EmptyTypes); return((Activator)Expression.Lambda(typeof(Activator), Expression.New(ctor)).Compile()); }); return((activator() as IUnknownCcw) !); }
public ItemActionMessage( ItemActionType itemActionType, [NotNull] IItemContainer container, InterfaceMetadata @interface, int itemIndexInContainer) { if (0 > itemIndexInContainer || itemIndexInContainer >= container.Provider.Count) { throw new ArgumentOutOfRangeException(nameof(itemIndexInContainer)); } ItemActionType = itemActionType; Container = container ?? throw new ArgumentNullException(nameof(container)); Interface = @interface; ItemIndexInContainer = itemIndexInContainer; }
private void Levelup(ISkillModel skill) { // fireworks Parent.ShowParticleEffect(ParticleEffect.LevelUp); // level up dialog var interf = Parent.GetInterfaces(); interf?.Show( InterfaceMetadata.Chat( new LevelUpChatInterface( skill.Id.LevelupInterfaceId, skill.Id.Name, skill.Level))); }
public static void ShowSidebar( [NotNull] this IInterfaceComponent interfaces, [NotNull] IGameInterface interf, byte sidebarIdx) { if (interfaces == null) { throw new ArgumentNullException(nameof(interfaces)); } if (interf == null) { throw new ArgumentNullException(nameof(interf)); } interfaces.Show(InterfaceMetadata.Sidebar(interf, sidebarIdx)); }
public void OnAction(IEntity parentEntity, IItemContainer itemsContainer, int itemIndexInContainer, InterfaceMetadata containerInterfaceMetadata, ItemStack item, int actionId) { // drop logic if (actionId == (int)ItemActionType.Drop) { var player = parentEntity.GetPlayer(); if (player != null) { itemsContainer.PlayerDropItem(itemIndexInContainer, player); return; } } parentEntity.SystemMessage($"Unimplemented item {ItemId} action {actionId}"); }
private void InitPlayer() { var net = Parent.GetNetwork(); if (net != null) { net.SendPacket(new InitializePlayerPacket(InstanceId, IsMember)); // TODO : delegate the retrieval of SetPlayerOptionPacket to the current Region net.SendPacket(SetPlayerOptionPacket.Follow); net.SendPacket(SetPlayerOptionPacket.TradeWith); net.SendPacket(SetPlayerOptionPacket.Report); } var interf = Parent.GetInterfaces(); if (interf != null) { var db = Parent.Server.Services.GetService <IInterfaceIdDatabase>(); if (db != null) { interf.ShowSidebar(new UnimplementedSidebarInterface(db.SkillSidebar, db.SkillSidebarIdx), db.SkillSidebarIdx); interf.ShowSidebar(new UnimplementedSidebarInterface(db.QuestSidebar, db.QuestSidebarIdx), db.QuestSidebarIdx); interf.ShowSidebar(new UnimplementedSidebarInterface(db.PrayerSidebar, db.PrayerSidebarIdx), db.PrayerSidebarIdx); // todo : different spellbooks interf.ShowSidebar(new UnimplementedSidebarInterface(db.StandardSpellbookSidebar, db.SpellbookSidebarIdx), db.SpellbookSidebarIdx); interf.ShowSidebar(new UnimplementedSidebarInterface(db.FriendsListSidebar, db.FriendsSidebarIdx), db.FriendsSidebarIdx); interf.ShowSidebar(new UnimplementedSidebarInterface(db.IgnoreListSidebar, db.IgnoresSidebarIdx), db.IgnoresSidebarIdx); interf.ShowSidebar(new UnimplementedSidebarInterface(db.LogoutSidebar, db.LogoutSidebarIdx), db.LogoutSidebarIdx); // todo : high and low detail interf.ShowSidebar(new UnimplementedSidebarInterface(db.OptionsHighDetailSidebar, db.OptionsSidebarIdx), db.OptionsSidebarIdx); interf.ShowSidebar(new UnimplementedSidebarInterface(db.ControlsSidebar, db.ControlsSidebarIdx), db.ControlsSidebarIdx); interf.ShowSidebar(new UnimplementedSidebarInterface(db.BackpackSidebar, db.BackpackSidebarIdx), db.BackpackSidebarIdx); interf.ShowSidebar(new UnimplementedSidebarInterface(db.EquipmentSidebar, db.EquipmentSidebarIdx), db.EquipmentSidebarIdx); var items = Parent.AssertGetPlayerContainers(); interf.Show(InterfaceMetadata.Register(new InventoryInterface(db.BackpackContainer, items.Backpack))); interf.Show(InterfaceMetadata.Register(new InventoryInterface(db.EquipmentContainer, items.Equipment))); } else { Parent.SystemMessage("Cannot intialize player sidebars due to there not being a InterfaceIdDatabase in the server's IServerProvider.", CoreSystemMessageFlags.Debug | CoreSystemMessageFlags.Entity); } } }
public ItemOnItemMessage( InterfaceMetadata metaA, [NotNull] IItemContainer containerA, int indexA, InterfaceMetadata metaB, [NotNull] IItemContainer containerB, int indexB) { if (0 > indexA || containerA.Provider.Count >= indexA) { throw new ArgumentOutOfRangeException(nameof(indexA)); } if (0 > indexB || containerB.Provider.Count >= indexB) { throw new ArgumentOutOfRangeException(nameof(indexB)); } ContainerA = containerA ?? throw new ArgumentNullException(nameof(containerA)); ContainerB = containerB ?? throw new ArgumentNullException(nameof(containerB)); MetaA = metaA; IndexA = indexA; MetaB = metaB; IndexB = indexB; }
/// <summary> /// Does no checks to see if the interface can be shown. /// Registers an interface as shown, adds it to the all list and makes it "alive" /// immediatelly /// </summary> private void InternalShow(InterfaceMetadata meta) { _interfaces.Add(meta.Interface.Id, meta); switch (meta.Type) { case InterfaceType.Main: Main = meta.Interface; break; case InterfaceType.Sidebar: _sidebars[meta.Index] = meta.Interface; break; case InterfaceType.Chat: Chat = meta.Interface; break; case InterfaceType.Input: Input = meta.Interface; break; case InterfaceType.None: _interfaces[meta.Interface.Id] = meta; break; default: throw new ArgumentOutOfRangeException(); } _interfaces[meta.Interface.Id] = meta; meta.Interface.ShowForEntity(Parent); }
public void OnAction(IEntity parentEntity, IItemContainer itemsContainer, int itemIndexInContainer, InterfaceMetadata containerInterfaceMetadata, ItemStack item, int actionId) { }