public MapIcon(EntityWrapper entityWrapper, HudTexture hudTexture, Func<bool> show, int iconSize = 10) { EntityWrapper = entityWrapper; TextureIcon = hudTexture; this.show = show; Size = iconSize; }
public unsafe Vector2 WorldToScreen(Vector3 vec3, EntityWrapper entityWrapper) { var isplayer = Game.IngameState.Data.LocalPlayer.IsValid && Game.IngameState.Data.LocalPlayer.Address == entityWrapper.Address; var isMoving = Game.IngameState.Data.LocalPlayer.GetComponent<Actor>().isMoving; float x, y; int addr = base.Address + 0xbc; fixed (byte* numRef = base.M.ReadBytes(addr, 0x40)) { Matrix matrix = *(Matrix*)numRef; Vector4 cord = *(Vector4*)&vec3; cord.W = 1; cord = Vector4.Transform(cord, matrix); cord = Vector4.Divide(cord, cord.W); x = ((cord.X + 1.0f) * 0.5f) * Width; y = ((1.0f - cord.Y) * 0.5f) * Height; } var resultCord = new Vector2(x, y); if (isMoving && isplayer) { if (Math.Abs(oldplayerCord.X - resultCord.X) < 40 || (Math.Abs(oldplayerCord.X - resultCord.Y) < 40)) resultCord = oldplayerCord; else oldplayerCord = resultCord; } else if (isplayer) { oldplayerCord = resultCord; } return resultCord; }
public void EntityAdded(EntityWrapper entity) { if (!Settings.Enabled || currentIcons.ContainsKey(entity)) { return; } if (entity.IsAlive && entity.HasComponent<Poe.EntityComponents.Monster>()) { currentIcons[entity] = GetMapIconForMonster(entity); string text = entity.Path; if (text.Contains('@')) { text = text.Split('@')[0]; } if (NamesToAlertOf.ContainsKey(text)) { addEntity(entity, NamesToAlertOf[text]); return; } foreach (string current in entity.GetComponent<ObjectMagicProperties>().Mods.Where(current => ModsToAlertOf.ContainsKey(current))) { addEntity(entity, ModsToAlertOf[current]); } } }
public void EntityAdded(EntityWrapper entity) { if (!Settings.Enabled || currentAlerts.ContainsKey(entity)) { return; } if (!entity.HasComponent<WorldItem>()) return; EntityWrapper item = new EntityWrapper(model, entity.GetComponent<WorldItem>().ItemEntity); ItemUsefulProperties props = EvaluateItem(item); if (!props.IsWorthAlertingPlayer(Settings, currencyNames)) return; AlertDrawStyle drawStyle = props.GetDrawStyle(); currentAlerts.Add(entity, drawStyle); drawStyle.IconForMap = new MapIcon(entity, new HudTexture("minimap_default_icon.png", drawStyle.color), 8) { Type = MapIcon.IconType.Item }; if (Settings.PlaySound && drawStyle.soundToPlay != null && !playedSoundsCache.Contains(entity.LongId)) { playedSoundsCache.Add(entity.LongId); drawStyle.soundToPlay.Play(); } ItemsOnGroundLabelElement labeledItem = model.Internal.IngameState.IngameUi.ItemsOnGroundLabels.FirstOrDefault(z => z.ItemOnGround.Address == entity.Address); if(labeledItem != null) { groundItemLabels.Add(labeledItem); } }
public void EntityAdded(EntityWrapper entity) { Healthbar healthbarSettings = this.GetHealthbarSettings(entity); if (healthbarSettings != null) { this.healthBars[(int)healthbarSettings.prio].Add(healthbarSettings); } }
public ICompletionData CreateEntityCompletionData(IEntity entity) { EntityWrapper<IEntity> entityWrapper = new EntityWrapper<IEntity>(entity); return new CompletionData(entityWrapper.CompletionDataType, entity.Name, priority: 2, description: entityWrapper.EntityDescription) { CompletionText = entityWrapper.AmbienceDescription, DisplayText = entity.Name, }; }
public void EntityRemoved(EntityWrapper entity) { string ktd = null; foreach (KeyValuePair<string, List<EntityWrapper>> kv in alertsText) { kv.Value.Remove(entity); if (kv.Value.Count == 0) ktd = kv.Key; } if (null != ktd) alertsText.Remove(ktd); currentIcons.Remove(entity); }
public void Should_Add_Item() { // Arrange var entity = new EntityWrapper(); // Act _repository.Add(entity); // Assert var added = _context.Set <EntityWrapper>().Find(entity.Id); Assert.Equal(added.Id, entity.Id); Assert.Equal(added, entity); }
public static void Set(EntityWrapper entity, Material mat, int slot = 0) { #if !(RELEASE && RELEASE_DISABLE_CHECKS) if (entity == null) { throw new ArgumentNullException("entity"); } if (mat == null) { throw new ArgumentNullException("mat"); } #endif MaterialInterop.SetMaterial(entity.EntityHandle, mat.Handle, slot); }
private void FillTimeClocks() { List <TimeClock> timeClocks = EntityWrapper.GetTimeClocksByUserId(UserManager.GetCurrentUser().Guid); List <TimeClockItem> timeClockItems = new List <TimeClockItem>(); for (int i = 0; i < timeClocks.Count; i++) { timeClockItems.Add(new TimeClockItem(timeClocks[i].Offset, timeClocks[i].Name, timeClocks[i].Guid)); } listBox.ItemsSource = timeClockItems; for (int i = 0; i < timeClockItems.Count; i++) { AddThread(timeClockItems[i]); } }
private MapIcon GetMapIcon(EntityWrapper e) { if (e.HasComponent <NPC>() && masters.Contains(e.Path)) { return(new CreatureMapIcon(e, "ms-cyan.png", () => Settings.Masters, 8)); } if (e.HasComponent <Chest>() && !e.GetComponent <Chest>().IsOpened) { return(e.GetComponent <Chest>().IsStrongbox ? new ChestMapIcon(e, new HudTexture("strongbox.png", e.GetComponent <ObjectMagicProperties>().Rarity), () => Settings.Strongboxes, 16) : new ChestMapIcon(e, new HudTexture("chest.png"), () => Settings.Chests, 3)); } return(null); }
internal void _EntityAdded(EntityWrapper entityWrapper) { if (DisableDueToError) { return; } if (!_initialized || !_allowRender) { return; } try { EntityAdded(entityWrapper); } catch (MissingMemberException me) { ProcessMissingMemberException(me, "EntityAdded"); } catch (Exception e) { HandlePluginError("EntityAdded", e); } }
//Copy-Paste - Sithylis_QoL private IEnumerator SetCursorToEntityAndClick(EntityWrapper entity) { var camera = GameController.Game.IngameState.Camera; var chestScreenCoords = camera.WorldToScreen(entity.Pos.Translate(0, 0, 0), entity); if (chestScreenCoords != new Vector2()) { var pos = Mouse.GetCursorPosition(); var iconRect1 = new Vector2(chestScreenCoords.X, chestScreenCoords.Y); yield return(Mouse.SetCursorPosAndLeftClick(iconRect1, 100)); Mouse.SetCursorPos(pos.X, pos.Y); } }
public void ProcessEntityObfuscateStringFields() { // Arrange CrmGenericImporterConfig config = GetCrmConfigWithFieldsToObfuscate(); string firstnameBefore = "Bob"; string surnameBefore = "Tester"; Entity entity = new Entity("contact"); entity.Attributes.Add("firstname", firstnameBefore); entity.Attributes.Add("surname", surnameBefore); EntityWrapper entityWrapper = new EntityWrapper(entity); List <FieldToBeObfuscated> fiedlsToBeObfuscated = new List <FieldToBeObfuscated> { new FieldToBeObfuscated() { FieldName = "firstname" } }; EntityToBeObfuscated entityToBeObfuscated = new EntityToBeObfuscated() { EntityName = "contact" }; entityToBeObfuscated.FieldsToBeObfuscated.AddRange(fiedlsToBeObfuscated); var fieldToBeObfuscated = new List <EntityToBeObfuscated> { entityToBeObfuscated }; config.FieldsToObfuscate.AddRange(fieldToBeObfuscated); // Act ObfuscateFieldsProcessor processor = new ObfuscateFieldsProcessor(MockEntityMetadataCache.Object, config.FieldsToObfuscate); processor.ProcessEntity(entityWrapper, 1, 1); string firstnameAfter = (string)entity["firstname"]; string surnameAfter = (string)entity["surname"]; // Assert Assert.AreNotEqual(firstnameBefore, firstnameAfter); Assert.AreEqual(surnameBefore, surnameAfter); }
public override void EntityAdded(EntityWrapper _Entity) { if (_Entity.HasComponent <Monster>() && _Entity.IsAlive) { Session.Instance.CurrentArea.Monsters.Add(_Entity); } else if (_Entity.HasComponent <WorldItem>() || _Entity.GetComponent <WorldItem>().ItemEntity.HasComponent <Mods>()) { Session.Instance.CurrentArea.Items.Add(_Entity); } /*if ((_Entity.HasComponent<Monster>() && _Entity.IsAlive) || (_Entity.GetComponent<WorldItem>().ItemEntity.HasComponent<Mods>() || _Entity.HasComponent<WorldItem>())) * { * Session.Instance.CurrentArea.UsefullEntities.Add(_Entity); * }*/ }
public override void EntityRemoved(EntityWrapper entityWrapper) { if (entityWrapper.HasComponent <Monster>()) { Session.Instance.CurrentArea.Monsters.Remove(entityWrapper); } else if (entityWrapper.HasComponent <WorldItem>() || entityWrapper.GetComponent <WorldItem>().ItemEntity.HasComponent <Mods>()) { Session.Instance.CurrentArea.Items.Remove(entityWrapper); } /*if(Session.Instance.CurrentArea.UsefullEntities.Contains(entityWrapper)) * { * Session.Instance.CurrentArea.UsefullEntities.Remove(entityWrapper); * }*/ }
public void ProcessEntity() { var idAliasKey = "Blogs"; var entity = new Entity("contact", Guid.NewGuid()); entity.Attributes["firstname"] = "Joe"; entity.Attributes["firstname"] = "Blogs"; var entityWrapper = new EntityWrapper(entity); mockEntityMetadataCache.Setup(a => a.GetIdAliasKey(It.IsAny <string>())).Returns(idAliasKey); FluentActions.Invoking(() => systemUnderTest.ProcessEntity(entityWrapper, 1, 3)) .Should() .NotThrow(); }
public HealthBar(EntityWrapper entity, HealthBarSettings settings) { Entity = entity; if (entity.HasComponent <Player>()) { Type = CreatureType.Player; Settings = settings.Players; IsValid = true; } else if (entity.HasComponent <Monster>()) { IsValid = true; if (entity.IsHostile) { isHostile = true; switch (entity.GetComponent <ObjectMagicProperties>().Rarity) { case MonsterRarity.White: Type = CreatureType.Normal; Settings = settings.NormalEnemy; break; case MonsterRarity.Magic: Type = CreatureType.Magic; Settings = settings.MagicEnemy; break; case MonsterRarity.Rare: Settings = settings.RareEnemy; Type = CreatureType.Rare; break; case MonsterRarity.Unique: Settings = settings.UniqueEnemy; Type = CreatureType.Unique; break; } } else { Type = CreatureType.Minion; Settings = settings.Minions; } } Life = Entity.GetComponent <Life>(); lastHp = GetFullHp(); }
public void handleSockets(EntityWrapper entityWrapper) { var socket = entityWrapper.GetComponent <WorldItem>().ItemEntity.GetComponent <Sockets>(); if (socket.LargestLinkSize == 6) { miscData.total6LDrops++; } else if (socket.NumberOfSockets == 6) { miscData.total6SDrops++; } else if (IsContainSocketGroup(socket.SocketGroup, "RGB")) { miscData.totalRGBDrops++; } }
public void ProcessEntity_ObfuscateDecimalFields() { // Arrange CrmGenericImporterConfig config = GetCrmConfigWithFieldsToObfuscate(); InitializeEntityMetadata(); MockEntityMetadataCache .Setup(cache => cache.GetAttribute("contact", "creditlimit")) .Returns(new DecimalAttributeMetadata()); decimal creditLimitBefore = 1000M; Entity entity = new Entity("contact"); entity.Attributes.Add("creditlimit", creditLimitBefore); EntityWrapper entityWrapper = new EntityWrapper(entity); List <FieldToBeObfuscated> fiedlsToBeObfuscated = new List <FieldToBeObfuscated>(); fiedlsToBeObfuscated.Add(new FieldToBeObfuscated() { FieldName = "creditlimit" }); EntityToBeObfuscated entityToBeObfuscated = new EntityToBeObfuscated() { EntityName = "contact", FieldsToBeObfuscated = fiedlsToBeObfuscated }; var fieldToBeObfuscated = new List <EntityToBeObfuscated>(); fieldToBeObfuscated.Add(entityToBeObfuscated); config.FieldsToObfuscate = fieldToBeObfuscated; // Act ObfuscateFieldsProcessor processor = new ObfuscateFieldsProcessor(MockEntityMetadataCache.Object, config.FieldsToObfuscate); processor.ProcessEntity(entityWrapper, 1, 1); decimal creditLimitAfter = (decimal)entity["creditlimit"]; // Assert Assert.AreNotEqual(creditLimitBefore, creditLimitAfter); }
public void ProcessEntityEntityWhichHasMapFieldButDoesntHaveOneOfMapValuesShouldNotUpdateTheEntitiesAttributes() { ObjectTypeCodeMappingConfiguration config = CreateConfiguration("cap_testentity", 10113, "cap_testfield"); systemUnderTest = new ObjectTypeCodeProcessor(config, MockLogger.Object, MockEntityRepo.Object); string expectedFieldName = "cap_testfield"; int expectedFieldValue = 10222; Entity entity = new Entity("cap_testentity"); entity.Attributes.Add(expectedFieldName, expectedFieldValue); EntityWrapper entityWrapper = new EntityWrapper(entity); systemUnderTest.ProcessEntity(entityWrapper, 0, 1); Assert.AreEqual(expectedFieldValue, entityWrapper.OriginalEntity[expectedFieldName]); }
public void ProcessEntityDonNotRemoveZeropassFields() { string textAttributeName = "some text field"; string textAttributeValue = "some random value"; Entity entity = new Entity(passOneReferences.First()); entity.Attributes.Add(textAttributeName, textAttributeValue); EntityWrapper entityWrapper = new EntityWrapper(entity); PassType pass = PassType.CreateRequiredEntity; systemUnderTest.ProcessEntity(entityWrapper, (int)pass, 100); Assert.IsTrue(entity.Attributes.Contains(textAttributeName)); Assert.AreEqual(textAttributeValue, entity.GetAttributeValue <string>(textAttributeName)); }
public void ProcessEntity_ObfuscateDoubleFields() { // Arrange CrmGenericImporterConfig config = GetCrmConfigWithFieldsToObfuscate(); InitializeEntityMetadata(); MockEntityMetadataCache .Setup(cache => cache.GetAttribute("contact", "address1_latitude")) .Returns(new DoubleAttributeMetadata()); double latitudeBefore = 51.5178737; Entity entity = new Entity("contact"); entity.Attributes.Add("address1_latitude", latitudeBefore); EntityWrapper entityWrapper = new EntityWrapper(entity); List <FieldToBeObfuscated> fieldsToBeObfuscated = new List <FieldToBeObfuscated>(); fieldsToBeObfuscated.Add(new FieldToBeObfuscated() { FieldName = "address1_latitude" }); EntityToBeObfuscated entityToBeObfuscated = new EntityToBeObfuscated() { EntityName = "contact", FieldsToBeObfuscated = fieldsToBeObfuscated }; var fieldToBeObfuscated = new List <EntityToBeObfuscated>(); fieldToBeObfuscated.Add(entityToBeObfuscated); config.FieldsToObfuscate = fieldToBeObfuscated; // Act ObfuscateFieldsProcessor processor = new ObfuscateFieldsProcessor(MockEntityMetadataCache.Object, config.FieldsToObfuscate); processor.ProcessEntity(entityWrapper, 1, 1); double latitudeAfter = (double)entity["address1_latitude"]; // Assert Assert.AreNotEqual(latitudeBefore, latitudeAfter); }
protected override void OnEntityAdded(EntityWrapper entityWrapper) { if (!Settings.Enable) { return; } if (entityWrapper.HasComponent <Monster>()) { if (entityWrapper.IsAlive) { aliveEntities.Add(entityWrapper); } else { Calc(entityWrapper); } } }
public void EntityRemoved(EntityWrapper entity) { string ktd = null; foreach (KeyValuePair <string, List <EntityWrapper> > kv in alertsText) { kv.Value.Remove(entity); if (kv.Value.Count == 0) { ktd = kv.Key; } } if (null != ktd) { alertsText.Remove(ktd); } currentIcons.Remove(entity); }
public HealthBar(EntityWrapper entity, HealthBarSettings settings) { Entity = entity; if (entity.HasComponent<Player>()) { Type = CreatureType.Player; Settings = settings.Players; IsValid = true; } else if (entity.HasComponent<Monster>()) { IsValid = true; if (entity.IsHostile) { isHostile = true; switch (entity.GetComponent<ObjectMagicProperties>().Rarity) { case MonsterRarity.White: Type = CreatureType.Normal; Settings = settings.NormalEnemy; break; case MonsterRarity.Magic: Type = CreatureType.Magic; Settings = settings.MagicEnemy; break; case MonsterRarity.Rare: Settings = settings.RareEnemy; Type = CreatureType.Rare; break; case MonsterRarity.Unique: Settings = settings.UniqueEnemy; Type = CreatureType.Unique; break; } } else { Type = CreatureType.Minion; Settings = settings.Minions; } } Life = Entity.GetComponent<Life>(); lastHp = GetFullHp(); }
protected override void OnUpdate() { Entities .WithAll <NetworkIdComponent>() .WithNone <NetworkStreamInGame>() .ForEach((Entity connectionEntity, ref NetworkIdComponent networkIdComponent) => { Debug.Log($"[Server] Client connected with network id = [{networkIdComponent.Value}]"); EntityWrapper.Wrap(connectionEntity, EntityManager) .SetName($"ClientConnection_{networkIdComponent.Value}"); var connectionCommandHandler = EntityWrapper.CreateEntity(EntityManager) .AddComponentData(new ServerToClientCommandHandler { connectionEntity = connectionEntity }) .SetName($"ClientConnection_{networkIdComponent.Value}_CommandBuffer") .Entity; PostUpdateCommands.SetComponent(connectionEntity, new CommandTargetComponent { targetEntity = connectionCommandHandler }); PostUpdateCommands.AddComponent <NetworkStreamInGame>(connectionEntity); ServerManager.Instance.OnConnected(networkIdComponent.Value, connectionEntity, connectionCommandHandler); var ghostCollection = GetSingletonEntity <GhostPrefabCollectionComponent>(); var prefab = Entity.Null; var prefabs = EntityManager.GetBuffer <GhostPrefabBuffer>(ghostCollection); for (int ghostId = 0; ghostId < prefabs.Length; ++ghostId) { if (EntityManager.HasComponent <SyncGhostComponent>(prefabs[ghostId].Value)) { prefab = prefabs[ghostId].Value; } } EntityWrapper.Instantiate(prefab, PostUpdateCommands) .SetName($"ClientConnection_{networkIdComponent.Value}_Ghost") .AddComponentData(new GhostOwnerComponent { NetworkId = networkIdComponent.Value }); }); }
private EntityWrapper ToEntityWrapper(EntityType entityType, int entityID) { if (entityID == 0) { return(null); } var result = new EntityWrapper { EntityId = entityID }; switch (entityType) { case EntityType.Case: var caseObj = DaoFactory.CasesDao.GetByID(entityID); if (caseObj == null) { return(null); } result.EntityType = "case"; result.EntityTitle = caseObj.Title; break; case EntityType.Opportunity: var dealObj = DaoFactory.DealDao.GetByID(entityID); if (dealObj == null) { return(null); } result.EntityType = "opportunity"; result.EntityTitle = dealObj.Title; break; default: return(null); } return(result); }
protected TEntity BaseCreate(TEntity entity, Dictionary <string, string> parameters = null) { Parameters = parameters ?? new Dictionary <string, string>(); var requestUriString = GetUrl(); requestUriString = AddParameters(requestUriString); Method = "POST"; ResponseType = RequestResponseType.JSON; RequestUriString = requestUriString; var wrappedEntity = new EntityWrapper <TEntity>() { Entity = entity }; return(DoRequest(wrappedEntity)?.Entity); }
public void ProcessEntityWithAttributeToBeDeleted() { var originalEntity = new Entity("contact"); originalEntity.Attributes["firstname"] = "Joe"; originalEntity.Attributes["lastname"] = "Bloggs"; originalEntity.Attributes["dateofbirth"] = DateTime.UtcNow; originalEntity.Attributes["BE DELETEDheight"] = DateTime.UtcNow; var entityWrapper = new EntityWrapper(originalEntity) { OperationType = OperationType.Create }; int passNumber = 1; int maxPassNumber = 3; FluentActions.Invoking(() => systemUnderTest.ProcessEntity(entityWrapper, passNumber, maxPassNumber)) .Should() .NotThrow(); }
private EntityWrapper ToEntityWrapper(EntityType entityType, int entityID) { if (entityID == 0) { return(null); } var result = new EntityWrapper { EntityId = entityID }; switch (entityType) { case EntityType.Case: result.EntityType = "case"; var cases = DaoFactory.GetCasesDao().GetByID(entityID); if (cases != null) { result.EntityTitle = cases.Title; } break; case EntityType.Opportunity: result.EntityType = "opportunity"; var obj = DaoFactory.GetDealDao().GetByID(entityID); if (obj != null) { result.EntityTitle = obj.Title; } break; default: return(null); } return(result); }
public override void EntityAdded(EntityWrapper entity) { if (!Settings.EnableBorders.Value) { return; } if (!Settings.Enable || entity == null || GameController.Area.CurrentArea.IsTown || _currentAlerts.ContainsKey(entity) || !entity.HasComponent <WorldItem>()) { return; } var item = entity.GetComponent <WorldItem>().ItemEntity; var visitResult = ProcessItem(item); if (visitResult == null) { return; } if (Settings.IgnoreOneHanded && visitResult.ItemType == StashItemType.OneHanded) { visitResult = null; } if (visitResult == null) { return; } var index = (int)visitResult.ItemType; if (index > 7) { index = 0; } var displData = DisplayData[index]; _currentAlerts.Add(entity, displData); }
public static void ApplyExplosionForce(EntityWrapper objectHit, Vector3 forceCenter, float forceMagnitude = 100f) { if (forceMagnitude.IsAlmost(0)) { return; } Vector3 forceDirection = objectHit.transform.position - forceCenter; var rbComp = objectHit.Entity.GetComponentDownward <RigidbodyComp>()?.rigidbody; if (rbComp == null) { return; } Vector3 added = forceDirection.normalized * forceMagnitude * 10; //Debug.Log($"Applying force to {objectHit.gameObject.name}: {added}"); rbComp.AddForce(forceDirection.normalized * forceMagnitude * 100, ForceMode.Impulse); }
public void ObfuscateStringFieldsTest() { var orgService = ConnectionHelper.GetOrganizationalServiceTarget(); var cache = new EntityMetadataCache(orgService); List <FieldToBeObfuscated> fiedlsToBeObfuscated = new List <FieldToBeObfuscated> { new FieldToBeObfuscated() { FieldName = "firstname" } }; EntityToBeObfuscated entityToBeObfuscated = new EntityToBeObfuscated() { EntityName = "contact" }; entityToBeObfuscated.FieldsToBeObfuscated.AddRange(fiedlsToBeObfuscated); var fieldsToBeObfuscated = new List <EntityToBeObfuscated> { entityToBeObfuscated }; ObfuscateFieldsProcessor processor = new ObfuscateFieldsProcessor(cache, fieldsToBeObfuscated); string beforeFirstName = "Bob"; string beforeLastName = "test"; Entity ent = new Entity("contact"); ent.Attributes.Add("firstname", beforeFirstName); ent.Attributes.Add("lastname", beforeLastName); EntityWrapper entWrap = new EntityWrapper(ent); processor.ProcessEntity(entWrap, 1, 1); Assert.AreNotEqual(beforeFirstName, entWrap.OriginalEntity.Attributes["firstname"]); Assert.AreEqual(beforeLastName, entWrap.OriginalEntity.Attributes["lastname"]); }
public EntityLabel GetLabelForEntity(EntityWrapper entity) { var hashSet = new HashSet<int>(); int entityLabelMap = gameController.Game.IngameState.EntityLabelMap; int num = entityLabelMap; while (true) { hashSet.Add(num); if (gameController.Memory.ReadInt(num + 8) == entity.Address) { break; } num = gameController.Memory.ReadInt(num); if (hashSet.Contains(num) || num == 0 || num == -1) { return null; } } return gameController.Game.ReadObject<EntityLabel>(num + 12); }
} //TODO: Remove, temporary workaround protected async Task <TEntity> BaseCreate(TEntity entity) { RequestInfo = new RequestInfo() { BaseUrl = BaseUrl, Resource = Resource, Indices = Array.Empty <string>(), Parameters = ParametersInjection ?? new Dictionary <string, string>(), Method = HttpMethod.Post, }; ParametersInjection = null; var wrappedEntity = new EntityWrapper <TEntity>() { Entity = entity }; var result = await DoEntityRequest(wrappedEntity).ConfigureAwait(false); return(result?.Entity); }
protected override void OnEntityAdded(EntityWrapper entity) { if (Settings.Enable && entity != null && !GameController.Area.CurrentArea.IsTown && !currentAlerts.ContainsKey(entity) && entity.HasComponent <WorldItem>()) { IEntity item = entity.GetComponent <WorldItem>().ItemEntity; ItemUsefulProperties props = initItem(item); if (props.ShouldAlert(currencyNames, Settings)) { AlertDrawStyle drawStyle = props.GetDrawStyle(); currentAlerts.TryAdd(entity, drawStyle); CurrentIcons[entity] = new MapIcon(entity, new HudTexture("minimap_default_icon.png", drawStyle.AlertColor), () => Settings.ShowItemOnMap, 8); if (Settings.PlaySound && !playedSoundsCache.Contains(entity.LongId)) { playedSoundsCache.Add(entity.LongId); Sounds.AlertSound.Play(); } } } }
protected override void OnEntityAdded(EntityWrapper entity) { if (!Settings.Enable) // Plugin not enabled { return; } if (entity.HasComponent <WorldItem>()) // Dropped in World ? { IEntity item = entity.GetComponent <WorldItem>().ItemEntity; if (countedIds.Contains(item.Id)) // Already counted. Do Noting ! { return; } countedIds.Add(item.Id); var mods = item.GetComponent <Mods>(); ItemRarity rarity = mods.ItemRarity; counters[rarity] += 1; totalDrops += 1; File.AppendAllText(Environment.CurrentDirectory + "\\drops.txt", String.Format("{0} -> {1}{2}", item.Id, item.ToString(), Environment.NewLine)); } }
private void Calc(EntityWrapper entityWrapper) { HashSet <long> monstersHashSet; var areaHash = gameController.Area.CurrentArea.Hash; if (!countedIds.TryGetValue(areaHash, out monstersHashSet)) { monstersHashSet = new HashSet <long>(); countedIds[areaHash] = monstersHashSet; } if (!monstersHashSet.Contains(entityWrapper.LongId)) { monstersHashSet.Add(entityWrapper.LongId); MonsterRarity rarity = entityWrapper.GetComponent <ObjectMagicProperties>().Rarity; if (entityWrapper.IsHostile && counters.ContainsKey(rarity)) { counters[rarity]++; summaryCounter++; } } }
public void RefreshState() { UpdatePlayer(); if (gameController.Area.CurrentArea == null) return; Dictionary<int, Entity> newEntities = gameController.Game.IngameState.Data.EntityList.EntitiesAsDictionary; var newCache = new Dictionary<int, EntityWrapper>(); foreach (var keyEntity in newEntities) { if (!keyEntity.Value.IsValid) continue; int entityAddress = keyEntity.Key; string uniqueEntityName = keyEntity.Value.Path + entityAddress; if (ignoredEntities.Contains(uniqueEntityName)) continue; if (entityCache.ContainsKey(entityAddress) && entityCache[entityAddress].IsValid) { newCache.Add(entityAddress, entityCache[entityAddress]); entityCache[entityAddress].IsInList = true; entityCache.Remove(entityAddress); continue; } var entity = new EntityWrapper(gameController, keyEntity.Value); if ((entity.Path.StartsWith("Metadata/Effects") || ((entityAddress & 0x80000000L) != 0L)) || entity.Path.StartsWith("Metadata/Monsters/Daemon")) { ignoredEntities.Add(uniqueEntityName); continue; } EntityAdded?.Invoke(entity); newCache.Add(entityAddress, entity); } RemoveOldEntitiesFromCache(); entityCache = newCache; }
private void addEntity(EntityWrapper entity, string key) { List<EntityWrapper> lew; if (!alertsText.TryGetValue(key, out lew)) alertsText[key] = lew = new List<EntityWrapper>(); lew.Add(entity); PlaySound(entity); }
private MapIcon GetMapIcon(EntityWrapper e) { if (e.HasComponent<NPC>() && masters.Contains(e.Path)) { return new MapIconCreature(e, new HudTexture("monster_ally.png"), 10) { Type = MapIcon.IconType.Master }; } if (e.HasComponent<Chest>() && !e.GetComponent<Chest>().IsOpened) { return e.GetComponent<Chest>().IsStrongbox ? new MapIconChest(e, new HudTexture("strongbox.png", e.GetComponent<ObjectMagicProperties>().Rarity), 16) { Type = MapIcon.IconType.Strongbox } : new MapIconChest(e, new HudTexture("minimap_default_icon.png"), 6) { Type = MapIcon.IconType.Chest }; } return null; }
private Healthbar GetHealthbarSettings(EntityWrapper e) { if (e.HasComponent<Player>()) { return new Healthbar(e, Settings.Players, RenderPrio.Player); } if (e.HasComponent<Poe.EntityComponents.Monster>()) { if (e.IsHostile) { switch (e.GetComponent<ObjectMagicProperties>().Rarity) { case Rarity.White: return new Healthbar(e, Settings.Enemies.Normal, RenderPrio.Normal); case Rarity.Magic: return new Healthbar(e, Settings.Enemies.Magic, RenderPrio.Magic); case Rarity.Rare: return new Healthbar(e, Settings.Enemies.Rare, RenderPrio.Rare); case Rarity.Unique: return new Healthbar(e, Settings.Enemies.Unique, RenderPrio.Unique); } } else { if (!e.IsHostile) { return new Healthbar(e, Settings.Minions, RenderPrio.Minion); } } } return null; }
public void EntityRemoved(EntityWrapper entity) { currentIcons.Remove(entity); }
public void EntityRemoved(EntityWrapper entity) { }
private Dictionary<int, List<EntityWrapper>> PopulateEntityDictionary(JsonResp jsonResp)//, string uiLang) { List<Entity> entities = jsonResp.results.entity.Where(x => x.label == "reference" || x.label == "concept" || x.label == "term").OrderBy(x => x.begin).ToList(); Dictionary<int, List<EntityWrapper>> dict = new Dictionary<int, List<EntityWrapper>>(); foreach (var entity in entities) { var newEntityWrapperStart = new EntityWrapper(); newEntityWrapperStart.Entity = entity; var newEntityWrapperEnd = new EntityWrapper(); newEntityWrapperEnd.Entity = entity; if (entity.label == "reference") { newEntityWrapperStart.EntityType = EntityType.StartReference; string id = entity.value, eurlex_uri = "http://eur-lex.europa.eu/legal-content/" + entity.language + "/TXT/?uri=CELEX:" + id, //clr = entity.label == "reference" ? "green" : "red"; clr = "green"; if (entity.toPar != "") eurlex_uri += "#" + entity.toPar;//"#"? newEntityWrapperStart.EntityNode = "<a href=\"" + eurlex_uri + "\" style=\"color:" + clr + "\">"; if (dict.ContainsKey(entity.begin)) { dict[entity.begin].Add(newEntityWrapperStart); dict[entity.begin].Sort(); } else { dict.Add(entity.begin, new List<EntityWrapper>() { newEntityWrapperStart }); } newEntityWrapperEnd.EntityType = EntityType.EndReference; newEntityWrapperEnd.EntityNode = "</a>"; if (dict.ContainsKey(entity.end)) { dict[entity.end].Add(newEntityWrapperEnd); dict[entity.end].Sort(); } else { dict.Add(entity.end, new List<EntityWrapper>() { newEntityWrapperEnd }); } } else if (entity.label == "concept" || entity.label == "term") { int lastKey = 0; if (dict.Keys.Count > 0) { lastKey = dict.Keys.Max(); } if (entity.begin < lastKey && entity.end > lastKey) { int end = entity.end; entity.end = lastKey; this.AddConcept(newEntityWrapperStart, newEntityWrapperEnd, entity, dict); entity.begin = lastKey; entity.end = end; this.AddConcept(newEntityWrapperStart, newEntityWrapperEnd, entity, dict); } else { this.AddConcept(newEntityWrapperStart, newEntityWrapperEnd, entity, dict); } } } return dict.OrderBy(x => x.Key).ToDictionary(x => x.Key, x => x.Value); }
public MapIconChest(EntityWrapper entity) : base(entity) { }
public void EntityAdded(EntityWrapper entity) { var icon = GetMapIcon(entity); if ( null != icon ) currentIcons[entity] = icon; }
private void PlaySound(EntityWrapper entity) { if (!Settings.PlaySound) { return; } if (!alreadyAlertedOf.Contains(entity.Id)) { Sounds.DangerSound.Play(); alreadyAlertedOf.Add(entity.Id); } }
private MapIcon GetMapIconForMonster(EntityWrapper e) { Rarity rarity = e.GetComponent<ObjectMagicProperties>().Rarity; if (!e.IsHostile) return new MapIconCreature(e, new HudTexture("monster_ally.png"), 6) { Rarity = rarity, Type = MapIcon.IconType.Minion }; switch (rarity) { case Rarity.White: return new MapIconCreature(e, new HudTexture("monster_enemy.png"), 6) { Type = MapIcon.IconType.Monster, Rarity = rarity }; case Rarity.Magic: return new MapIconCreature(e, new HudTexture("monster_enemy_blue.png"), 8) { Type = MapIcon.IconType.Monster, Rarity = rarity }; case Rarity.Rare: return new MapIconCreature(e, new HudTexture("monster_enemy_yellow.png"), 10) { Type = MapIcon.IconType.Monster, Rarity = rarity }; case Rarity.Unique: return new MapIconCreature(e, new HudTexture("monster_enemy_orange.png"), 10) { Type = MapIcon.IconType.Monster, Rarity = rarity }; } return null; }
public object Wrap(ModelInstance instance) { if (instance == null) return Null.Value; string key = instance.Type.Name + "|" + instance.Id; EntityWrapper entity; if (entities.TryGetValue(key, out entity)) return entity; entity = new EntityWrapper(engine, instance, this); entities.Add(key, entity); return entity; }
public Healthbar(EntityWrapper entity, HealthBarRenderer.PerGroupSetting settings, RenderPrio prio) { this.entity = entity; this.settings = settings; this.prio = prio; }
public CreatureMapIcon(EntityWrapper entityWrapper, string hudTexture, Func<bool> show, int iconSize) : base(entityWrapper, new HudTexture(hudTexture), show, iconSize) {}
public void EntityRemoved(EntityWrapper entity) { currentAlerts.Remove(entity); groundItemLabels.RemoveAll(e => e.ItemOnGround.Address == entity.Address); }
public ChestMapIcon(EntityWrapper entityWrapper, HudTexture hudTexture, Func<bool> show, int iconSize) : base(entityWrapper, hudTexture, show, iconSize) {}
private ItemUsefulProperties EvaluateItem(EntityWrapper item) { ItemUsefulProperties ip = new ItemUsefulProperties(); Mods mods = item.GetComponent<Mods>(); Sockets socks = item.GetComponent<Sockets>(); Map map = item.HasComponent<Map>() ? item.GetComponent<Map>() : null; Quality q = item.HasComponent<Quality>() ? item.GetComponent<Quality>() : null; ip.Name = model.Files.BaseItemTypes.Translate(item.Path); ip.ItemLevel = mods.ItemLevel; ip.NumLinks = socks.LargestLinkSize; ip.NumSockets = socks.NumberOfSockets; ip.Rarity = mods.ItemRarity; ip.MapLevel = map == null ? 0 : 1; ip.IsCurrency = item.Path.Contains("Currency"); ip.IsSkillGem = item.HasComponent<SkillGem>(); ip.IsFlask = item.HasComponent<Flask>(); ip.Quality = q == null ? 0 : q.ItemQuality; ip.WorthChrome = socks != null && socks.IsRGB; ip.IsVaalFragment = item.Path.Contains("VaalFragment"); CraftingBase craftingBase; if (craftingBases.TryGetValue(ip.Name, out craftingBase) && Settings.AlertOfCraftingBases) ip.IsCraftingBase = ip.ItemLevel >= craftingBase.MinItemLevel && ip.Quality >= craftingBase.MinQuality && (craftingBase.Rarities == null || craftingBase.Rarities.Contains(ip.Rarity)); return ip; }
public MapIcon(EntityWrapper entity, HudTexture hudTexture, int iconSize = 10) : this(entity) { MinimapIcon = hudTexture; Size = iconSize; }
private void UpdatePlayer() { int address = gameController.Game.IngameState.Data.LocalPlayer.Address; if ((player == null) || (player.Address != address)) { player = new EntityWrapper(gameController, address); } }
private void AddConcept(EntityWrapper newEntityWrapperStart, EntityWrapper newEntityWrapperEnd, Entity entity, Dictionary<int, List<EntityWrapper>> dict) { newEntityWrapperStart.EntityType = EntityType.StartConcept; //newEntityWrapperStart.EntityNode = string.Format("<span class='concept' data-id='{0}'>", entity.value); newEntityWrapperStart.EntityNode = "<span style=\"color:red\">"; if (dict.ContainsKey(entity.begin)) { dict[entity.begin].Add(newEntityWrapperStart); dict[entity.begin].Sort(); } else { dict.Add(entity.begin, new List<EntityWrapper>() { newEntityWrapperStart }); } newEntityWrapperEnd.EntityType = EntityType.EndConcept; newEntityWrapperEnd.EntityNode = "</span>"; if (dict.ContainsKey(entity.end)) { dict[entity.end].Add(newEntityWrapperEnd); dict[entity.end].Sort(); } else { dict.Add(entity.end, new List<EntityWrapper>() { newEntityWrapperEnd }); } }
public MapIcon(EntityWrapper entity) { Entity = entity; }