Stream(ArrayList data, Entity entity)
      {
         data.Add(new Snoop.Data.ClassSeparator(typeof(Entity)));
         data.Add(new Snoop.Data.Bool("Is Valid", entity.IsValid()));
         data.Add(new Snoop.Data.Bool("Read Access Granted", entity.ReadAccessGranted()));
         data.Add(new Snoop.Data.Bool("Write Access Granted", entity.WriteAccessGranted()));
         data.Add(new Snoop.Data.Object("Schema", entity.Schema));
         Schema schema = entity.Schema;
         if (schema != null)
         {
            foreach (Field field in schema.ListFields())
            {
               data.Add(new Snoop.Data.Object("Field", new ExtensibleStorageField(entity, field)));
            }
         }

      }
        /// <summary>
        /// Updates the entity in the pipe fitting and accessory pressure drop UI data. 
        /// </summary>
        /// <param name="data">
        /// The pipe fitting and accessory pressure drop UI data.
        /// </param>
        /// <param name="dbServerId">
        /// The corresponding DB server Id of the UI server.
        /// </param>
        /// <param name="schemaField">
        /// The schema field to be updated.
        /// </param>
        /// <param name="newValue">
        /// The new value to be set to the schema field.
        /// </param>
        /// <returns>
        /// True if the entity in the UI data is updated, false otherwise.
        /// </returns>
        public static bool UpdateEntities(PipeFittingAndAccessoryPressureDropUIData data, Guid dbServerId, string schemaField, string newValue)
        {
            bool isUpdated = false;

             ExternalService service = ExternalServiceRegistry.GetService(ExternalServices.BuiltInExternalServices.PipeFittingAndAccessoryPressureDropService);
             if (service == null)
            return isUpdated;

             IPipeFittingAndAccessoryPressureDropServer dbServer = service.GetServer(dbServerId) as IPipeFittingAndAccessoryPressureDropServer;
             if (dbServer == null)
             {
            return isUpdated;
             }

             Schema schema = dbServer.GetDataSchema();
             if (schema == null)
            return isUpdated;

             Field field = schema.GetField(schemaField);
             if (field == null)
            return isUpdated;

             Entity entity = new Entity(schema);
             entity.Set<string>(field, newValue);

             IList<PipeFittingAndAccessoryPressureDropUIDataItem> uiDataItems = data.GetUIDataItems();
             foreach (PipeFittingAndAccessoryPressureDropUIDataItem uiDataItem in uiDataItems)
             {

            Entity oldEntity = uiDataItem.GetEntity();
            if (oldEntity == null && entity == null)
            {
               continue;
            }

            if (oldEntity == null || entity == null)
            {
               uiDataItem.SetEntity(entity);
               isUpdated = true;
               continue;
            }

            if ((!oldEntity.IsValid()) && (!entity.IsValid()))
            {
               continue;
            }

            if ((!oldEntity.IsValid()) || (!entity.IsValid()))
            {
               uiDataItem.SetEntity(entity);
               isUpdated = true;
               continue;
            }

            string oldValue = oldEntity.Get<string>(schemaField);
            if (oldValue != newValue)
            {
               uiDataItem.SetEntity(entity);
               isUpdated = true;
               continue;
            }
             }

             return isUpdated;
        }
Beispiel #3
0
        public static SerializableObjective GetSerObjectiveFromEntity(Entity ent, Vector3 pos)
        {
            {
                var threshold = 1.5f;
                foreach (SerializablePickupObjective objective in CurrentMission.Objectives.OfType<SerializablePickupObjective>())
                {
                    if (objective.GetObject() == null || !objective.GetObject().IsValid()) continue;
                    if ((objective.GetObject().Position - pos).Length() > threshold) continue;
                    return objective;
                }

                foreach (var mark in CurrentMission.Objectives.OfType<SerializableMarker>())
                {
                    if ((mark.Position - pos).Length() > threshold) continue;
                    return mark;
                }
            }

            if (ent == null || !ent.IsValid()) return null;

            var type = GetEntityType(ent);
            
            switch (type)
            {
                case EntityType.ObjectiveActor:
                    return CurrentMission.Objectives.First(o =>
                    {
                        var act = o as SerializableActorObjective;
                        return act?.GetPed()?.Handle.Value == ent.Handle.Value;
                    });
                case EntityType.ObjectiveVehicle:
                    return CurrentMission.Objectives.First(o =>
                    {
                        var act = o as SerializableVehicleObjective;
                        return act?.GetVehicle()?.Handle.Value == ent.Handle.Value;
                    });
                case EntityType.ObjectivePickup:
                    return CurrentMission.Objectives.First(o =>
                    {
                        var d = o as SerializablePickupObjective;
                        return d?.GetObject()?.Handle.Value == ent.Handle.Value;
                    });
            }


            return null;
        }
Beispiel #4
0
        private void CheckForIntersection(Entity ent)
        {
            if (MarkerData.RepresentedBy != null && MarkerData.RepresentedBy.IsValid() && ent != null && ent.IsValid())
            {
                var type = GetEntityType(ent);
                if (MarkerData.RepresentedBy is Vehicle && type == EntityType.NormalVehicle && !IsPlacingObjective)
                {
                    MarkerData.RepresentedBy.Opacity = 0f;
                    MarkerData.HeadingOffset = 45f;
                    RingData.Color = Color.Red;
                    _hoveringEntity = ent;
                }

                if (MarkerData.RepresentedBy is Vehicle && IsPlacingObjective && type == EntityType.ObjectiveVehicle)
                {
                    MarkerData.RepresentedBy.Opacity = 0f;
                    MarkerData.HeadingOffset = 45f;
                    RingData.Color = Color.Red;
                    _hoveringEntity = ent;
                }

                else if (MarkerData.RepresentedBy is Ped && ent.IsPed() && !PlayerSpawnOpen && !IsPlacingObjective && type == EntityType.NormalActor)
                {
                    MarkerData.RepresentedBy.Opacity = 0f;
                    MarkerData.HeadingOffset = 45f;
                    RingData.Color = Color.Red;
                    _hoveringEntity = ent;
                }

                else if (MarkerData.RepresentedBy is Ped && ent.IsPed() && PlayerSpawnOpen && type == EntityType.Spawnpoint)
                {
                    MarkerData.RepresentedBy.Opacity = 0f;
                    MarkerData.HeadingOffset = 45f;
                    RingData.Color = Color.Red;
                    _hoveringEntity = ent;
                }

                else if (MarkerData.RepresentedBy is Ped && ent.IsPed() && IsPlacingObjective && type == EntityType.ObjectiveActor)
                {
                    MarkerData.RepresentedBy.Opacity = 0f;
                    MarkerData.HeadingOffset = 45f;
                    RingData.Color = Color.Red;
                    _hoveringEntity = ent;
                }

                else if (MarkerData.RepresentedBy is Ped && ent.IsVehicle() &&
                    type == EntityType.NormalVehicle &&
                    ((Vehicle)ent).GetFreeSeatIndex().HasValue)
                {
                    RingData.Color = Color.GreenYellow;
                    _hoveringEntity = ent;
                }

                else if (MarkerData.RepresentedBy is Object && ent.IsObject() &&
                    type == EntityType.NormalObject && PlacedWeaponHash == 0)
                {
                    MarkerData.RepresentedBy.Opacity = 0f;
                    MarkerData.HeadingOffset = 45f;
                    RingData.Color = Color.Red;
                    _hoveringEntity = ent;
                }
            }
            else if (_hoveringEntity != null && _hoveringEntity.IsValid() && MarkerData.RepresentedBy != null && MarkerData.RepresentedBy.IsValid() && PlacedWeaponHash == 0)
            {
                MarkerData.RepresentedBy.Opacity = 1f;
                MarkerData.HeadingOffset = 0f;
                RingData.Color = Color.MediumPurple;
                _hoveringEntity = null;
            }
        }
Beispiel #5
0
        public static SerializableObject GetSerObjectFromEntity(Entity ent, Vector3 pos)
        {
            {
                var threshold = 1.5f;
                foreach (SerializablePickup pickup in CurrentMission.Pickups)
                {
                    if (pickup.GetEntity() == null || !pickup.GetEntity().IsValid()) continue;
                    if ((pickup.GetEntity().Position - pos).Length() > threshold) continue;
                    return pickup;
                }
            }

            if (ent == null || !ent.IsValid()) return null;

            var type = GetEntityType(ent);
            switch (type)
            {
                case EntityType.NormalActor:
                    return CurrentMission.Actors.First(o => o?.GetEntity()?.Handle.Value == ent.Handle.Value);
                case EntityType.Spawnpoint:
                    return CurrentMission.Spawnpoints.First(o => o?.GetEntity()?.Handle.Value == ent.Handle.Value);
                case EntityType.NormalVehicle:
                    return CurrentMission.Vehicles.First(o => o?.GetEntity()?.Handle.Value == ent.Handle.Value);
                case EntityType.NormalObject:
                    return CurrentMission.Objects.First(o => o?.GetEntity()?.Handle.Value == ent.Handle.Value);
                case EntityType.NormalPickup:
                    return CurrentMission.Pickups.First(o => o?.GetEntity()?.Handle.Value == ent.Handle.Value);
            }
            return null;
        }
Beispiel #6
0
        public static EntityType GetEntityType(Entity ent)
        {
            if (ent == null || !ent.IsValid()) return EntityType.None;

            if (ent.IsPed())
            {
                if(CurrentMission.Actors.Any(o => o?.GetEntity()?.Handle.Value == ent.Handle.Value))
                    return EntityType.NormalActor;
                if(CurrentMission.Spawnpoints.Any(o => o?.GetEntity()?.Handle.Value == ent.Handle.Value))
                    return EntityType.Spawnpoint;
                if (CurrentMission.Objectives.Any(o =>
                {
                    var act = o as SerializableActorObjective;
                    return act?.GetPed()?.Handle.Value == ent.Handle.Value;
                })) 
                    return EntityType.ObjectiveActor;
            }
            else if (ent.IsVehicle())
            {
                if(CurrentMission.Vehicles.Any(o => o?.GetEntity()?.Handle.Value == ent.Handle.Value))
                    return EntityType.NormalVehicle;
                if (CurrentMission.Objectives.Any(o =>
                {
                    var act = o as SerializableVehicleObjective;
                    return act?.GetVehicle()?.Handle.Value == ent.Handle.Value;
                }))
                    return EntityType.ObjectiveVehicle;
            }
            else if (ent.IsObject())
            {
                if(CurrentMission.Objects.Any(o => o?.GetEntity()?.Handle.Value == ent.Handle.Value))
                    return EntityType.NormalObject;
                if(CurrentMission.Pickups.Any(o => o?.GetEntity()?.Handle.Value == ent.Handle.Value))
                    return EntityType.NormalPickup;
                if(CurrentMission.Objectives.Any(o =>
                {
                    var d = o as SerializablePickupObjective;
                    return d?.GetObject()?.Handle.Value == ent.Handle.Value;
                }))
                    return EntityType.ObjectivePickup;
            }
            return EntityType.None;
        }
Beispiel #7
0
 private void CheckForProperty(Entity ent)
 {
     if (ent != null && ent.IsValid())
     {
         var type = GetEntityType(ent);
         if (type != EntityType.None)
         {
             RingData.Color = Color.Yellow;
             _hoveringEntity = ent;
         }
     }
     else if (_hoveringEntity != null && _hoveringEntity.IsValid())
     {
         var type = GetEntityType(_hoveringEntity);
         if (type == EntityType.NormalPickup || type == EntityType.ObjectivePickup || type == EntityType.ObjectiveMarker) return;
         RingData.Color = Color.Gray;
         _hoveringEntity = null;
     }
 }
        public void Process(Vector3 markerPos, Entity crossent)
        {
            CreateWaypointMenu.ProcessControl();
            CreateWaypointMenu.Draw();

            _waypointPropertiesMenu.ProcessControl();
            _waypointPropertiesMenu.Draw();

            if (_children != null)
                foreach (var menu in _children)
                {
                    menu.ProcessControl();
                    menu.Draw();
                }

            if (!IsInEditor) return;
            RepresentCurrentWaypoints();
            DrawInstructionalButtonsScaleform();
            if (CreateWaypointMenu.Visible && Util.IsDisabledControlJustPressed(GameControl.CellphoneCancel))
            {
                
                return;
            }

            if (crossent != null && crossent.IsValid() && crossent.IsVehicle())
            {
                var item = CreateWaypointMenu.MenuItems.FirstOrDefault(i => i.Text.EndsWith("EnterVehicle"));
                if (item != null)
                    item.Enabled = true;
            }
            else
            {
                var item = CreateWaypointMenu.MenuItems.FirstOrDefault(i => i.Text.EndsWith("EnterVehicle"));
                if (item != null)
                    item.Enabled = false;
            }

            var wpy = CheckForIntersection(markerPos);
            if (wpy != null && CreateWaypointMenu.Visible)
            {
                if (Util.IsDisabledControlJustPressed(GameControl.Attack))
                {
                    RebuildWaypointPropertiesMenu(wpy);
                    CreateWaypointMenu.Visible = false;
                    _waypointPropertiesMenu.Visible = true;
                    return;
                }

                if (Util.IsDisabledControlJustPressed(GameControl.CreatorDelete))
                {
                    if (_mainPed != null)
                        _mainPed.Waypoints.Remove(wpy);
                    else _mainActorObjective.Waypoints.Remove(wpy);
                    return;
                }
            }

            if (CreateWaypointMenu.Visible)
            {
                DrawCrosshair(markerPos);
                //if (Game.IsControlJustPressed(0, GameControl.Attack))
                if (Util.IsDisabledControlJustPressed(GameControl.Attack))
                {
                    CreateWaypoint(_placingWaypointType, markerPos + new Vector3(0,0,1), crossent);
                    return;
                }
            }
        }
        public SerializableWaypoint CreateWaypoint(WaypointTypes type, Vector3 pos, Entity ent)
        {
            var wpy = new SerializableWaypoint();
            wpy.Type = type;
            wpy.Position = pos;
            wpy.Duration = 0;
            wpy.VehicleSpeed = 20f;
            wpy.DrivingStyle = 0xC00AB;

            switch (type)
            {
                case WaypointTypes.EnterVehicle:
                    if (ent != null && ent.IsValid() && ent.IsVehicle())
                    {
                        wpy.VehicleTargetModel = ent.Model.Hash;
                    }
                    break;
            }


            if(_mainPed != null)
                _mainPed.Waypoints.Add(wpy);
            else
                _mainActorObjective.Waypoints.Add(wpy);

            return wpy;
        }