///<inheritdoc/>
        public override int GetHashCode()
        {
            int hash = 17;

            // Overflow is fine, just wrap
            unchecked
            {
                hash = (hash * 29) + PaintScheme.GetHashCode();
                hash = (hash * 29) + Mobility.GetHashCode();
                hash = (hash * 29) + Mission.GetHashCode();
                hash = (hash * 29) + Damage.GetHashCode();
                hash = (hash * 29) + Smoke.GetHashCode();
                hash = (hash * 29) + TrailingEffects.GetHashCode();
                hash = (hash * 29) + Lights.GetHashCode();
                hash = (hash * 29) + Flaming.GetHashCode();
                hash = (hash * 29) + Antenna.GetHashCode();
                hash = (hash * 29) + CamouflageType.GetHashCode();
                hash = (hash * 29) + Concealed.GetHashCode();
                hash = (hash * 29) + FrozenStatus.GetHashCode();
                hash = (hash * 29) + PowerPlantStatus.GetHashCode();
                hash = (hash * 29) + State.GetHashCode();
                hash = (hash * 29) + Tent.GetHashCode();
                hash = (hash * 29) + BlackoutLights.GetHashCode();
                hash = (hash * 29) + InteriorLights.GetHashCode();
            }

            return(hash);
        }
        public void Apply_NotACharacter_Test()
        {
            var entity    = Mock.Of <IEntity>();
            var concealed = new Concealed();

            concealed.Apply(entity);
            Assert.IsTrue(true); // If we made it here without exception then the test passed
        }
        public void Remove_NoConditions_Test()
        {
            var character = CreateMockCharacter();
            var concealed = new Concealed();

            concealed.Apply(character);
            concealed.Remove(character);
            Assert.AreEqual(0, character.Conditions.Count);
        }
        public void Apply_Character_WithExistingConcealedCondition_Test()
        {
            var character = CreateMockCharacter();

            character.Conditions.Add(new Concealed());
            var concealed = new Concealed();

            concealed.Apply(character);
        }
        public void Apply_Character_NoConditions_Test()
        {
            var character = CreateMockCharacter();
            var concealed = new Concealed();

            concealed.Apply(character);
            Assert.AreEqual(EntityIds.CONCEALED_CONDITION_ID, character.Conditions[0].Id);
            Assert.AreSame(concealed, character.Conditions[0]);
            Assert.AreEqual(ConditionGroup.Senses, character.Conditions[0].Group);
        }
Exemple #6
0
        protected void Observe()
        {
            if (!IsControlled)
            {
                return;
            }

            //Log.Trace("Observing", "Observe");

            var viewingSphere = new BoundingSphereD(Position, ViewDistance);

            //Log.Trace("Viewing shpere Center: " + viewingSphere.Center, "Observe");
            //Log.Trace("Viewing shpere Radius: " + viewingSphere.Radius, "Observe");

            List <ObservableEntity> viewableEntities = Sector.ObservableInSphere(viewingSphere);

            viewableEntities.AddRange(Concealed.EntitiesInSphere(viewingSphere));

            // don't mark self
            viewableEntities = viewableEntities.Where((e) => e.EntityId != EntityId).ToList();

            //Log.Trace("Viewable entity count: " + viewableEntities.Count, "Observe");

            if (viewableEntities.Count > 0)
            {
                Log.Trace("Entities observed: " +
                          String.Join(", ", viewableEntities.Select((e) => e.EntityId).ToList()), "observe");
            }
            else
            {
                Log.Trace(EntityId + " is not viewing any entities", "observe");
            }


            foreach (ObservableEntity e in viewableEntities)
            {
                MarkViewing(e);
            }

            // do other ranges, can use largest between detection and view,
            // but communication depends on broadcast radius of others so would have to check that too

            LastObservingTime     = DateTime.UtcNow;
            LastObservingPosition = Position;
        }
        private void UpdateRevealBlocked()
        {
            IsRevealBlocked = false;

            //Log.Trace("Begin UpdateRevealBlocked", "UpdateRevealBlocked");
            BoundingBoxD     boxCopy         = BoundingBox;
            List <IMyEntity> boundedEntities = MyAPIGateway.Entities.
                                               GetElementsInBox(ref boxCopy);

            if (boundedEntities.Count == 0)
            {
                Log.Trace("No nearby entities, reveal is not blocked", "UpdateRevealBlocked");
                return;
            }

            foreach (IMyEntity e in boundedEntities)
            {
                if (e.GetTopMostParent() != Entity)
                {
                    Log.Trace("Found an entity in bounding box that's not a child, reveal is blocked", "UpdateRevealBlocked");
                    IsRevealBlocked = true;
                    return;
                }
            }

            //Log.Trace("All entities in bounds are children.", "UpdateRevealBlocked");

            List <ConcealedEntity> concealedEntities = Concealed.EntitiesInBox(boxCopy);

            //Log.Trace("concealed boundedEntities count " + concealedEntities.Count, "UpdateRevealBlocked");

            if (concealedEntities.Count > 0)
            {
                Log.Trace("Found a concealed entity in bounding box, reveal is blocked", "UpdateRevealBlocked");
                IsRevealBlocked = true;
                return;
            }

            Log.Trace("All entities in concealed bounds are children.", "UpdateRevealBlocked");
        }
        ///<inheritdoc/>
        public override int GetHashCode()
        {
            int hash = 17;

            // Overflow is fine, just wrap
            unchecked
            {
                hash = (hash * 29) + PaintScheme.GetHashCode();
                hash = (hash * 29) + Mobility.GetHashCode();
                hash = (hash * 29) + FirePower.GetHashCode();
                hash = (hash * 29) + Damage.GetHashCode();
                hash = (hash * 29) + Smoke.GetHashCode();
                hash = (hash * 29) + TrailingEffects.GetHashCode();
                hash = (hash * 29) + Hatch.GetHashCode();
                hash = (hash * 29) + HeadLights.GetHashCode();
                hash = (hash * 29) + TailLights.GetHashCode();
                hash = (hash * 29) + BrakeLights.GetHashCode();
                hash = (hash * 29) + Flaming.GetHashCode();
                hash = (hash * 29) + Launcher.GetHashCode();
                hash = (hash * 29) + CamouflageType.GetHashCode();
                hash = (hash * 29) + Concealed.GetHashCode();
                hash = (hash * 29) + FrozenStatus.GetHashCode();
                hash = (hash * 29) + PowerPlantStatus.GetHashCode();
                hash = (hash * 29) + State.GetHashCode();
                hash = (hash * 29) + Tent.GetHashCode();
                hash = (hash * 29) + Ramp.GetHashCode();
                hash = (hash * 29) + BlackoutLights.GetHashCode();
                hash = (hash * 29) + BlackoutBrakeLights.GetHashCode();
                hash = (hash * 29) + SpotLights.GetHashCode();
                hash = (hash * 29) + InteriorLights.GetHashCode();
                hash = (hash * 29) + SurrenderState.GetHashCode();
                hash = (hash * 29) + MaskedCloaked.GetHashCode();
            }

            return(hash);
        }