Ejemplo n.º 1
0
        public override void Update(double deltaTime)
        {
            var partyMembers = PartySystem.ClientGetCurrentPartyMembers();

            if (character.IsInitialized && !character.IsDestroyed &&
                character.ProtoGameObject is PlayerCharacter &&
                !character.GetPublicState <ICharacterPublicState>().IsDead &&
                character.GetPublicState <PlayerCharacterPublicState>().SelectedItemWeaponProto != null &&
                character.GetPublicState <PlayerCharacterPublicState>().SelectedItemWeaponProto is IProtoItemWeaponRanged &&
                (!partyMembers.Contains(character.Name) || character.IsCurrentClientCharacter))
            {
                var beamColor = Colors.Red;
                if (partyMembers.Contains(character.Name) || character.IsCurrentClientCharacter)
                {
                    beamColor = Colors.Green;
                }
                var protoWeapon  = character.GetPublicState <ICharacterPublicState>().SelectedItemWeaponProto;
                var ammoMaxRange = character.GetPublicState <PlayerCharacterPublicState>().SelectedItemWeaponProto?.CompatibleAmmoProtos?
                                   .Max <IProtoItemAmmo>(obj => obj.DamageDescription.RangeMax)
                                   ?? protoWeapon?.OverrideDamageDescription?.RangeMax ?? 0.0;
                var rangeMultiplier = character.GetPublicState <ICharacterPublicState>().SelectedItemWeaponProto?.RangeMultiplier ?? 0.0;
                var rangeMax        = ammoMaxRange * rangeMultiplier;
                var rangedPosition  = character.Position + (0, character.ProtoCharacter.CharacterWorldWeaponOffsetRanged);
                var toPosition      = rangedPosition
                                      + new Vector2D(rangeMax, 0)
                                      .RotateRad(character.ProtoCharacter.SharedGetRotationAngleRad(character));
                bool isBlocking  = false;
                var  hitPosition = Vector2D.Zero;
                LineTraceForHitResults(GetTracerLocation(), toPosition, ref isBlocking, ref hitPosition);
                var tmpToPosition = Vector2D.Zero;
                if (isBlocking)
                {
                    tmpToPosition = toPosition;
                    toPosition    = hitPosition;
                }

                if (rangeMax > 0)
                {
                    ComponentTracerBeam.Create(
                        sourcePosition: GetTracerLocation(),
                        targetPosition: toPosition,
                        traceStartWorldOffset: 0.1,
                        texture: TextureResourceBeam,
                        beamWidth: 0.12,
                        originOffset: Vector2D.Zero,
                        true,
                        fadeInDistance: 0.0,
                        fadeOutDistanceHit: 0.0,
                        fadeOutDistanceNoHit: 0.0,
                        blendMode: BlendMode.AdditivePremultiplied,
                        beamColor);

                    if (isBlocking)
                    {
                        ComponentTracerBeam.Create(
                            sourcePosition: toPosition,
                            targetPosition: tmpToPosition,
                            traceStartWorldOffset: 0.1,
                            texture: TextureResourceBeam,
                            beamWidth: 0.12,
                            originOffset: Vector2D.Zero,
                            true,
                            fadeInDistance: 0.0,
                            fadeOutDistanceHit: 0.0,
                            fadeOutDistanceNoHit: 0.0,
                            blendMode: BlendMode.AdditivePremultiplied,
                            beamColor,
                            0.34);
                    }
                }
            }
        }