public ItemObject(string id, World world) { World = world; TemplateId = id; _durability = new Lockable <double>(MaximumDurability); _count = new Lockable <int>(1); }
private int GetMessageSize() { var result = new Lockable <int>(); var messageSizeBuffer = new byte[4]; var cts = new CancellationTokenSource(100); try { Stream.Value.ReadAsync(messageSizeBuffer, 0, 4, cts.Token).ContinueWith(task => { var len = BitConverter.ToInt32(messageSizeBuffer, 0); result.Value = len; }, TaskContinuationOptions.OnlyOnRanToCompletion).Wait(); } catch (TaskCanceledException) { //ignore } catch (AggregateException) { //ignore - Log.e("PipeTransceiver.AggregateException: " + e.Message); } return(result.Value); }
public Lockable Create(Lockable lockable) { return(apiService.SendAndConvert <Lockable, Lockable>( HttpMethod.Post, new Uri("api/lockable/create", UriKind.Relative), lockable)); }
public Door(Room roomA, Room roomB) { this.roomA = roomA; this.roomB = roomB; closed = false; theLock = new RegularLock(); }
int IComparer.Compare(object a, object b) { Lockable lockable1 = (Lockable)a; Lockable lockable2 = (Lockable)b; if (lockable1 == null && lockable2 == null) { return(0); } if (lockable1 == null) { return(-1); } if (lockable2 == null) { return(1); } float dist1 = Vector3.Distance(lockable1.transform.position, anchorPos); float dist2 = Vector3.Distance(lockable2.transform.position, anchorPos); return((int)Mathf.Sign(dist1 - dist2)); }
// RAYCAST TO SEE IF WE ARE LOCKING ON TO ANYTHING private void checkLockOn() { // initialize RaycastHits RaycastHit hitFar = new RaycastHit(); // Vector shit Vector3 aim = transform.position - cam.transform.position; Vector3 offset = Vector3.Normalize(aim) * .009f; Debug.DrawRay(transform.position + offset, Vector3.Normalize(aim) * 200, Color.blue); bool f = Physics.Raycast(transform.position + offset, aim, out hitFar, 200); // lock on to a far target if (f && checkLockable(hitFar)) { updateState(hitFar); } // Or else reset else if (currentState != State.IDLE) { if (target) { Lockable l = (Lockable)target.GetComponents(typeof(Lockable))[0]; l.onRelease(); } reset(); } }
private void Acquire(Lock @lock) { lock (this) { Lockable.Acquired(@lock); locks.Add(@lock); } }
private async Task <IEnumerable <Lockable> > GenerateLockables(int number) { var lockables = new List <Lockable>(); for (var i = 0; i < number; i++) { var categories = i % 2 == 0 ? new[] { "blue", "purple" } : new[] { "blue" }; var customer = new Customer { Age = i + 20, FirstName = i % 2 == 0 ? "Bob" : "Tim", LastName = i % 3 == 0 ? "Jones" : "Potter" }; var lockable = new Lockable { Categories = categories, CreatedOn = DateTime.Now, Data = customer, Name = "Customer", Locks = new Lock[0] }; lockables.Add(lockable); } var results = await LockableService.CreateManyAsync(lockables); return(results.Results); }
public Lockable Update(Lockable lockable) { return(apiService.SendAndConvert <Lockable, Lockable>( HttpMethod.Put, new Uri("api/lockable/update"), lockable)); }
private void LockOnByOffset(int offset, Vector3 lockAnchor) { if (!HasLockOn()) { lockables.SortByDistance(lockAnchor); } Lockable newLock = null; for (int nextOffset = offset, iterations = 0; iterations < lockables.Value.Length; nextOffset += offset, iterations++) { newLock = lockables.GetNextByOffset(GetLocked(), nextOffset); if (newLock != GetLocked() && newLock != null && newLock.CanLock()) { break; // not found } } UnlockOn(); if (newLock != null) { currentlyLocked.Value = newLock; newLock.OnLock(); } else { Debug.Log("Nothing to lockOn"); } }
protected override void OnStop() { if (hasLock && lockable != null) { lockable.locked = false; lockable = null; } }
public Inventory(int size) { _itemsObject = new Lockable <ItemObject[]>(new ItemObject[size]); _size = new Lockable <int>(size); _count = new Lockable <int>(0); _weight = new Lockable <int>(0); _inventoryIndex = new ConcurrentDictionary <string, List <ItemObject> >(); }
public void Release(Lock @lock) { lock (this) { locks.Remove(@lock); Lockable.Released(@lock); Monitor.PulseAll(this); } }
// Simple copy constructor for an ItemObject, mostly used when we split a stack and it results // in the creation of a new ItemObject. public ItemObject(ItemObject previousItemObject) { _count = new Lockable <int>(previousItemObject.Count); _durability = new Lockable <double>(previousItemObject.Durability); World = previousItemObject.World; TemplateId = previousItemObject.TemplateId; Durability = previousItemObject.Durability; Count = previousItemObject.Count; }
/// <summary> /// Get the hashcode of this object. /// </summary> public override Int32 GetHashCode() { unchecked { return(Plug.GetHashCode() * 7 ^ Lockable.GetHashCode() * 5 ^ CableAttached.GetHashCode() * 3 ^ CableLength.GetHashCode()); } }
/// <summary> /// Compares two SocketOutlet for equality. /// </summary> /// <param name="SocketOutlet">An SocketOutlet to compare with.</param> /// <returns>True if both match; False otherwise.</returns> public Boolean Equals(SocketOutlet SocketOutlet) { if ((Object)SocketOutlet == null) { return(false); } return(Plug.Equals(SocketOutlet.Plug) && Lockable.Equals(SocketOutlet.Lockable) && CableAttached.Equals(SocketOutlet.CableAttached) && CableLength.Equals(SocketOutlet.CableLength)); }
public void Incorrect_Key_Length_Returns_None_With_InvalidKeyLengthMsg() { // Arrange var box = new Lockable <string>(Rnd.Str); var key = Rnd.ByteF.Get(20); // Act var result = box.Lock(key); // Assert result.AssertNone().AssertType <InvalidKeyLengthMsg>(); }
public void Sets_Properties() { // Arrange var value = Rnd.Str; var box = new Lockable <string>(value); // Act var result = box.Contents; // Assert Assert.Equal(value, result); }
public void String_Key_Returns_Locked() { // Arrange var box = new Lockable <string>(Rnd.Str); var key = Rnd.Str; // Act var result = box.Lock(key); // Assert Assert.NotNull(result.EncryptedContents); }
private void fire(RaycastHit hit) { // If we have a Rigidbody, apply an explosive force to it if (hit.rigidbody) { hit.rigidbody.AddExplosionForce(power, transform.position, radius); } // Call the target's onFire function Lockable l = (Lockable)hit.transform.GetComponents(typeof(Lockable))[0]; l.onFire(); }
void OnCollisionEnter(Collision c) { if (c.rigidbody && c.transform.GetComponents(typeof(Lockable)).Length > 0) { c.rigidbody.AddForce(Vector3.Normalize(c.transform.position - transform.position) * stoppingPower); Lockable l = (Lockable)c.transform.GetComponents(typeof(Lockable))[0]; l.onArrow(); currentState = State.HIT; transform.parent = c.transform; Destroy(transform.rigidbody); Destroy(transform.collider); transform.position += transform.up * .15f; } }
public void Byte_Key_Returns_Locked() { // Arrange var box = new Lockable <string>(Rnd.Str); var key = Rnd.ByteF.Get(32); // Act var result = box.Lock(key); // Assert var some = result.AssertSome(); Assert.NotNull(some.EncryptedContents); }
public void Remove(Lockable lockable) { if (GetLocked() == lockable) { if (LockNextOnRemove) { LockOnNext(lockable.transform.position); } else { UnlockOn(); } } lockables.Remove(lockable); }
void Start() { pointsInTime = new List <PointInTime>(); if (GetComponent <Rigidbody>() != null) { rb = GetComponent <Rigidbody>(); } if (GetComponent <Lockable>() != null) { lockable = GetComponent <Lockable>(); } if (GetComponent <MovingObject>() != null) { movingObject = GetComponent <MovingObject>(); } }
private void fire(Transform t) { // If we have a Rigidbody, apply an explosive force to it if (t.rigidbody) { t.rigidbody.AddExplosionForce(power, transform.position - new Vector3(0, 1, 0), radius); } // Call the target's onFire function Lockable l = (Lockable)t.GetComponents(typeof(Lockable))[0]; l.onFire(); // Sounds gameMaster.onFire(); }
protected override void OnStart(Context context) { GameObject subjectObj; if (context.memory.Recall(subject, out subjectObj)) { lockable = subjectObj.GetComponent <Lockable>(); if (lockable != null && !lockable.locked) { lockable.locked = true; hasLock = true; return; } } hasLock = false; }
public void SimpleTyped() { var age = new Lockable <int>(25); var name = "Jordan"; var result = Thread <int> .Create <int>((internalAge, cts) => { Assert.IsTrue(age.Value == internalAge); age.Value = 47; }, (b, exception) => { name = "Jordan Duerksen"; }, age.Value).Join(1000); Assert.IsTrue(age.Value == 47); Assert.IsTrue(result); Assert.IsTrue(name == "Jordan Duerksen"); }
public StatInfo(bool defaultAttr = true) { // TODO: DRY _level = new Lockable <byte>(1); _experience = new Lockable <uint>(0); _ability = new Lockable <byte>(0); _abilityExp = new Lockable <uint>(0); _hp = new Lockable <uint>(50); _mp = new Lockable <uint>(50); _baseHp = new Lockable <long>(50); _baseMp = new Lockable <long>(50); _baseStr = new Lockable <long>(defaultAttr ? 3 : 0); _baseInt = new Lockable <long>(defaultAttr ? 3 : 0); _baseWis = new Lockable <long>(defaultAttr ? 3 : 0); _baseCon = new Lockable <long>(defaultAttr ? 3 : 0); _baseDex = new Lockable <long>(defaultAttr ? 3 : 0); _bonusHp = new Lockable <long>(0); _bonusMp = new Lockable <long>(0); _bonusStr = new Lockable <long>(0); _bonusInt = new Lockable <long>(0); _bonusWis = new Lockable <long>(0); _bonusCon = new Lockable <long>(0); _bonusDex = new Lockable <long>(0); _bonusDmg = new Lockable <long>(0); _bonusHit = new Lockable <long>(0); _bonusAc = new Lockable <long>(0); _bonusMr = new Lockable <long>(0); _bonusRegen = new Lockable <long>(0); _baseOffensiveElement = new Lockable <Xml.Element>(Xml.Element.None); _baseDefensiveElement = new Lockable <Xml.Element>(Xml.Element.None); _offensiveElementOverride = new Lockable <Xml.Element>(Xml.Element.None); _defensiveElementOverride = new Lockable <Xml.Element>(Xml.Element.None); _baseReflectChance = new Lockable <double>(0); _bonusReflectChance = new Lockable <double>(0); _damageTypeOverride = new Lockable <Xml.DamageType?>(null); _baseReflectIntensity = new Lockable <double>(1); _bonusReflectIntensity = new Lockable <double>(0); _baseHealModifier = new Lockable <double>(1); _bonusHealModifier = new Lockable <double>(0); _baseDamageModifier = new Lockable <double>(1); _bonusDamageModifier = new Lockable <double>(0); _random = new Lockable <Random>(new Random()); }
public async Task CreateTest() { var lockable = new Lockable { Categories = new[] { "blue", "purple" }, CreatedOn = DateTime.Now, Data = new Customer { FirstName = "Alex", LastName = "Hayes", Age = 23 }, Locks = new Lock[0], Name = "Customers" }; var result = await LockableService.CreateAsync(lockable); Assert.IsNotNull(result); }
public void CreateTest() { var lockable = new Lockable { Categories = new List <string> { "Nop", "Address" }, Data = new Address { Address1 = "Make Believe Ln.", Address2 = "Suite B.", Name = "Address", Zip = "12345-12345" }, Name = "Address", Locks = new Lock[0] }; var createdLockable = LockableManagerService.Create(lockable); Assert.IsNotNull(createdLockable); Assert.IsNotNull(createdLockable.Id); }