static public float getMyChestArmor(Agent agent) { float num = 0f; for (EquipmentIndex equipmentIndex = EquipmentIndex.NumAllWeaponSlots; equipmentIndex < EquipmentIndex.ArmorItemEndSlot; equipmentIndex++) { EquipmentElement equipmentElement = agent.SpawnEquipment[equipmentIndex]; if (equipmentElement.Item != null && equipmentElement.Item.ItemType == ItemObject.ItemTypeEnum.BodyArmor) { num += (float)equipmentElement.Item.ArmorComponent.BodyArmor; } } return(num); }
public void PickupItems() { if (!master.inventory) { return; } List <GenericPickupController> pickups = InstanceTracker.GetInstancesList <GenericPickupController>(); for (int i = 0; i < pickups.Count; i++) { GenericPickupController pickup = pickups[i]; // Skip lunar coins if (pickup.pickupIndex.coinValue > 0) { continue; } // Skip these ItemDef def = ItemCatalog.GetItemDef(pickup.pickupIndex.itemIndex); if (def != null && def.tier == ItemTier.Lunar) { continue; } EquipmentIndex equipmentIndex = pickup.pickupIndex.equipmentIndex; if (equipmentIndex != EquipmentIndex.None) { if (EquipmentCatalog.GetEquipmentDef(equipmentIndex).isLunar) { continue; } if (master.inventory.currentEquipmentIndex != EquipmentIndex.None) { continue; } } if (pickup.GetInteractability(this.bodyInteractor) == Interactability.Available) { // Move to pickup item if within 60 meters float dist = PlayerBotUtils.GetFastDist(master.GetBody().transform.position, pickup.gameObject.transform.position); if (dist <= (60f * 60f)) { this.ai.customTarget.gameObject = pickup.gameObject; return; } } } }
// Token: 0x06000D2D RID: 3373 RVA: 0x00041BFC File Offset: 0x0003FDFC public List <GameObject> GetEquipmentDisplayObjects(EquipmentIndex equipmentIndex) { List <GameObject> list = new List <GameObject>(); for (int i = this.parentedPrefabDisplays.Count - 1; i >= 0; i--) { if (this.parentedPrefabDisplays[i].equipmentIndex == equipmentIndex) { GameObject instance = this.parentedPrefabDisplays[i].instance; list.Add(instance); } } return(list); }
private void ConsequenceStrip(Companion companion, Hero hero) { if (companion.MultipleRestrictedListOfConsequences.Contains(RestrictedListOfConsequences.Strip)) { if (hero == null) { return; } Equipment randomElement = new Equipment(false); ItemObject itemObjectBody = hero.IsFemale ? MBObjectManager.Instance.GetObject <ItemObject>("burlap_sack_dress") : MBObjectManager.Instance.GetObject <ItemObject>("tattered_rags"); randomElement.AddEquipmentToSlotWithoutAgent(EquipmentIndex.Body, new EquipmentElement(itemObjectBody)); Equipment randomElement2 = new Equipment(true); randomElement2.FillFrom(randomElement, false); if (CESettings.Instance != null && CESettings.Instance.EventCaptorGearCaptives) { CECampaignBehavior.AddReturnEquipment(hero, hero.BattleEquipment, hero.CivilianEquipment); } foreach (EquipmentCustomIndex index in Enum.GetValues(typeof(EquipmentCustomIndex))) { EquipmentIndex i = (EquipmentIndex)index; try { if (!hero.BattleEquipment.GetEquipmentFromSlot(i).IsEmpty) { PartyBase.MainParty.ItemRoster.AddToCounts(hero.BattleEquipment.GetEquipmentFromSlot(i).Item, 1); } } catch (Exception) { } try { if (!hero.CivilianEquipment.GetEquipmentFromSlot(i).IsEmpty) { PartyBase.MainParty.ItemRoster.AddToCounts(hero.CivilianEquipment.GetEquipmentFromSlot(i).Item, 1); } } catch (Exception) { } } EquipmentHelper.AssignHeroEquipmentFromEquipment(hero, randomElement); EquipmentHelper.AssignHeroEquipmentFromEquipment(hero, randomElement2); } }
private void ChooseWeaponToCheerWithCheerAndUpdateTimer(Agent cheerAgent, out bool resetTimer) { resetTimer = false; if (cheerAgent.GetCurrentActionType(1) == Agent.ActionCodeType.EquipUnequip) { return; } EquipmentIndex wieldedItemIndex = cheerAgent.GetWieldedItemIndex(Agent.HandIndex.MainHand); bool flag = wieldedItemIndex != EquipmentIndex.None && !cheerAgent.Equipment[wieldedItemIndex].Item.ItemFlags.HasAnyFlag <ItemFlags>(ItemFlags.DropOnAnyAction); if (!flag) { EquipmentIndex slotIndex = EquipmentIndex.None; for (EquipmentIndex index = EquipmentIndex.WeaponItemBeginSlot; index < EquipmentIndex.Weapon4; ++index) { if ((cheerAgent.Equipment[index].IsEmpty ? 0 : (!cheerAgent.Equipment[index].Item.ItemFlags.HasAnyFlag <ItemFlags>(ItemFlags.DropOnAnyAction) ? 1 : 0)) != 0) { slotIndex = index; break; } } if (slotIndex == EquipmentIndex.None) { if (wieldedItemIndex != EquipmentIndex.None) { cheerAgent.TryToSheathWeaponInHand(Agent.HandIndex.MainHand, Agent.WeaponWieldActionType.WithAnimation); } else { flag = true; } } else { cheerAgent.TryToWieldWeaponInSlot(slotIndex, Agent.WeaponWieldActionType.WithAnimation, false); } } if (!flag) { return; } if (this._selectedCheerActions == null) { this._selectedCheerActions = this._midCheerActions; } cheerAgent.SetActionChannel(1, this._selectedCheerActions[MBRandom.RandomInt(this._selectedCheerActions.Length)]); cheerAgent.MakeVoice(SkinVoiceManager.VoiceType.Victory, SkinVoiceManager.CombatVoiceNetworkPredictionType.NoPrediction); resetTimer = true; }
private static void HideFloatingEquipment(On.RoR2.CharacterModel.orig_SetEquipmentDisplay orig, CharacterModel self, EquipmentIndex newEquipmentIndex) { EquipmentIndex[] equipmentsToHide = new EquipmentIndex[] { RoR2Content.Equipment.Blackhole.equipmentIndex, RoR2Content.Equipment.Saw.equipmentIndex, RoR2Content.Equipment.PassiveHealing.equipmentIndex, RoR2Content.Equipment.Meteor.equipmentIndex }; if (!self.body.master.IsLocalMaster() || !equipmentsToHide.Contains(newEquipmentIndex)) { orig(self, newEquipmentIndex); } }
public SpawnWeaponAsDropFromAgent( Agent agent, EquipmentIndex equipmentIndex, Vec3 velocity, Vec3 angularVelocity, Mission.WeaponSpawnFlags weaponSpawnFlags, int forcedIndex) { this.Agent = agent; this.EquipmentIndex = equipmentIndex; this.Velocity = velocity; this.AngularVelocity = angularVelocity; this.WeaponSpawnFlags = weaponSpawnFlags; this.ForcedIndex = forcedIndex; }
// Token: 0x06000ADE RID: 2782 RVA: 0x00035A64 File Offset: 0x00033C64 public static EliteIndex IsEquipmentElite(EquipmentIndex equipmentIndex) { if (equipmentIndex < EquipmentIndex.CommandMissile || equipmentIndex >= EquipmentIndex.Count) { return(EliteIndex.None); } foreach (EliteDef eliteDef in EliteCatalog.eliteDefs) { if (eliteDef.eliteEquipmentIndex == equipmentIndex) { return(eliteDef.eliteIndex); } } return(EliteIndex.None); }
public static DroneMode EvaluateDroneMode(EquipmentIndex equipmentIndex) { //_logger.LogMessage($"Trying out EquipmentIndex {equipmentIndex}"); DroneMode droneMode; if (DroneModeDictionary.TryGetValue(equipmentIndex, out DroneMode newDroneMode)) { droneMode = newDroneMode; } else { droneMode = DroneMode.None; } return(droneMode); }
// Token: 0x0600056E RID: 1390 RVA: 0x0001610C File Offset: 0x0001430C public static EliteIndex GetEquipmentEliteIndex(EquipmentIndex equipmentIndex) { if (!EquipmentCatalog.IsIndexValid(equipmentIndex)) { return(EliteIndex.None); } foreach (EliteDef eliteDef in EliteCatalog.eliteDefs) { if (eliteDef.eliteEquipmentIndex == equipmentIndex) { return(eliteDef.eliteIndex); } } return(EliteIndex.None); }
public SetWieldedItemIndex( Agent agent, bool isLeftHand, bool isWieldedInstantly, bool isWieldedOnSpawn, EquipmentIndex wieldedItemIndex, int mainHandCurUsageIndex) { this.Agent = agent; this.IsLeftHand = isLeftHand; this.IsWieldedInstantly = isWieldedInstantly; this.IsWieldedOnSpawn = isWieldedOnSpawn; this.WieldedItemIndex = wieldedItemIndex; this.MainHandCurrentUsageIndex = mainHandCurUsageIndex; }
private static void EquipmentAbsorbHook() { IL.RoR2.GenericPickupController.AttemptGrant += (il) => { ILCursor c = new ILCursor(il); bool found = c.TryGotoNext( x => x.MatchLdarg(0), x => x.MatchLdfld <GenericPickupController>("pickupIndex"), x => x.MatchCall("RoR2.PickupCatalog", "GetPickupDef"), x => x.MatchStloc(1) ); if (found) { c.Index += 4; c.Emit(OpCodes.Ldarg, 0); c.Emit(OpCodes.Ldarg, 1); c.Emit(OpCodes.Ldloc, 1); c.EmitDelegate <Func <GenericPickupController, CharacterBody, PickupDef, PickupDef> >((controller, body, pickupDef) => { if (Configuration.AspectEquipmentAbsorb.Value) { EquipmentIndex pickupEquip = pickupDef.equipmentIndex; if (pickupEquip != EquipmentIndex.None && pickupEquip == body.inventory.currentEquipmentIndex) { ItemIndex newIndex = Catalog.ItemizeEliteEquipment(pickupEquip); if (newIndex != ItemIndex.None) { controller.pickupIndex = PickupCatalog.FindPickupIndex(newIndex); return(PickupCatalog.GetPickupDef(controller.pickupIndex)); } } } return(pickupDef); }); c.Emit(OpCodes.Stloc, 1); } else { Logger.Warn("EquipmentAbsorbHook Failed"); } }; }
// Token: 0x06002520 RID: 9504 RVA: 0x000AE590 File Offset: 0x000AC790 public void AddSimplePickup(PickupIndex pickupIndex) { ItemIndex itemIndex = pickupIndex.itemIndex; EquipmentIndex equipmentIndex = pickupIndex.equipmentIndex; string token = null; if (itemIndex != ItemIndex.None) { ItemDef itemDef = ItemCatalog.GetItemDef(itemIndex); this.AddDescriptionPanel(Language.GetString(itemDef.descriptionToken)); token = itemDef.loreToken; ulong statValueULong = this.statSheet.GetStatValueULong(PerItemStatDef.totalCollected.FindStatDef(itemIndex)); ulong statValueULong2 = this.statSheet.GetStatValueULong(PerItemStatDef.highestCollected.FindStatDef(itemIndex)); string stringFormatted = Language.GetStringFormatted("GENERIC_PREFIX_FOUND", new object[] { statValueULong }); string stringFormatted2 = Language.GetStringFormatted("ITEM_PREFIX_STACKCOUNT", new object[] { statValueULong2 }); this.AddSimpleTextPanel(new string[] { stringFormatted, stringFormatted2 }); } else if (equipmentIndex != EquipmentIndex.None) { EquipmentDef equipmentDef = EquipmentCatalog.GetEquipmentDef(equipmentIndex); this.AddDescriptionPanel(Language.GetString(equipmentDef.descriptionToken)); token = equipmentDef.loreToken; string stringFormatted3 = Language.GetStringFormatted("EQUIPMENT_PREFIX_TOTALTIMEHELD", new object[] { this.statSheet.GetStatDisplayValue(PerEquipmentStatDef.totalTimeHeld.FindStatDef(equipmentIndex)) }); string stringFormatted4 = Language.GetStringFormatted("EQUIPMENT_PREFIX_USECOUNT", new object[] { this.statSheet.GetStatDisplayValue(PerEquipmentStatDef.totalTimesFired.FindStatDef(equipmentIndex)) }); this.AddSimpleTextPanel(new string[] { stringFormatted3, stringFormatted4 }); } this.AddNotesPanel(Language.IsTokenInvalid(token) ? Language.GetString("EARLY_ACCESS_LORE") : Language.GetString(token)); }
public override bool IsDisabledForAgent(Agent agent) { EquipmentIndex wieldedItemIndex = agent.GetWieldedItemIndex(Agent.HandIndex.MainHand); if (wieldedItemIndex == EquipmentIndex.None) { return(true); } WeaponComponentData currentUsageItem = agent.Equipment[wieldedItemIndex].CurrentUsageItem; if (currentUsageItem == null || !currentUsageItem.IsRangedWeapon) { return(true); } return(wieldedItemIndex == EquipmentIndex.Weapon4 ? (double)this.ThrowingValueMultiplier <= 0.0 || base.IsDisabledForAgent(agent) : (double)this.RangedWeaponValueMultiplier <= 0.0 || base.IsDisabledForAgent(agent)); }
void Start() { enemyTeamIndex = baseAI.master.teamIndex == TeamIndex.Player ? TeamIndex.Monster : TeamIndex.Player; if (!equipmentSlot) { if (baseAI.body && baseAI.body.inventory) { equipmentSlot = baseAI.body.equipmentSlot; } } equipmentIndex = baseAI.master.inventory.currentEquipmentIndex; droneMode = EvaluateDroneMode(equipmentIndex); _logger.LogMessage($"Chosen Drone Mode: {droneMode}"); }
// Token: 0x060027B8 RID: 10168 RVA: 0x000AB180 File Offset: 0x000A9380 private int EquipmentDiscovered() { int num = 0; EquipmentIndex equipmentIndex = EquipmentIndex.CommandMissile; EquipmentIndex equipmentCount = (EquipmentIndex)EquipmentCatalog.equipmentCount; while (equipmentIndex < equipmentCount) { if (base.userProfile.HasDiscoveredPickup(new PickupIndex(equipmentIndex))) { num++; } equipmentIndex++; } return(num); }
// Token: 0x0600230C RID: 8972 RVA: 0x000A514C File Offset: 0x000A334C public void OnPickup(CharacterMaster characterMaster, PickupIndex pickupIndex) { ItemIndex itemIndex = pickupIndex.itemIndex; if (itemIndex >= ItemIndex.Syringe) { this.OnItemPickup(characterMaster, itemIndex); return; } EquipmentIndex equipmentIndex = pickupIndex.equipmentIndex; if (equipmentIndex >= EquipmentIndex.CommandMissile) { this.OnEquipmentPickup(characterMaster, equipmentIndex); } }
// Token: 0x06000EFA RID: 3834 RVA: 0x00049B54 File Offset: 0x00047D54 private void Execute() { EquipmentIndex equipmentIndex = this.equipmentIndex; if (EquipmentCatalog.GetEquipmentDef(equipmentIndex) != null && this.subcooldownTimer <= 0f && this.PerformEquipmentAction(equipmentIndex)) { this.inventory.DeductActiveEquipmentCharges(1); this.CallRpcOnClientEquipmentActivationRecieved(); Action <EquipmentSlot, EquipmentIndex> action = EquipmentSlot.onServerEquipmentActivated; if (action == null) { return; } action(this, equipmentIndex); } }
// Token: 0x06000AA7 RID: 2727 RVA: 0x0002F4A8 File Offset: 0x0002D6A8 private void UpdateTargets() { bool flag = this.stock > 0; bool flag2 = (this.equipmentIndex == EquipmentIndex.Lightning || this.equipmentIndex == EquipmentIndex.SoulCorruptor) && flag; bool flag3 = this.equipmentIndex == EquipmentIndex.PassiveHealing && flag; if (flag2 || flag3) { if (flag2) { this.ConfigureTargetFinderForEnemies(); } if (flag3) { this.ConfigureTargetFinderForFriendlies(); } this.currentTargetHurtBox = this.targetFinder.GetResults().FirstOrDefault <HurtBox>(); this.currentTargetBodyObject = (this.currentTargetHurtBox ? this.currentTargetHurtBox.healthComponent.gameObject : null); } else { this.currentTargetHurtBox = null; } bool flag4 = this.currentTargetHurtBox; if (flag4) { EquipmentIndex equipmentIndex = this.equipmentIndex; if (equipmentIndex != EquipmentIndex.Lightning) { if (equipmentIndex != EquipmentIndex.PassiveHealing) { this.targetIndicator.visualizerPrefab = Resources.Load <GameObject>("Prefabs/LightningIndicator"); } else { this.targetIndicator.visualizerPrefab = Resources.Load <GameObject>("Prefabs/WoodSpriteIndicator"); } } else { this.targetIndicator.visualizerPrefab = Resources.Load <GameObject>("Prefabs/LightningIndicator"); } } this.targetIndicator.active = flag4; this.targetIndicator.targetTransform = (flag4 ? this.currentTargetHurtBox.transform : null); }
public CreateAgent( Agent agent, bool isPlayerAgent, Vec3 position, Vec2 direction, NetworkCommunicator peer) { this.AgentIndex = agent.Index; bool flag = agent.MountAgent != null && agent.MountAgent.RiderAgent == agent; this.MountAgentIndex = flag ? agent.MountAgent.Index : -1; this.Peer = peer; this.Character = agent.Character; this.Monster = agent.Monster; this.SpawnEquipment = new Equipment(); this.SpawnMissionEquipment = new MissionEquipment(); for (EquipmentIndex index = EquipmentIndex.WeaponItemBeginSlot; index < EquipmentIndex.NumAllWeaponSlots; ++index) { this.SpawnMissionEquipment[index] = agent.Equipment[index]; } for (EquipmentIndex equipmentIndex = EquipmentIndex.NumAllWeaponSlots; equipmentIndex < EquipmentIndex.ArmorItemEndSlot; ++equipmentIndex) { this.SpawnEquipment[equipmentIndex] = agent.SpawnEquipment.GetEquipmentFromSlot(equipmentIndex); } if (flag) { this.SpawnEquipment[EquipmentIndex.ArmorItemEndSlot] = agent.MountAgent.SpawnEquipment[EquipmentIndex.ArmorItemEndSlot]; this.SpawnEquipment[EquipmentIndex.HorseHarness] = agent.MountAgent.SpawnEquipment[EquipmentIndex.HorseHarness]; } else { this.SpawnEquipment[EquipmentIndex.ArmorItemEndSlot] = new EquipmentElement(); this.SpawnEquipment[EquipmentIndex.HorseHarness] = new EquipmentElement(); } this.BodyPropertiesValue = agent.BodyPropertiesValue; this.BodyPropertiesSeed = agent.BodyPropertiesSeed; this.IsFemale = agent.IsFemale; this.Team = agent.Team; this.Position = position; this.Direction = direction; Formation formation = agent.Formation; this.FormationIndex = formation != null ? formation.Index : -1; this.ClothingColor1 = agent.ClothingColor1; this.ClothingColor2 = agent.ClothingColor2; this.IsPlayerAgent = isPlayerAgent; }
static bool EnforceBannedEquipments(On.RoR2.Inventory.orig_SetEquipmentInternal orig, Inventory self, EquipmentState equipmentState, uint slot) { EquipmentState equipment = equipmentState; if (NetworkServer.active) { //Ban check bool isBanned = Settings.BannedEquipments.ContainsKey(equipment.equipmentIndex) ? true : false; //Reroll if banned if (isBanned) { Chat.SendBroadcastChat(new Chat.SimpleChatMessage { baseToken = Util.GenerateColoredString("Banned equipment detected! rerolling...", new Color32(255, 106, 0, 255)) }); bool assigned = false; if (equipment.equipmentDef != null) { if (equipment.equipmentDef.isLunar) { if (Run.instance.availableLunarEquipmentDropList.Count != 0) { EquipmentIndex equipmentIndex = Tools.TryGetRandomEquipment(Run.instance.availableLunarEquipmentDropList, Run.instance.treasureRng); equipment = new EquipmentState(equipmentIndex, equipment.chargeFinishTime, equipment.charges); assigned = true; } } else { if (Run.instance.availableNormalEquipmentDropList.Count != 0) { EquipmentIndex equipmentIndex = Tools.TryGetRandomEquipment(Run.instance.availableNormalEquipmentDropList, Run.instance.treasureRng); equipment = new EquipmentState(equipmentIndex, equipment.chargeFinishTime, equipment.charges); assigned = true; } } } if (!assigned) { equipment = EquipmentState.empty; } } } return(orig(self, equipment, slot)); }
public static void Postfix(Agent __instance, SpawnedItemEntity spawnedItemEntity, EquipmentIndex weaponPickUpSlotIndex, bool removeWeapon) { try { AgentInitializeMissionEquipmentPatch.AgentOriginalWeaponSpeed[__instance][(int)weaponPickUpSlotIndex] = new Tuple <int, int>(spawnedItemEntity.WeaponCopy.PrimaryItem.PrimaryWeapon.SwingSpeed, spawnedItemEntity.WeaponCopy.PrimaryItem.PrimaryWeapon.ThrustSpeed); MissionOnTickPatch.ChangeWeaponSpeedsHandler(__instance, MissionSpawnAgentPatch.GetCurrentStaminaRatio(__instance)); } catch (KeyNotFoundException) { #if DEBUG InformationManager.DisplayMessage(new InformationMessage("Caught KeyNotFoundException in AgentOnItemPickupPatch!", new Color(1.00f, 0.38f, 0.01f), "Debug")); #endif } }
public static List <EquipmentIndex> GetEquipment() { List <EquipmentIndex> equipment = new List <EquipmentIndex>(); string[] unreleasedEquipment = { "Count" }; // string[] unreleasedEquipment = { "SoulJar", "AffixYellow", "AffixGold", "GhostGun", "OrbitalLaser", "Enigma", "LunarPotion", "SoulCorruptor", "Count" }; foreach (string equipmentName in Enum.GetNames(typeof(EquipmentIndex))) { bool unreleasednullEquipment = unreleasedEquipment.Any(equipmentName.Contains); if (!unreleasednullEquipment) { EquipmentIndex equipmentIndex = (EquipmentIndex)Enum.Parse(typeof(EquipmentIndex), equipmentName); equipment.Add(equipmentIndex); } } return(equipment); }
public static void UnlockAll() { //Goes through resource file containing all unlockables... Easily updatable, just paste "RoR2.UnlockCatalog" and GetAllUnlockable does the rest. //This is needed to unlock logs foreach (var unlockableName in Main.unlockableNames) { var unlockableDef = UnlockableCatalog.GetUnlockableDef(unlockableName); NetworkUser networkUser = Util.LookUpBodyNetworkUser(Main.LocalPlayerBody); if (networkUser) { networkUser.ServerHandleUnlock(unlockableDef); } } //Gives all achievements. var achievementManager = AchievementManager.GetUserAchievementManager(LocalUserManager.GetFirstLocalUser()); foreach (var achievement in AchievementManager.allAchievementDefs) { achievementManager.GrantAchievement(achievement); } //Give all survivors var profile = LocalUserManager.GetFirstLocalUser().userProfile; foreach (var survivor in SurvivorCatalog.allSurvivorDefs) { if (profile.statSheet.GetStatValueDouble(RoR2.Stats.PerBodyStatDef.totalTimeAlive, survivor.bodyPrefab.name) == 0.0) { profile.statSheet.SetStatValueFromString(RoR2.Stats.PerBodyStatDef.totalTimeAlive.FindStatDef(survivor.bodyPrefab.name), "0.1"); } } //All items and equipments foreach (string itemName in Enum.GetNames(typeof(ItemIndex))) { ItemIndex itemIndex = (ItemIndex)Enum.Parse(typeof(ItemIndex), itemName); profile.DiscoverPickup(PickupCatalog.FindPickupIndex(itemIndex)); } foreach (string equipmentName in Enum.GetNames(typeof(EquipmentIndex))) { EquipmentIndex equipmentIndex = (EquipmentIndex)Enum.Parse(typeof(EquipmentIndex), equipmentName); profile.DiscoverPickup(PickupCatalog.FindPickupIndex(equipmentIndex)); } }
private static void TargetGiveEquip(ConCommandArgs args) { var localMaster = PlayerCharacterMasterController.instances[0].master; var component = HasComponent(localMaster); if (component && component.HasBody()) { var inventory = component.targetedBody.inventory; if (inventory) { //https://stackoverflow.com/questions/23563960/how-to-get-enum-value-by-string-or-int EquipmentIndex equipmentIndex = (EquipmentIndex)args.GetArgInt(0); inventory.SetEquipmentIndex(equipmentIndex); Chat.AddMessage("Gave " + equipmentIndex + " to " + component.targetedBody.GetDisplayName()); } } }
public SpawnedItemEntity SelectPickableItem(Vec3 bMin, Vec3 bMax) { Agent targetAgent = this.Agent.GetTargetAgent(); Vec3 v1 = targetAgent == null ? Vec3.Invalid : targetAgent.Position - this.Agent.Position; int num1 = this.Agent.Mission.Scene.SelectEntitiesInBoxWithScriptComponent <SpawnedItemEntity>(ref bMin, ref bMax, this._tempPickableEntities, this._pickableItemsId); float num2 = 0.0f; SpawnedItemEntity spawnedItemEntity = (SpawnedItemEntity)null; for (int index = 0; index < num1; ++index) { SpawnedItemEntity firstScriptOfType = this._tempPickableEntities[index].GetFirstScriptOfType <SpawnedItemEntity>(); int num3; if (firstScriptOfType != null) { MissionWeapon weaponCopy = firstScriptOfType.WeaponCopy; if (!weaponCopy.IsEmpty) { weaponCopy = firstScriptOfType.WeaponCopy; num3 = weaponCopy.IsShield() || firstScriptOfType.IsStuckMissile() ? 1 : (firstScriptOfType.IsQuiverAndNotEmpty() ? 1 : 0); goto label_5; } } num3 = 0; label_5: if (num3 != 0 && !firstScriptOfType.HasUser && (firstScriptOfType.MovingAgents.Count == 0 || firstScriptOfType.MovingAgents.ContainsKey(this.Agent)) && firstScriptOfType.GameEntityWithWorldPosition.WorldPosition.GetNavMesh() != UIntPtr.Zero) { Vec3 v2 = firstScriptOfType.GetUserFrameForAgent(this.Agent).Origin.Position - this.Agent.Position; double num4 = (double)v2.Normalize(); if (targetAgent == null || (double)v1.Length - (double)Vec3.DotProduct(v1, v2) > (double)targetAgent.MaximumForwardUnlimitedSpeed * 3.0) { EquipmentIndex slotToPickUp = MissionEquipment.SelectWeaponPickUpSlot(this.Agent, firstScriptOfType.WeaponCopy, firstScriptOfType.IsStuckMissile()); WorldPosition worldPosition = firstScriptOfType.GameEntityWithWorldPosition.WorldPosition; if (slotToPickUp != EquipmentIndex.None && worldPosition.GetNavMesh() != UIntPtr.Zero && (this.IsItemAvailable(firstScriptOfType, slotToPickUp) && this.Agent.CanMoveDirectlyToPosition(in worldPosition))) { float itemScore = this.GetItemScore(firstScriptOfType); if ((double)itemScore > (double)num2) { spawnedItemEntity = firstScriptOfType; num2 = itemScore; } } } } } return(spawnedItemEntity); }
protected override void OnWrite() { GameNetworkMessage.WriteNetworkPeerReferenceToPacket(this.Peer); GameNetworkMessage.WriteIntToPacket(this.VisualsIndex, CompressionMission.AgentOffsetCompressionInfo); GameNetworkMessage.WriteObjectReferenceToPacket((MBObjectBase)this.Character, CompressionBasic.GUIDCompressionInfo); bool flag = this.Equipment[EquipmentIndex.ArmorItemEndSlot].Item != null; GameNetworkMessage.WriteBoolToPacket(flag); for (EquipmentIndex equipmentIndex = EquipmentIndex.WeaponItemBeginSlot; equipmentIndex < (flag ? EquipmentIndex.NumEquipmentSetSlots : EquipmentIndex.ArmorItemEndSlot); ++equipmentIndex) { ModuleNetworkData.WriteItemReferenceToPacket(this.Equipment.GetEquipmentFromSlot(equipmentIndex)); } GameNetworkMessage.WriteIntToPacket(this.BodyPropertiesSeed, CompressionGeneric.RandomSeedCompressionInfo); GameNetworkMessage.WriteBoolToPacket(this.IsFemale); GameNetworkMessage.WriteIntToPacket(this.SelectedEquipmentSetIndex, CompressionBasic.MissionObjectIDCompressionInfo); GameNetworkMessage.WriteIntToPacket(this.TroopCountInFormation, CompressionBasic.PlayerCompressionInfo); }
public static bool HasRangedWeaponEquipped() { Equipment playerEquipment = Hero.MainHero.BattleEquipment; for (EquipmentIndex equipmentIndex = EquipmentIndex.WeaponItemBeginSlot; equipmentIndex < EquipmentIndex.NumAllWeaponSlots; equipmentIndex++) { ItemObject item = playerEquipment[equipmentIndex].Item; if (item != null && (item.Type == ItemObject.ItemTypeEnum.Thrown || item.Type == ItemObject.ItemTypeEnum.Bow || item.Type == ItemObject.ItemTypeEnum.Crossbow)) { return(true); } } return(false); }
static void PostfixGetAiWeight(ref Formation ___formation, ref float __result) { int mountedSkirmishersCount = 0; if (___formation != null) { PropertyInfo property = typeof(Formation).GetProperty("arrangement", BindingFlags.NonPublic | BindingFlags.Instance); property.DeclaringType.GetProperty("arrangement"); IFormationArrangement arrangement = (IFormationArrangement)property.GetValue(___formation); FieldInfo field = typeof(LineFormation).GetField("_allUnits", BindingFlags.NonPublic | BindingFlags.Instance); field.DeclaringType.GetField("_allUnits"); List <IFormationUnit> agents = (List <IFormationUnit>)field.GetValue(arrangement); foreach (Agent agent in agents.ToList()) { bool ismountedSkrimisher = false; for (EquipmentIndex equipmentIndex = EquipmentIndex.WeaponItemBeginSlot; equipmentIndex < EquipmentIndex.NumAllWeaponSlots; equipmentIndex++) { if (agent.Equipment != null && !agent.Equipment[equipmentIndex].IsEmpty) { if (agent.Equipment[equipmentIndex].PrimaryItem.Type == ItemTypeEnum.Thrown && agent.MountAgent != null) { ismountedSkrimisher = true; } } } if (ismountedSkrimisher) { mountedSkirmishersCount++; } } float mountedSkirmishersRatio = (float)mountedSkirmishersCount / (float)___formation.CountOfUnits; if (mountedSkirmishersRatio > 0.6f) { //___formation.AI.SetBehaviorWeight<BehaviorProtectFlank>(0f); __result = 5f; } else { //___formation.AI.SetBehaviorWeight<BehaviorProtectFlank>(1f); __result = 1f; } } }
// Token: 0x06000585 RID: 1413 RVA: 0x00017050 File Offset: 0x00015250 private static void RegisterEquipment(EquipmentIndex equipmentIndex, EquipmentDef equipmentDef) { equipmentDef.equipmentIndex = equipmentIndex; EquipmentCatalog.equipmentDefs[(int)equipmentIndex] = equipmentDef; if (equipmentDef.canDrop) { EquipmentCatalog.equipmentList.Add(equipmentIndex); } if (equipmentDef.enigmaCompatible) { EquipmentCatalog.enigmaEquipmentList.Add(equipmentIndex); } if (equipmentDef.name == null) { equipmentDef.name = equipmentIndex.ToString(); } string name = equipmentDef.name; string arg = name.ToUpper(CultureInfo.InvariantCulture); if (equipmentDef.nameToken == null) { equipmentDef.nameToken = string.Format(CultureInfo.InvariantCulture, "EQUIPMENT_{0}_NAME", arg); } if (equipmentDef.descriptionToken == null) { equipmentDef.descriptionToken = string.Format(CultureInfo.InvariantCulture, "EQUIPMENT_{0}_DESC", arg); } if (equipmentDef.pickupToken == null) { equipmentDef.pickupToken = string.Format(CultureInfo.InvariantCulture, "EQUIPMENT_{0}_PICKUP", arg); } if (equipmentDef.loreToken == null) { equipmentDef.loreToken = string.Format(CultureInfo.InvariantCulture, "EQUIPMENT_{0}_LORE", arg); } if (equipmentDef.pickupModelPath == null) { equipmentDef.pickupModelPath = "Prefabs/NullModel"; } if (equipmentDef.pickupIconPath == null) { equipmentDef.pickupIconPath = "Textures/ItemIcons/texNullIcon"; } EquipmentCatalog.equipmentNameToIndex[name] = equipmentIndex; }