public ForwardChainExpectation When(
     HttpRequest httpRequest, Times times, TimeToLive timeToLive, int priority = DefaultPriority)
 {
     return(new ForwardChainExpectation(
                this,
                new Expectation(httpRequest, times, timeToLive, priority)));
 }
        /// <summary>
        /// Calculates a hash code for this object.
        /// </summary>
        /// <returns>The hash code for this instance of <see cref="RandomParticleProperties"/>.</returns>
        public override int GetHashCode()
        {
            unchecked // Overflow is fine, just wrap
            {
                int hash = 23;

                if (Speed != null)
                {
                    hash = hash * 31 + Speed.GetHashCode();
                }
                if (Tint != null)
                {
                    hash = hash * 31 + Tint.GetHashCode();
                }
                if (Scale != null)
                {
                    hash = hash * 31 + Scale.GetHashCode();
                }
                if (TimeToLive != null)
                {
                    hash = hash * 31 + TimeToLive.GetHashCode();
                }
                if (ColorFactor != null)
                {
                    hash = hash * 31 + ColorFactor.GetHashCode();
                }
                if (RotationChange != null)
                {
                    hash = hash * 31 + RotationChange.GetHashCode();
                }
                return(hash);
            }
        }
        public void Execute(ArchetypeChunk chunk, int chunkIndex, int firstEntityIndex)
        {
            var chunkHealths      = chunk.GetNativeArray(healthType);
            var chunkTranslations = chunk.GetNativeArray(translationType);

            for (int i = 0; i < chunk.Count; i++)
            {
                float       damage = 0f;
                Health      health = chunkHealths[i];
                Translation pos    = chunkTranslations[i];

                if (doTimeToLive)
                {
                    for (int b_chuck_i = 0; b_chuck_i < bullerChucks.Length; b_chuck_i++)
                    {
                        var b_chuck = bullerChucks[b_chuck_i];

                        var b_trans          = b_chuck.GetNativeArray(translationType);
                        var b_times_to_lives = b_chuck.GetNativeArray(timeToLiveType);

                        for (int b_i = 0; b_i < b_chuck.Count; b_i++)
                        {
                            TimeToLive time_to_live = b_times_to_lives[b_i];

                            if (time_to_live.Value > 0.0f)
                            {
                                Translation pos2 = b_trans[b_i];

                                if (CheckCollision(pos.Value, pos2.Value, radius))
                                {
                                    damage += 1;

                                    time_to_live.Value    = 0.0f;
                                    b_times_to_lives[b_i] = time_to_live;
                                }
                            }
                        }
                    }
                }
                else
                {
                    for (int j = 0; j < transToTestAgainst.Length; j++)
                    {
                        Translation pos2 = transToTestAgainst[j];

                        if (CheckCollision(pos.Value, pos2.Value, radius))
                        {
                            damage += 1;
                        }
                    }
                }

                if (damage > 0)
                {
                    health.Value   -= damage;
                    chunkHealths[i] = health;
                }
            }
        }
Example #4
0
    // Use this for initialization
    void Start()
    {
        line = GetComponent <LineRenderer>();
        ttl  = GetComponent <TimeToLive>();

        line.SetPosition(0, Vector3.one * 1000);
        line.SetPosition(1, Vector3.one * 1000);
    }
Example #5
0
        public void when_item_is_not_specified()
        {
            Action creation = () => new StoreCommand(null, TimeToLive.CreateNeverExpiring(), 1);

            creation
            .ShouldThrow <ArgumentException>()
            .WithMessage("When storing item, item should be specified.", ComparisonMode.Substring);
        }
Example #6
0
        public void when_items_value_is_not_specified()
        {
            Action creation = () => new StoreCommand(new CacheItem(), TimeToLive.CreateNeverExpiring(), 1);

            creation
            .ShouldThrow <ArgumentException>()
            .WithMessage("item's value should be specified", ComparisonMode.Substring);
        }
Example #7
0
    // Use this for initialization
    void Start()
    {
        screenUpperLeft  = Camera.main.ScreenToWorldPoint(new Vector3(0, Screen.height, 0));
        screenLowerRight = Camera.main.ScreenToWorldPoint(new Vector3(Screen.width, 0, 0));

        ttl     = GetComponent <TimeToLive>();
        tracker = GetComponent <ObjectChaser>();
        trigger = GetComponent <Collider>();
    }
Example #8
0
        protected virtual void SendPushRegistration(ReactorVirtualClient c)
        {
            EosPacket p = new EosPacket();

            p.Sender = ReactorServer.Id;
            p.Type   = EosPacketType.Registered;
            p.Data.Add(Encoding.Unicode.GetBytes(TimeToLive.ToString()));
            c.SendPacket(p.ToBytes());
        }
 /// <inheritdoc />
 public override int GetHashCode()
 {
     unchecked
     {
         var hashCode = TimeUnit.GetHashCode();
         hashCode = (hashCode * 397) ^ TimeToLive.GetHashCode();
         hashCode = (hashCode * 397) ^ Unlimited.GetHashCode();
         return(hashCode);
     }
 }
Example #10
0
        public void when_specifying_check_and_set_store_mode()
        {
            Action creation = () => new StoreCommand(new CacheItem {
                Data = 1
            }, TimeToLive.CreateNeverExpiring(), StoreMode.CheckAndSet);

            creation
            .ShouldThrow <ArgumentException>()
            .WithMessage("To initialize 'Check and Set' command use another constructor, which accepts unique ID.", ComparisonMode.Substring);
        }
Example #11
0
 public override int GetHashCode()
 {
     unchecked
     {
         var hashCode = (int)State;
         hashCode = (hashCode * 397) ^ TimeToLive.GetHashCode();
         hashCode = (hashCode * 397) ^ TimeStamp.GetHashCode();
         return(hashCode);
     }
 }
Example #12
0
 public bool Equals(CircuitBreakerStateDescriptor other)
 {
     if (ReferenceEquals(null, other))
     {
         return(false);
     }
     if (ReferenceEquals(this, other))
     {
         return(true);
     }
     return(State == other.State && TimeToLive.Equals(other.TimeToLive) && TimeStamp.Equals(other.TimeStamp));
 }
Example #13
0
        public void Store(string encryptedPassword, string key, TimeToLive timeToLive)
        {
            var item = new Item
            {
                StoredDateTime    = DateTime.Now,
                TimeToLive        = timeToLive,
                EncryptedPassword = encryptedPassword,
                Key = key
            };

            _items.Add(key, item);
        }
Example #14
0
                public override string ToString()
                {
                    List <string> slug = new List <string>();

                    slug.Add(@"--" + OPT_TIMETOLIVE + "=" + BaconArgs.Escape(TimeToLive.ToString()));
                    slug.Add(@"--" + OPT_TIMECREATED + "=" + BaconArgs.Escape(DateTimeToTimestamp(TimeCreated).ToString()));
                    slug.Add(@"--" + OPT_TYPE + "=" + BaconArgs.Escape(Type));
                    slug.Add(@"--" + OPT_SENDER + "=" + BaconArgs.Escape(Sender));
                    slug.Add(@"--");
                    slug.Add(Content);
                    return(string.Join(" ", slug));
                }
Example #15
0
        public override bool Equals(object obj)
        {
            var record = obj as BaseResourceRecord;

            return(record != null &&
                   EqualityComparer <Domain> .Default.Equals(Name, record.Name) &&
                   Type == record.Type &&
                   Class == record.Class &&
                   TimeToLive.Equals(record.TimeToLive) &&
                   DataLength == record.DataLength &&
                   EqualityComparer <byte[]> .Default.Equals(Data, record.Data) &&
                   Size == record.Size);
        }
Example #16
0
        //plays a sfx at a certain world position
        public void playSFXAtPosition(string name, Vector3 worldPosition, Transform parent)
        {
            bool SFXFound = false;

            foreach (AudioItem audioItem in AudioList)
            {
                if (audioItem.name == name)
                {
                    //check the time threshold
                    if (Time.time - audioItem.lastTimePlayed < audioItem.MinTimeBetweenCall)
                    {
                        return;
                    }
                    else
                    {
                        audioItem.lastTimePlayed = Time.time;
                    }

                    //pick a random number
                    int rand = Random.Range(0, audioItem.clip.Length);

                    //create gameobject for the audioSource
                    GameObject audioObj = new GameObject();
                    audioObj.transform.parent   = parent;
                    audioObj.name               = name;
                    audioObj.transform.position = worldPosition;
                    AudioSource audiosource = audioObj.AddComponent <AudioSource>();

                    //audio source settings
                    audiosource.clip                  = audioItem.clip[rand];
                    audiosource.spatialBlend          = 1.0f;
                    audiosource.minDistance           = 4f;
                    audiosource.volume                = audioItem.volume * sfxVolume;
                    audiosource.outputAudioMixerGroup = source.outputAudioMixerGroup;
                    audiosource.loop                  = audioItem.loop;
                    audiosource.Play();

                    //Destroy on finish
                    if (!audioItem.loop && audiosource.clip != null)
                    {
                        TimeToLive TTL = audioObj.AddComponent <TimeToLive> ();
                        TTL.LifeTime = audiosource.clip.length;
                    }
                    SFXFound = true;
                }
            }
            if (!SFXFound)
            {
                Debug.Log("no sfx found with name: " + name);
            }
        }
Example #17
0
    /// <summary>
    /// 播放音效
    /// </summary>
    /// <param name="name">音效名称</param>
    /// <param name="worldPosition">播放位置</param>
    /// <param name="parent">父物体</param>
    public void playSFXAtPosition(string name, Vector3 worldPosition, Transform parent)
    {
        bool SFXFound = false;

        foreach (AudioItem s in AudioList)
        {
            if (s.name == name)
            {
                //check the time threshold
                if (Time.time - s.lastTimePlayed < s.MinTimeBetweenCall)
                {
                    return;
                }
                else
                {
                    s.lastTimePlayed = Time.time;
                }


                int rand = Random.Range(0, s.clip.Length);

                //创建播放器
                GameObject audioObj = new GameObject();
                audioObj.transform.parent   = parent;
                audioObj.name               = name;
                audioObj.transform.position = worldPosition;
                AudioSource audiosource = audioObj.AddComponent <AudioSource>();

                //音效设置
                audiosource.clip                  = s.clip[rand];
                audiosource.spatialBlend          = 1.0f;
                audiosource.minDistance           = 4f;
                audiosource.volume                = s.volume * sfxVolume;
                audiosource.outputAudioMixerGroup = source.outputAudioMixerGroup;
                audiosource.loop                  = s.loop;
                audiosource.Play();

                //播放完成后销毁
                if (!s.loop && audiosource.clip != null)
                {
                    TimeToLive TTL = audioObj.AddComponent <TimeToLive>();
                    TTL.LifeTime = audiosource.clip.length;
                }
                SFXFound = true;
            }
        }
        if (!SFXFound)
        {
            Debug.Log("没有找到:  " + name);
        }
    }
Example #18
0
        public int CompareTo(DnsRecordBase other)
        {
            int compare = Name.CompareTo(other.Name);

            if (compare != 0)
            {
                return(compare);
            }

            compare = RecordType.CompareTo(other.RecordType);
            if (compare != 0)
            {
                return(compare);
            }

            compare = RecordClass.CompareTo(other.RecordClass);
            if (compare != 0)
            {
                return(compare);
            }

            compare = TimeToLive.CompareTo(other.TimeToLive);
            if (compare != 0)
            {
                return(compare);
            }

            int maxLength = 2 + Math.Max(MaximumRecordDataLength, other.MaximumRecordDataLength);

            byte[] thisBuffer = new byte[maxLength];
            int    thisLength = 0;

            EncodeRecordBody(thisBuffer, 0, ref thisLength, null, false);

            byte[] otherBuffer = new byte[maxLength];
            int    otherLength = 0;

            other.EncodeRecordBody(otherBuffer, 0, ref otherLength, null, false);

            for (int i = 0; i < Math.Min(thisLength, otherLength); i++)
            {
                compare = thisBuffer[i].CompareTo(otherBuffer[i]);
                if (compare != 0)
                {
                    return(compare);
                }
            }

            return(thisLength.CompareTo(otherLength));
        }
Example #19
0
        public StoreCommand(CacheItem item, TimeToLive timeToLive, ulong uniqueID)
        {
            Condition.Requires(item).IsNotNull(
                "When storing item, item should be specified.");
            Condition.Requires(timeToLive).IsNotNull(
                "When storing item '{0}', item's time to live should be specified".FormatString(item));
            Condition.Requires(item.Data).IsNotNull(
                "When storing item '{0}', item's value should be specified.".FormatString(item));

            _item       = item;
            _timeToLive = timeToLive;
            _storeMode  = StoreMode.CheckAndSet;
            _uniqueID   = uniqueID;
        }
Example #20
0
 public when_setting_item_with_check_and_operation_fails()
 {
     Given(() => item_is_handled_and_key_generated("simplekey"));
     Given(() => value_serialized_to("source_value", "formatted_value"));
     Given(() => item_is_checked_but_is_not_stored_successfully(
               "simplekey",
               "formatted_value",
               12,
               TimeToLive.CreateValidFor(TimeSpan.FromMinutes(2))));
     When(() => result = runtime.CheckAndSet(
              item => item.ValueOf("source_value"),
              12,
              TimeToLive.CreateValidFor(TimeSpan.FromMinutes(2))));
 }
Example #21
0
 public when_setting_item_with_check_and_item_was_already_updated_by_someone_else()
 {
     Given(() => item_is_handled_and_key_generated("simplekey"));
     Given(() => value_serialized_to("source_value", "formatted_value"));
     Given(() => item_was_already_updated_by_someone_else(
               "simplekey",
               "formatted_value",
               12,
               TimeToLive.CreateValidFor(TimeSpan.FromMinutes(2))));
     When(() => result = runtime.CheckAndSet(
              item => item.ValueOf("source_value"),
              12,
              TimeToLive.CreateValidFor(TimeSpan.FromMinutes(2))));
 }
Example #22
0
        public StoreCommand(CacheItem item, TimeToLive timeToLive, ulong uniqueID)
        {
            Condition.Requires(item).IsNotNull(
                "When storing item, item should be specified.");
            Condition.Requires(timeToLive).IsNotNull(
                "When storing item '{0}', item's time to live should be specified".FormatString(item));
            Condition.Requires(item.Data).IsNotNull(
                "When storing item '{0}', item's value should be specified.".FormatString(item));

            _item = item;
            _timeToLive = timeToLive;
            _storeMode = StoreMode.CheckAndSet;
            _uniqueID = uniqueID;
        }
        public void Register(Type Dependency, Type Implementation, TimeToLive timeToLive, int name = 0)
        {
            InterfaceImplementation implementationBuf = new InterfaceImplementation(Implementation, timeToLive, name);

            if (InterfaceDependencies.ContainsKey(Dependency))
            {
                InterfaceDependencies[Dependency].Add(implementationBuf);
            }
            else
            {
                List <InterfaceImplementation> implementations = new List <InterfaceImplementation>();
                implementations.Add(implementationBuf);
                InterfaceDependencies.Add(Dependency, implementations);
            }
        }
    public void Convert(Entity entity, EntityManager dstManager, GameObjectConversionSystem conversionSystem)
    {
        dstManager.AddComponentData(entity, new DealsDamage {
            Value = 20
        });
        MoveSpeed moveSpeed = new MoveSpeed {
            Value = speed
        };

        dstManager.AddComponentData(entity, moveSpeed);
        TimeToLive ttl = new TimeToLive {
            Value = lifeTime
        };

        dstManager.AddComponentData(entity, ttl);
    }
Example #25
0
        public StoreCommand(CacheItem item, TimeToLive timeToLive, StoreMode storeMode)
        {
            Condition.Requires(item).IsNotNull(
                "When storing item, item should be specified.");
            Condition.Requires(item.Data).IsNotNull(
                "When storing item '{0}', item's value should be specified.".FormatString(item));
            Condition.Requires(timeToLive).IsNotNull(
                "When storing item '{0}', item's time to live should be specified.".FormatString(item));
            Condition.Requires(storeMode).IsNotEqualTo(StoreMode.CheckAndSet,
                                                       "To initialize 'Check and Set' command use another constructor, which accepts unique ID.");

            _item       = item;
            _timeToLive = timeToLive;
            _storeMode  = storeMode;
            _uniqueID   = null;
        }
Example #26
0
    public void Convert(Entity entity, EntityManager manager, GameObjectConversionSystem conversionSystem)
    {
        manager.AddComponent(entity, typeof(MoveForward));

        MoveSpeed moveSpeed = new MoveSpeed {
            Value = speed
        };

        manager.AddComponentData(entity, moveSpeed);

        TimeToLive timeToLive = new TimeToLive {
            Value = lifeTime
        };

        manager.AddComponentData(entity, timeToLive);
    }
Example #27
0
        public StoreCommand(CacheItem item, TimeToLive timeToLive, StoreMode storeMode)
        {
            Condition.Requires(item).IsNotNull(
                "When storing item, item should be specified.");
            Condition.Requires(item.Data).IsNotNull(
                "When storing item '{0}', item's value should be specified.".FormatString(item));
            Condition.Requires(timeToLive).IsNotNull(
                "When storing item '{0}', item's time to live should be specified.".FormatString(item));
            Condition.Requires(storeMode).IsNotEqualTo(StoreMode.CheckAndSet,
                "To initialize 'Check and Set' command use another constructor, which accepts unique ID.");

            _item = item;
            _timeToLive = timeToLive;
            _storeMode = storeMode;
            _uniqueID = null;
        }
Example #28
0
    public void PlaySound(AudioClip clip)
    {
        GameObject audioObject = effectsSoundPool.GetNextInstance(false);

        if (audioObject != null)
        {
            AudioSource effectSource = audioObject.GetComponent <AudioSource>();
            TimeToLive  ttl          = audioObject.GetComponent <TimeToLive>();

            audioObject.SetActive(true);
            audioObject.name = effectsSoundPool.GetPooledPrefab().name;

            ttl.TTL = clip.length;

            effectSource.clip   = clip;
            effectSource.volume = soundVolume;
            effectSource.Play();
        }
    }
Example #29
0
        /// <summary>
        /// Creates a string representation of the IpPacket object.
        /// </summary>
        public override string ToString()
        {
            var s = new StringBuilder();

            s.Append("IP version: ");
            s.AppendLine(IpVersion.ToString());
            s.Append("Internet Header Length ");
            s.AppendLine(InternetHeaderLength.ToString());
            s.Append("DSCP value ");
            s.AppendLine(DscpValue.ToString());
            s.Append("ECN value ");
            s.AppendLine(ExplicitCongestionNotice.ToString());
            s.Append("IP packet length ");
            s.AppendLine(IpPacketLength.ToString());
            s.Append("ID/Fragment Group ");
            s.AppendLine(FragmentGroupId.ToString());
            s.Append("IP header flags ");
            s.AppendLine(IpHeaderFlags.ToString());
            s.Append("Fragment offset ");
            s.AppendLine(FragmentOffset.ToString());
            s.Append("TTL ");
            s.AppendLine(TimeToLive.ToString());
            s.Append("Protocol Number ");
            s.AppendLine(ProtocolNumber.ToString());
            s.Append("Header Checksum ");
            s.AppendLine(PacketHeaderChecksum.ToString());
            s.Append("Source IP ");
            s.AppendLine(SourceIpAddress.ToString());
            s.Append("Destination IP ");
            s.AppendLine(DestinationIpAddress.ToString());
            if (IpOptions != null)
            {
                s.Append("Length of IP options ");
                s.AppendLine(IpOptions.Length.ToString());
            }
            s.Append("Packet Data Length ");
            s.AppendLine(PacketData.Length.ToString());
            s.Append("Size of data buffer processed ");
            s.AppendLine(DataBuffer.Length.ToString());

            return(s.ToString());
        }
Example #30
0
        public XElement CreateHttpBody()
        {
            var payloadElement = new XElement("Payload");

            if (Payload != null && Payload.Root != null)
            {
                payloadElement.Add(Payload.Root);
            }
            else
            {
                payloadElement.Value = "#WARNING: No payload";
            }

            var binaryPayloadElement = new XElement("BinaryPayload");

            if (BinaryPayload != null)
            {
                binaryPayloadElement.Value = Convert.ToBase64String(BinaryPayload);
            }
            else
            {
                binaryPayloadElement.Value = "#WARNING: No binary payload";
            }

            return(new XElement("AMQPMessage",
                                payloadElement,
                                binaryPayloadElement,
                                new XElement("ApplicationTimestamp", ApplicationTimestamp),
                                new XElement("ContentType", ContentType),
                                new XElement("CorrelationId", CorrelationId),
                                new XElement("CpaId", CpaId),
                                new XElement("EnqueuedTimeUtc", EnqueuedTimeUtc),
                                new XElement("ScheduledEnqueueTimeUtc", ScheduledEnqueueTimeUtc),
                                new XElement("TimeToLive", TimeToLive.ToString()),
                                new XElement("To", To),
                                new XElement("ToHerId", ToHerId),
                                new XElement("FromHerId", FromHerId),
                                new XElement("MessageFunction", MessageFunction),
                                new XElement("MessageId", MessageId),
                                new XElement("ReplyTo", ReplyTo)
                                ));
        }
Example #31
0
    public void PlaySoundWithRandomPitch(AudioClip clip, float minPitch, float maxPitch)
    {
        GameObject audioObject = effectsSoundPool.GetNextInstance(false);

        if (audioObject != null)
        {
            AudioSource effectSource = audioObject.GetComponent <AudioSource>();
            TimeToLive  ttl          = audioObject.GetComponent <TimeToLive>();

            audioObject.SetActive(true);
            audioObject.name = effectsSoundPool.GetPooledPrefab().name;

            ttl.TTL = clip.length;

            effectSource.clip   = clip;
            effectSource.volume = soundVolume;
            effectSource.pitch  = Random.Range(minPitch, maxPitch);
            effectSource.Play();
        }
    }
Example #32
0
        /// <inheritdoc />
        public Int32 CompareTo(WebCookie other)
        {
            var cmp = Domain?.CompareTo(other.Domain ?? String.Empty) ?? 0;

            if (cmp != 0)
            {
                return(cmp);
            }

            cmp = Path?.CompareTo(other.Path ?? String.Empty) ?? 0;

            if (cmp != 0)
            {
                return(cmp);
            }

            cmp = Key?.CompareTo(other.Key ?? String.Empty) ?? 0;

            if (cmp != 0)
            {
                return(cmp);
            }

            cmp = Value?.CompareTo(other.Value ?? String.Empty) ?? 0;

            if (cmp != 0)
            {
                return(cmp);
            }

            cmp = TimeToLive?.CompareTo(other.TimeToLive ?? TimeSpan.Zero) ?? 0;

            if (cmp != 0)
            {
                return(cmp);
            }

            return(GetHashCode().CompareTo(other.GetHashCode()));
        }
Example #33
0
    // Use this for initialization
    void Start()
    {
        screenUpperLeft = Camera.main.ScreenToWorldPoint(new Vector3(0, Screen.height, 0));
        screenLowerRight = Camera.main.ScreenToWorldPoint(new Vector3(Screen.width, 0, 0));

        ttl = GetComponent<TimeToLive>();
        tracker = GetComponent<ObjectChaser>();
        trigger = GetComponent<Collider>();
    }
 private void item_was_already_updated_by_someone_else(string key, object value, ulong uniqueID, TimeToLive timeToLive)
 {
     memcachedClient.Setup(mc => mc.Cas(key, value, uniqueID, timeToLive)).Returns(CasResult.NotFound).Verifiable();
 }
 private void item_is_checked_and_stored_in_cache_sucessfully(string key, object value, ulong uniqueID, TimeToLive timeToLive)
 {
     memcachedClient.Setup(mc => mc.Cas(key, value, uniqueID, timeToLive)).Returns(CasResult.Stored).Verifiable();
 }