Exemple #1
0
        void SendTimeStatus()
        {
            minute = ClockDisplay.minutes;
            hour   = ClockDisplay.houres;

            float time      = (hour * 60 + ((float)minute)) * 60;
            float clouds    = (float)1 / (CloudCovregeDropdown.value + 1);
            int   windSpeed = 2;
            float windDirX  = 1;
            float windDirY  = 0;

            s = new EventReports.EnvironmentState()
            {
                TimeOfDay           = time,
                TimeMultiplier      = timeMultiplier,
                CloudsCoverageScale = clouds,
                Intensity           = IntensitySlider.value,
                WindSpeed           = windSpeed,
                WindDirX            = windDirX,
                WindDirY            = windDirY,
                Fog          = PercipitationManger.Fog,
                Lightning    = PercipitationManger.Lightning,
                weatherState = PercipitationManger.weatherState
            };

            EventReportsManager.Send(s);
        }
        private void SendEventReport(EnterExitTermicStruct.Action action)
        {
            EnterExitTermicStruct s = new EnterExitTermicStruct()
            {
                deviceType = Device,
                action     = action
            };

            EntityId id = EntityId.NullId;

            if (PublishedEntity)
            {
                id = PublishedEntity.MyEntityId;
            }
            else if (InfantryConnection && InfantryConnection.OperatorReflectedEntity)
            {
                var ent = InfantryConnection.OperatorReflectedEntity;
                id = ent.EntityId;
            }
            else
            {
                return;
            }

            s.SenderId   = id;
            s.ReceiverId = id;

            EventReportsManager.Send(s);
        }
Exemple #3
0
    private void sendOrientationStruct()
    {
        float pitch = Camera.transform.rotation.eulerAngles.x;

        //if (pitch > 180)
        //    pitch -= 360;
        //pitch *= -1;

        EventReports.Orientation s = new EventReports.Orientation()
        {
            applicationType = Application,
            orientationUtm  = new Vector3(
                pitch,
                Camera.transform.rotation.eulerAngles.y,                                                                 //heading
                Camera.transform.rotation.eulerAngles.z),                                                                //roll
            vFov = Camera.fieldOfView,
            hFov = Mathf.Rad2Deg * (2 * Mathf.Atan(Mathf.Tan((Camera.fieldOfView / 2) * Mathf.Deg2Rad) * Camera.aspect)) //google
        };
        if (PublishedEntity != null)
        {
            s.SenderId = PublishedEntity.MyEntityId;
        }
        else if (Connection != null)
        {
            s.SenderId = Connection.OperatorReflectedEntity.EntityId;
        }
        EventReportsManager.Send(s);
    }
    private void Start()
    {
        TerrainLoader.TerrainFullyLoaded += () => terrainFullyLoaded = true;

        EventReportsManager.Subscribe <BuildingDamageResult>(BuildingDamageHandler);
        EventReportsManager.Subscribe <DamagedBuildingsReport>(x => StartCoroutine(DamagedBuildingsReportHandler(x)));

        EventReportsManager.Send(new DamagedBuildingsRequest());
    }
Exemple #5
0
 private void SendDeployFoldStruct(EventReports.DeployFoldDevice.Action deviceAction)
 {
     EventReports.DeployFoldDevice s = new EventReports.DeployFoldDevice()
     {
         action     = deviceAction,
         deviceType = DeviceType,
         SenderId   = PublishedEntity.MyEntityId
     };
     EventReportsManager.Send(s);
 }
        private void PublishReport()
        {
            DamagedBuildingsReport report = new DamagedBuildingsReport();

            int length = damageMessages.Messages.Count;

            DamagedBuildingsReport.DamagedBuildings[] damagedBuildings = new DamagedBuildingsReport.DamagedBuildings[length];

            for (int i = 0; i < length; i++)
            {
                BuildingDamageResult resultMessage = damageMessages.Messages[i];

                damagedBuildings[i] = new DamagedBuildingsReport.DamagedBuildings()
                {
                    Location = resultMessage.Location,
                    State    = (DamagedBuildingsReport.DamageState)resultMessage.Result
                };
            }

            report.DamagedBuildingsLength = length;
            report.Buildings = damagedBuildings;

            EventReportsManager.Send(report);
        }
    private void EntityStateChanged(EntityState entityState)
    {
        if (!checkedEntityIds.Contains(entityState.entityId))
        {
            PublishedEntity e = ExerciseConnection.LocalPublishedEntities.Find(x => x.MyEntityId == entityState.entityId);

            //Reflected entities' marking text is capped at 11 characters. This is why StartsWith is used and not ==.
            //if same entity id but different marking texts, change
            if (null != e && !e.MarkingText.StartsWith(NetSimAgent.Instance.GetReflectedEntityMarkingText(entityState.reflectedEntityPtr)))
            {
                EventReports.EntityIdChange idChange = new EventReports.EntityIdChange();
                idChange.SenderId = e.MyEntityId;
                EntityId id = new EntityId(1, UnityEngine.Random.Range(0, 9999), (ushort)UnityEngine.Random.Range(0, 255));
                idChange.NewEntityId = id;
                EventReportsManager.Send(idChange);
                e.MyEntityId = id;
                e.entityPublisher.SetEntityId(id.ToString());
                if (entitiesIdsToIgnore.Remove(idChange.SenderId))
                {
                    entitiesIdsToIgnore.Add(id);
                }
            }
            else
            {
                checkedEntityIds.Add(entityState.entityId);
            }
        }

        if (entitiesIdsToIgnore.Contains(entityState.entityId))
        {
            return;
        }

        ReflectedEntityCache reflectedEntityCache;

        bool joined = false;

        if (!reflectedEntitiesCache.TryGetValue(entityState.entityId, out reflectedEntityCache))
        {
            reflectedEntityCache = CreateReflectedEntity(entityState);
            joined = true;
        }

        if (reflectedEntityCache == null)
        {
            return;
        }

        if (reflectedEntityCache.Rigidbody != null)
        {
            reflectedEntityCache.Rigidbody.MovePosition(new Vector3(doubleToFloat(entityState.posX), doubleToFloat(entityState.posY), doubleToFloat(entityState.posZ)));
            reflectedEntityCache.Rigidbody.velocity = new Vector3(doubleToFloat(entityState.velX), doubleToFloat(entityState.velZ), doubleToFloat(entityState.velY));
        }
        else
        {
            reflectedEntityCache.Transform.position = new Vector3(doubleToFloat(entityState.posX), doubleToFloat(entityState.posY), doubleToFloat(entityState.posZ));
        }
        reflectedEntityCache.Transform.eulerAngles = new Vector3(doubleToFloat(-entityState.rotY), doubleToFloat(entityState.rotX), doubleToFloat(-entityState.rotZ));

        // TODO: Use this for Pitch.
        //reflectedEntityCache.Transform.eulerAngles = new Vector3(doubleToFloat(entityState.rotX), doubleToFloat(entityState.rotY), doubleToFloat(entityState.rotZ));

        if (reflectedEntityCache.Animator != null)
        {
            SetAnimatorParams("Posture", entityState.lifeformState, ref reflectedEntityCache.PrevLifeformState, reflectedEntityCache);
            SetAnimatorParams("Damage", entityState.DamageState, ref reflectedEntityCache.PrevDamageStateName, reflectedEntityCache);
            if (reflectedEntityCache.AnimatorSpeedParameterHash != -1)
            {
                reflectedEntityCache.Animator.SetFloat(reflectedEntityCache.AnimatorSpeedParameterHash, new Vector3(doubleToFloat(entityState.velX), doubleToFloat(entityState.velZ), doubleToFloat(entityState.velY)).magnitude);
            }
        }


        reflectedEntityCache.ReflectedEntity.LifeformState      = entityState.lifeformState;
        reflectedEntityCache.ReflectedEntity.DamageState        = entityState.DamageState;
        reflectedEntityCache.ReflectedEntity.ForceType          = entityState.forceType;
        reflectedEntityCache.ReflectedEntity.PrimaryWeaponState = entityState.primaryWeaponState;
        if (null != reflectedEntityCache.SelectedDevice)
        {
            reflectedEntityCache.SelectedDevice.SetCurrentWeaponState(entityState.primaryWeaponState);
        }

        if (joined && ReflectedEntityJoined != null)
        {
            ReflectedEntityJoined(reflectedEntityCache.ReflectedEntity);
        }
    }