private async Task OnTick() { foreach (MarkerEvent marker in markerEvents.Values.ToList()) { marker.Draw(); if (marker.EventAction != null && marker.EventAction.Type == EventActionType.PressControl) { marker.Check(); } } List <string> textToDelete = new List <string>(); foreach (KeyValuePair <string, Text3D> pair in texts) { string identifier = pair.Key; Text3D text = pair.Value; if (text.Entity == null || (text.Entity != null && text.EntityExist())) { text.Draw(); } else { //Entity doesn't exist, clearing... textToDelete.Add(identifier); } } foreach (string identifier in textToDelete) { texts.Remove(identifier); } foreach (AreaBase area in areas.Values.ToList()) { if (area.Debug) { area.Draw(); } } foreach (CustomPickup pick in pickups.ToList()) { if (pick.EventAction != null && pick.EventAction.Type == EventActionType.PressControl) { if (pick.Check()) { break; } } } }
private bool AddTextToMarkerEvent(string markerEventId, Text3D text) { try { if (markerEventId != null && markerEvents.ContainsKey(markerEventId)) { markerEvents[markerEventId].Text3D = text; return(true); } return(false); } catch (Exception Ex) { Debug.WriteLine("Error: " + Ex); return(false); } }
public void GetMapDirective(dynamic addCb) { addCb("createMarkerEvent", new Func <dynamic, dynamic, Action <dynamic> >((state, arg) => { return(new Action <dynamic>(arg2 => { bool created = CreateMarkerEvent( arg, (MarkerType)arg2.Type, new Vector3 { X = (float)arg2.Pos.X, Y = (float)arg2.Pos.Y, Z = (float)arg2.Pos.Z }, new Vector3 { X = (float)arg2.Scale.X, Y = (float)arg2.Scale.Y, Z = (float)arg2.Scale.Z }, Color.FromArgb(arg2.Color.R, arg2.Color.G, arg2.Color.B), (float)arg2.MaxDistance, IsPropertyExist(arg2, "BobUpAndDown") ? (bool)arg2.BobUpAndDown : false, IsPropertyExist(arg2, "FaceCamera") ? (bool)arg2.FaceCamera : false, IsPropertyExist(arg2, "Rotate") ? (bool)arg2.Rotate : false, IsPropertyExist(arg2, "Accessibility") ? (int)arg2.Accessibility : 0, IsPropertyExist(arg2, "OnEnter") ? arg2.OnEnter : null, IsPropertyExist(arg2, "OnExit") ? arg2.OnExit : null ); if (created) { state.add("markerId", arg); } })); }), new Action <dynamic>(state => { string markerId = state.markerId; if (markerId != null && markerEvents.ContainsKey(markerId)) { markerEvents.Remove(markerId); } })); addCb("addTextToMarkerEvent", new Func <dynamic, dynamic, Action <dynamic> >((state, arg) => { return(new Action <dynamic>(arg2 => { Text3D text = new Text3D { TextString = arg2.Text, Font = (CitizenFX.Core.UI.Font)arg2.Font, Color = Color.FromArgb(arg2.Color.R, arg2.Color.G, arg2.Color.B), Scale = new Vector2 { X = (float)arg2.Scale.X, Y = (float)arg2.Scale.Y }, Pos = new Vector3 { X = (float)arg2.Pos.X, Y = (float)arg2.Pos.Y, Z = (float)arg2.Pos.Z }, MaxDistance = (float)arg2.MaxDistance }; bool done = AddTextToMarkerEvent( arg, text ); if (done) { state.add("markerId", arg); } })); }), new Action <dynamic>(state => { string markerId = state.markerId; if (markerId != null && markerEvents.ContainsKey(markerId)) { markerEvents[markerId].Text3D = null; } })); addCb("addActionToMarkerEvent", new Func <dynamic, dynamic, Action <dynamic> >((state, arg) => { return(new Action <dynamic>(arg2 => { EventAction action = new EventAction { Type = (EventActionType)arg2.Action, Callback = arg2.CallBack }; if (IsPropertyExist(arg2, "HelpText")) { action.HelpText = arg2.HelpText; } if (IsPropertyExist(arg2, "Control")) { action.Control = (Control)arg2.Control; } if (IsPropertyExist(arg2, "Params")) { action.Params = arg2.Params; } bool done = AddActionToMarkerEvent( arg, action ); if (done) { state.add("markerId", arg); } })); }), new Action <dynamic>(state => { string markerId = state.markerId; if (markerId != null && markerEvents.ContainsKey(markerId)) { markerEvents[markerId].EventAction = null; } })); addCb("create3DText", new Func <dynamic, dynamic, Action <dynamic> >((state, arg) => { return(new Action <dynamic>(arg2 => { bool done = CreateText3D( arg, arg2.Text, (CitizenFX.Core.UI.Font)arg2.Font, Color.FromArgb(arg2.Color.R, arg2.Color.G, arg2.Color.B), new Vector2 { X = (float)arg2.Scale.X, Y = (float)arg2.Scale.Y }, new Vector3 { X = (float)arg2.Pos.X, Y = (float)arg2.Pos.Y, Z = (float)arg2.Pos.Z }, (float)arg2.MaxDistance ); if (done) { state.add("textId", arg); } })); }), new Action <dynamic>(state => { string textId = state.textId; if (textId != null && texts.ContainsKey(textId)) { texts.Remove(textId); } })); addCb("createArea", new Func <dynamic, dynamic, Action <dynamic> >((state, arg) => { return(new Action <dynamic>(arg2 => { bool done = CreateArea( arg, (AreaType)arg2.Type, arg2.Data, IsPropertyExist(arg2, "OnEnter") ? arg2.OnEnter : null, IsPropertyExist(arg2, "OnExit") ? arg2.OnExit : null, IsPropertyExist(arg2, "Params") ? arg2.Params : null, IsPropertyExist(arg2, "Debug") ? (bool)arg2.Debug : false ); if (done) { state.add("areaId", arg); } })); }), new Action <dynamic>(state => { string areaId = state.areaId; if (areaId != null && areas.ContainsKey(areaId)) { areas.Remove(areaId); } })); }