Exemple #1
0
        /// <summary>
        ///
        /// </summary>
        /// <param name="fxPlayback"></param>
        public void UpdateRenderState(FXPlayback fxPlayback, ModelManager modelManager)
        {
            if (sfxDirty)
            {
                sfxDirty = false;

                FXInstance?.Kill();
                FXInstance = null;

                if (sfx > 0)
                {
                    var fxe = new FXEvent(sfx, ID, Position, LinearVelocity, Rotation);
                    FXInstance = fxPlayback.RunFX(fxe, true);
                }
            }

            if (modelDirty)
            {
                modelDirty = false;

                ModelInstance?.Kill();
                ModelInstance = null;

                if (model > 0)
                {
                    ModelInstance = modelManager.AddModel(model, this);
                }
            }
        }
        public FXEventDetailsPage(FXEvent fxEvent)
        {
            Title   = fxEvent.Title;
            Padding = new Thickness(20);

            Grid grid = new Grid()
            {
                ColumnDefinitions = new ColumnDefinitionCollection()
                {
                    new ColumnDefinition()
                    {
                        Width = new GridLength(1, GridUnitType.Star)
                    },
                    new ColumnDefinition()
                    {
                        Width = new GridLength(2, GridUnitType.Star)
                    }
                },
                RowDefinitions = new RowDefinitionCollection()
                {
                    new RowDefinition(),
                    new RowDefinition(),
                    new RowDefinition(),
                    new RowDefinition(),
                    new RowDefinition(),
                    new RowDefinition(),
                    new RowDefinition(),
                    new RowDefinition(),
                }
            };

            grid.Children.Add(new Label()
            {
                Text = "Currency", FontAttributes = FontAttributes.Bold, VerticalTextAlignment = TextAlignment.Center
            });
            grid.Children.Add(new Label()
            {
                Text = fxEvent.Currency.ToString(), VerticalTextAlignment = TextAlignment.Center
            }, 1, 0);

            grid.Children.Add(new Label()
            {
                Text = "Impact", FontAttributes = FontAttributes.Bold, VerticalTextAlignment = TextAlignment.Center
            }, 0, 1);
            grid.Children.Add(new Label()
            {
                Text = fxEvent.Level.ToString(), VerticalTextAlignment = TextAlignment.Center
            }, 1, 1);

            grid.Children.Add(new Label()
            {
                Text = "Time", FontAttributes = FontAttributes.Bold, VerticalTextAlignment = TextAlignment.Center
            }, 0, 2);
            grid.Children.Add(new Label()
            {
                Text = $"{fxEvent.Timestamp:dd/MM/yy HH:mm zzz}", VerticalTextAlignment = TextAlignment.Center
            }, 1, 2);
Exemple #3
0
        public async Task <FXEvent> GetFXEventById(string id)
        {
            try
            {
                if (string.IsNullOrEmpty(id))
                {
                    throw new ArgumentNullException(nameof(id));
                }

                if (detailedFXEvents.ContainsKey(id) && detailedFXEvents[id] != null)
                {
                    return(detailedFXEvents[id]);
                }
                else
                {
                    CancellationTokenSource cts = new CancellationTokenSource();
                    cts.CancelAfter(TimeSpan.FromMinutes(1));

                    FXEvent fxEvent = await fxEventsConnector.GetById(id, cts.Token);

                    if (fxEvent != null)
                    {
                        detailedFXEvents[id] = fxEvent;
                    }

                    return(fxEvent);
                }
            }
            catch (OperationCanceledException)
            {
                Debug.WriteLine("Not retrieving FX event's details: operation cancelled");
                return(null);
            }
            catch (ArgumentNullException ex)
            {
                Debug.WriteLine($"Not retrieving execution's details: missing or invalid parameter {ex.ParamName}");
                return(null);
            }
            catch (Exception e)
            {
                Debug.WriteLine($"Sync error: {e.Message}");
                return(null);
            }
        }
Exemple #4
0
 private static string FormatFXEvent(FXEvent fxEvent)
 {
     return($"{fxEvent.Timestamp:dd/MM/yy HH:mm:ss zzz} - {fxEvent.Currency} - {fxEvent.Title}");
 }
Exemple #5
0
 private static int CompareFXEventsTimestamps(FXEvent x, FXEvent y)
 {
     return(x.Timestamp.CompareTo(y.Timestamp));
 }
Exemple #6
0
        /// <summary>
        ///
        /// </summary>
        /// <param name="snapshotStream"></param>
        /// <param name="entities"></param>
        /// <param name="fxEvents"></param>
        public void Read <T> (Stream snapshotStream, ref T header, Dictionary <uint, Entity> entities, Action <FXEvent> runfx, Action <Entity> spawned, Action <uint> killed) where T : struct
        {
            using (var reader = new BinaryReader(snapshotStream)) {
                header = reader.Read <T>();

                int snapshotCounter       = reader.ReadInt32();
                int snapshotCountrerDelta = snapshotCounter - recvSnapshotCounter;
                recvSnapshotCounter = snapshotCounter;

                reader.ExpectFourCC("ENT0", "Bad snapshot");

                int length = reader.ReadInt32();
                var oldIDs = entities.Select(pair => pair.Key).ToArray();
                var newIDs = new uint[length];

                for (int i = 0; i < length; i++)
                {
                    uint id = reader.ReadUInt32();
                    newIDs[i] = id;

                    if (entities.ContainsKey(id))
                    {
                        //	Entity with given ID exists.
                        //	Just update internal state.
                        entities[id].Read(reader, 1);
                    }
                    else
                    {
                        //	Entity does not exist.
                        //	Create new one.
                        var ent = new Entity(id);

                        ent.Read(reader, 1);
                        entities.Add(id, ent);

                        //ConstructEntity( ent );
                        spawned?.Invoke(ent);
                    }
                }

                //	Kill all stale entities :
                var staleIDs = oldIDs.Except(newIDs);

                foreach (var id in staleIDs)
                {
                    killed?.Invoke(id);
                }


                //
                //	Run FX events
                //
                reader.ExpectFourCC("FXE0", "Bad snapshot");

                int count = reader.ReadInt32();

                for (int i = 0; i < count; i++)
                {
                    var fxe = new FXEvent();
                    fxe.Read(reader);

                    if (fxe.SendCount <= snapshotCountrerDelta)
                    {
                        runfx?.Invoke(fxe);
                    }
                }
            }
        }