/// <summary> /// To be called when a user performs an illegal action on this computer. /// </summary> public void PerformIllegalAction() { #pragma warning disable CS4014 // Because this call is not awaited, execution of the current method continues before the call is completed if (this != World.World.GetInstance().Player.PlayerComp) { ActiveTracer.GetInstance().StartTrace(TraceTime); // TODO: base tracetime on computer difficulty or something } #pragma warning restore CS4014 // Because this call is not awaited, execution of the current method continues before the call is completed OnIllegalAction?.Invoke(this, new IllegalActionEventArgs(World.World.GetInstance().CurrentGameTime)); }
private static ViewDefinition GetView(MshExpressionFactory expressionFactory, TypeInfoDataBase db, Type mainControlType, Collection <string> typeNames, string viewName) { TypeMatch match = new TypeMatch(expressionFactory, db, typeNames); foreach (ViewDefinition definition in db.viewDefinitionsSection.viewDefinitionList) { if ((definition == null) || (mainControlType != definition.mainControl.GetType())) { ActiveTracer.WriteLine("NOT MATCH {0} NAME: {1}", new object[] { ControlBase.GetControlShapeName(definition.mainControl), (definition != null) ? definition.name : string.Empty }); } else if (IsOutOfBandView(definition)) { ActiveTracer.WriteLine("NOT MATCH OutOfBand {0} NAME: {1}", new object[] { ControlBase.GetControlShapeName(definition.mainControl), definition.name }); } else if (definition.appliesTo == null) { ActiveTracer.WriteLine("NOT MATCH {0} NAME: {1} No applicable types", new object[] { ControlBase.GetControlShapeName(definition.mainControl), definition.name }); } else if ((viewName != null) && !string.Equals(definition.name, viewName, StringComparison.OrdinalIgnoreCase)) { ActiveTracer.WriteLine("NOT MATCH {0} NAME: {1}", new object[] { ControlBase.GetControlShapeName(definition.mainControl), definition.name }); } else { try { TypeMatch.SetTracer(ActiveTracer); if (match.PerfectMatch(new TypeMatchItem(definition, definition.appliesTo))) { TraceHelper(definition, true); return(definition); } } finally { TypeMatch.ResetTracer(); } TraceHelper(definition, false); } } ViewDefinition bestMatch = GetBestMatch(match); if (bestMatch == null) { Collection <string> collection = Deserializer.MaskDeserializationPrefix(typeNames); if (collection != null) { bestMatch = GetView(expressionFactory, db, mainControlType, collection, viewName); } } return(bestMatch); }
/// <summary> /// Disconnect the player from this computer /// </summary> public void Disconnect(bool forced = false) { World.World.GetInstance().Player.ConnectedComp = World.World.GetInstance().Player.PlayerComp; IsPlayerConnected = false; if (ActiveTracer.GetInstance().IsActive) { ActiveTracer.GetInstance().StopTrace(); } OnDisconnected?.Invoke(this, new DisconnectedEventArgs(World.World.GetInstance().CurrentGameTime)); if (forced) { Game.Terminal.WriteLine("Connection closed by remote host"); MusicManager.GetInstance().ChangeSong("gameBgm", 0.5f); } }
private static void TraceHelper(ViewDefinition vd, bool isMatched) { if ((ActiveTracer.Options & PSTraceSourceOptions.WriteLine) != PSTraceSourceOptions.None) { foreach (TypeOrGroupReference reference in vd.appliesTo.referenceList) { StringBuilder builder = new StringBuilder(); TypeReference reference2 = reference as TypeReference; builder.Append(isMatched ? "MATCH FOUND" : "NOT MATCH"); if (reference2 != null) { builder.AppendFormat(CultureInfo.InvariantCulture, " {0} NAME: {1} TYPE: {2}", new object[] { ControlBase.GetControlShapeName(vd.mainControl), vd.name, reference2.name }); } else { TypeGroupReference reference3 = reference as TypeGroupReference; builder.AppendFormat(CultureInfo.InvariantCulture, " {0} NAME: {1} GROUP: {2}", new object[] { ControlBase.GetControlShapeName(vd.mainControl), vd.name, reference3.name }); } ActiveTracer.WriteLine(builder.ToString(), new object[0]); } } }
public override void Update(GameTime gameTime) { _text = $"Trace: {ActiveTracer.GetInstance().GetTracePercentage()}"; base.Update(gameTime); }
public override void Initialize() { base.Initialize(); _font = FontManager.GetFont("FontM"); _text = $"Trace: {ActiveTracer.GetInstance().GetTracePercentage()}"; }