Ejemplo n.º 1
0
 static void Postfix(ref SpawnedItemEntity ____itemToPickUp, ref Agent ___Agent)
 {
     if (____itemToPickUp != null && (___Agent.AIStateFlags & Agent.AIStateFlag.UseObjectMoving) != 0)
     {
         float             num = MissionGameModels.Current.AgentStatCalculateModel.GetInteractionDistance(___Agent) * 3f;
         WorldFrame        userFrameForAgent = ____itemToPickUp.GetUserFrameForAgent(___Agent);
         ref WorldPosition origin            = ref userFrameForAgent.Origin;
         Vec3  targetPoint = ___Agent.Position;
         float distanceSq  = origin.DistanceSquaredWithLimit(in targetPoint, num * num + 1E-05f);
         float newDist     = -1f;
         itemPickupDistanceStorage.TryGetValue(___Agent, out newDist);
         if (newDist == 0f)
         {
             itemPickupDistanceStorage[___Agent] = distanceSq;
         }
         else
         {
             if (distanceSq == newDist)
             {
                 ___Agent.StopUsingGameObject(isSuccessful: false);
                 itemPickupDistanceStorage.Remove(___Agent);
             }
             itemPickupDistanceStorage[___Agent] = distanceSq;
         }
     }
Ejemplo n.º 2
0
 public SpawnAttachedWeaponOnSpawnedWeapon(
     SpawnedItemEntity spawnedWeapon,
     int attachmentIndex,
     int forcedIndex)
 {
     this.SpawnedWeapon   = spawnedWeapon;
     this.AttachmentIndex = attachmentIndex;
     this.ForcedIndex     = forcedIndex;
 }
Ejemplo n.º 3
0
 public EquipWeaponFromSpawnedItemEntity(
     Agent a,
     EquipmentIndex slot,
     SpawnedItemEntity spawnedItemEntity,
     bool removeWeapon)
 {
     this.Agent             = a;
     this.SlotIndex         = slot;
     this.SpawnedItemEntity = spawnedItemEntity;
     this.RemoveWeapon      = removeWeapon;
 }
Ejemplo n.º 4
0
        private void OnAllyPickedUpAmmo(Agent agent, SpawnedItemEntity item)
        {
            if (!AgentHashCodeToCurrentArrows.ContainsKey(agent.GetHashCode()))
            {
                return;
            }

            short lastKnownAmmoOnAgent = AgentHashCodeToCurrentArrows[agent.GetHashCode()];
            short newAmmoOnAgent       = CalculateRemainingAmmo(agent);
            short amountPickedUp       = (short)(newAmmoOnAgent - lastKnownAmmoOnAgent);

            AgentHashCodeToCurrentArrows[agent.GetHashCode()] += amountPickedUp;
            AddToRemainingArrows(amountPickedUp);
        }
Ejemplo n.º 5
0
 public ZaWarudoMissile(Missile missile, SpawnedItemEntity spawnedItem)
 {
     //IL_0018: Unknown result type (might be due to invalid IL or missing references)
     //IL_001d: Unknown result type (might be due to invalid IL or missing references)
     //IL_0024: Unknown result type (might be due to invalid IL or missing references)
     //IL_0029: Unknown result type (might be due to invalid IL or missing references)
     //IL_0035: Unknown result type (might be due to invalid IL or missing references)
     //IL_003a: Unknown result type (might be due to invalid IL or missing references)
     //IL_0054: Unknown result type (might be due to invalid IL or missing references)
     //IL_0059: Unknown result type (might be due to invalid IL or missing references)
     this.missile     = missile;
     this.spawnedItem = spawnedItem;
     position         = ((MBMissile)missile).GetPosition();
     velocity         = ((MBMissile)missile).GetVelocity();
     matrixFrame      = missile.Entity.GetGlobalFrame();
 }
Ejemplo n.º 6
0
        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
            }
        }
Ejemplo n.º 7
0
        public override void OnItemPickup(Agent agent, SpawnedItemEntity item)
        {
            base.OnItemPickup(agent, item);

            if (!IsActivated)
            {
                return;
            }

            if (!Utils.IsAmmo(item))
            {
                return;
            }

            if (PlayerAgent != null && Utils.IsPlayerAlly(agent, PlayerAgent))
            {
                OnAllyPickedUpAmmoEvent?.Invoke(agent, item);
            }
        }
        void IStatus.Leave()
        {
            Main.Enable = false;
            if (Mission.Current == null)
            {
                return;
            }


            foreach (Agent agent in Mission.Current.Agents.ToArray())
            {
                if (agent == Mission.Current.MainAgent)
                {
                    continue;
                }

                agent.SetMaximumSpeedLimit(-1f, false);
                agent.SetController(Agent.ControllerType.AI);
            }

            Main.agentToDice.Clear();



            foreach (var missile2 in _Missiles.Values)
            {
                var missile = missile2.missile;

                SpawnedItemEntity spawnedItem = missile2.spawnedItem;

                if (spawnedItem.GameEntity != null)
                {
                    addMissileToMission(missile2);
                    spawnedItem.GameEntity.Remove(81);
                    spawnedItem.OnSpawnedItemEntityRemoved();
                }
            }
        }
Ejemplo n.º 9
0
        private void SetFireSwordEnable(bool enable)
        {
            if (Agent.Main == null)
            {
                return;
            }
            if (enable)
            {
                EquipmentIndex index = Agent.Main.GetWieldedItemIndex(Agent.HandIndex.MainHand);
                if (index == EquipmentIndex.None)
                {
                    return;
                }
                GameEntity wieldedWeaponEntity = Agent.Main.GetWeaponEntityFromEquipmentSlot(index);

                MissionWeapon wieldedWeapon = Agent.Main.WieldedWeapon;
                int           length        = wieldedWeapon.GetWeaponStatsData()[0].WeaponLength;
                int           num           = (int)Math.Round(length / 10f);
                Skeleton      skeleton      = Agent.Main.AgentVisuals.GetSkeleton();

                Light light = Light.CreatePointLight(FireLordConfig.FireSwordLightRadius);
                light.Intensity  = FireLordConfig.FireSwordLightIntensity;
                light.LightColor = FireLordConfig.FireSwordLightColor;

                switch (wieldedWeapon.CurrentUsageItem.WeaponClass)
                {
                case WeaponClass.OneHandedSword:
                case WeaponClass.TwoHandedSword:
                case WeaponClass.Mace:
                case WeaponClass.TwoHandedMace:
                    for (int i = 1; i < num; i++)
                    {
                        MatrixFrame    localFrame = new MatrixFrame(Mat3.Identity, new Vec3(0, 0, 0)).Elevate(i * 0.1f);
                        ParticleSystem particle   = ParticleSystem.CreateParticleSystemAttachedToEntity("psys_game_burning_agent",
                                                                                                        wieldedWeaponEntity, ref localFrame);
                        skeleton.AddComponentToBone(Game.Current.HumanMonster.MainHandItemBoneIndex, particle);
                    }
                    light.Frame = light.Frame.Elevate((num - 1) * 0.1f);
                    break;

                case WeaponClass.OneHandedAxe:
                case WeaponClass.TwoHandedAxe:
                case WeaponClass.OneHandedPolearm:
                case WeaponClass.TwoHandedPolearm:
                case WeaponClass.LowGripPolearm:
                    int fireLenth = (num > 19)? 9 :(num > 15)? 6 : (num > 12)? 5 :(num > 10) ? 4 : 3;
                    for (int i = num - 1; i > 0 && i > num - fireLenth; i--)
                    {
                        MatrixFrame    localFrame = new MatrixFrame(Mat3.Identity, new Vec3(0, 0, 0)).Elevate(i * 0.1f);
                        ParticleSystem particle   = ParticleSystem.CreateParticleSystemAttachedToEntity("psys_game_burning_agent",
                                                                                                        wieldedWeaponEntity, ref localFrame);
                        skeleton.AddComponentToBone(Game.Current.HumanMonster.MainHandItemBoneIndex, particle);
                    }
                    light.Frame = light.Frame.Elevate((num - 1) * 0.1f);
                    break;

                default:
                    //InformationManager.DisplayMessage(new InformationMessage("当前武器无法点燃"));
                    return;
                }
                skeleton.AddComponentToBone(Game.Current.HumanMonster.MainHandItemBoneIndex, light);

                //只有通过扔掉再重新捡起这把武器,才能让粒子效果出现
                DropLock = true;
                Agent.Main.DropItem(index);
                SpawnedItemEntity spawnedItemEntity = wieldedWeaponEntity.GetFirstScriptOfType <SpawnedItemEntity>();
                Agent.Main.OnItemPickup(spawnedItemEntity, EquipmentIndex.None, out bool removeItem);
                DropLock = false;

                _fireSwordLight   = light;
                _fireSwordEntity  = wieldedWeaponEntity;
                _fireSwordEnabled = true;
            }
            else
            {
                _fireSwordEnabled = false;
                if (_fireSwordEntity != null)
                {
                    Skeleton skeleton = Agent.Main.AgentVisuals.GetSkeleton();
                    if (_fireSwordLight != null && skeleton != null)
                    {
                        skeleton.RemoveComponent(_fireSwordLight);
                    }
                    _fireSwordEntity.RemoveAllParticleSystems();
                }
            }
        }
Ejemplo n.º 10
0
 internal static bool IsAmmo(SpawnedItemEntity item)
 {
     return(item.IsStuckMissile() || item.WeaponCopy.IsAnyAmmo());
 }
Ejemplo n.º 11
0
        public override void OnMissionTick(float dt)
        {
            if (!_initialized && Mission.Current != null && Agent.Main != null)
            {
                _initialized = true;
                Initialize();
            }

            //每支箭落地燃烧,4秒火势变弱,8秒熄灭(默认)
            if (_hitArrowFires.Count > 0)
            {
                List <ArrowFireData> _deleteitems = new List <ArrowFireData>();
                foreach (ArrowFireData item in _hitArrowFires)
                {
                    if (item.timer.Check(true))
                    {
                        if (!item.delete)
                        {
                            item.delete = true;
                            GameEntity entity = item.bigFireParticle.GetEntity();
                            if (entity != null)
                            {
                                entity.GetLight().Intensity = FireLordConfig.FireArrowLightIntensity - 35;
                                entity.RemoveComponent(item.bigFireParticle);
                            }
                        }
                        else
                        {
                            GameEntity entity = item.missile.Entity;
                            if (entity != null)
                            {
                                entity.RemoveAllParticleSystems();
                                Light light = entity.GetLight();
                                if (light != null)
                                {
                                    entity.RemoveComponent(light);
                                }
                            }
                            _deleteitems.Add(item);
                        }
                    }
                }
                foreach (ArrowFireData item in _deleteitems)
                {
                    _hitArrowFires.Remove(item);
                }
            }

            //计算每个agent的着火条,满了就点燃
            if (AgentFireDatas.Count > 0)
            {
                List <Agent> _deleteAgent = new List <Agent>();
                foreach (KeyValuePair <Agent, AgentFireData> item in AgentFireDatas)
                {
                    Agent         agent    = item.Key;
                    AgentFireData fireData = item.Value;
                    if (fireData.isBurning)
                    {
                        if (FireLordConfig.IgnitionDealDamage && fireData.damageTimer.Check(true) && agent.IsActive())
                        {
                            Blow blow = CreateBlow(fireData.attacker, agent);
                            agent.RegisterBlow(blow);
                            if (fireData.attacker == Agent.Main)
                            {
                                TextObject text = GameTexts.FindText("ui_delivered_burning_damage", null);
                                text.SetTextVariable("DAMAGE", blow.InflictedDamage);
                                InformationManager.DisplayMessage(new InformationMessage(text.ToString()));
                            }
                            else if (agent == Agent.Main)
                            {
                                TextObject text = GameTexts.FindText("ui_received_burning_damage", null);
                                text.SetTextVariable("DAMAGE", blow.InflictedDamage);
                                InformationManager.DisplayMessage(new InformationMessage(text.ToString(), Color.ConvertStringToColor("#D65252FF")));
                            }
                        }
                        if (fireData.burningTimer.Check())
                        {
                            if (fireData.fireEntity != null)
                            {
                                foreach (ParticleSystem particle in fireData.particles)
                                {
                                    fireData.fireEntity.RemoveComponent(particle);
                                }
                                if (fireData.fireLight != null)
                                {
                                    fireData.fireLight.Intensity = 0;
                                    Skeleton skeleton = agent.AgentVisuals.GetSkeleton();
                                    if (skeleton != null)
                                    {
                                        skeleton.RemoveComponent(fireData.fireLight);
                                    }
                                }
                                fireData.fireEntity = null;
                                fireData.fireLight  = null;
                            }
                            fireData.firebar   = 0;
                            fireData.isBurning = false;
                        }
                    }
                    else
                    {
                        if (fireData.firebar >= FireLordConfig.IgnitionBarMax)
                        {
                            fireData.isBurning    = true;
                            fireData.burningTimer = new MissionTimer(FireLordConfig.IgnitionDurationInSecond);
                            fireData.damageTimer  = new MissionTimer(1f);
                            EquipmentIndex index = agent.GetWieldedItemIndex(Agent.HandIndex.MainHand);
                            if (index == EquipmentIndex.None)
                            {
                                return;
                            }
                            GameEntity wieldedWeaponEntity = agent.GetWeaponEntityFromEquipmentSlot(index);
                            Skeleton   skeleton            = agent.AgentVisuals.GetSkeleton();
                            if (skeleton == null)
                            {
                                return;
                            }
                            fireData.particles = new ParticleSystem[_ignitionBoneIndexes.Length];
                            for (byte i = 0; i < _ignitionBoneIndexes.Length; i++)
                            {
                                MatrixFrame    localFrame = new MatrixFrame(Mat3.Identity, new Vec3(0, 0, 0));
                                ParticleSystem particle   = ParticleSystem.CreateParticleSystemAttachedToEntity("psys_campfire",
                                                                                                                wieldedWeaponEntity, ref localFrame);
                                skeleton.AddComponentToBone(_ignitionBoneIndexes[i], particle);
                                fireData.particles[i] = particle;
                            }

                            //只有通过扔掉再重新捡起这把武器,才能让粒子效果出现
                            FireSwordLogic.DropLock = true;
                            agent.DropItem(index);
                            SpawnedItemEntity spawnedItemEntity = wieldedWeaponEntity.GetFirstScriptOfType <SpawnedItemEntity>();
                            agent.OnItemPickup(spawnedItemEntity, EquipmentIndex.None, out bool removeItem);
                            fireData.fireEntity     = wieldedWeaponEntity;
                            FireSwordLogic.DropLock = false;

                            Light light = Light.CreatePointLight(FireLordConfig.IgnitionLightRadius);
                            light.Intensity  = FireLordConfig.IgnitionLightIntensity;
                            light.LightColor = FireLordConfig.IgnitionLightColor;
                            skeleton.AddComponentToBone(0, light);
                            fireData.fireLight = light;
                        }
                        else
                        {
                            fireData.firebar -= dt * FireLordConfig.IgnitionDropPerSecond;
                            fireData.firebar  = Math.Max(fireData.firebar, 0);

                            if (!agent.IsActive())
                            {
                                _deleteAgent.Add(agent);
                            }
                        }
                    }
                }
                foreach (Agent agent in _deleteAgent)
                {
                    AgentFireData fireData = AgentFireDatas[agent];
                    GameEntity    entity   = fireData.fireEntity;
                    if (entity != null)
                    {
                        entity.RemoveAllParticleSystems();
                    }
                    Skeleton skeleton = agent.AgentVisuals.GetSkeleton();
                    if (skeleton != null && fireData.fireLight != null)
                    {
                        skeleton.RemoveComponent(fireData.fireLight);
                    }
                    AgentFireDatas.Remove(agent);
                }
            }
        }