public IEnumerable<ICommand> Preprocess(IActor actor, ICommand command) { if (!(command is IDWMCommand)) { yield return command; yield break; } var cmd = command as IDWMCommand; if (cmd.DifWheelMovement == null) { yield return command; yield break; } cmd.DifWheelMovement = new DifWheelMovement { LeftRotatingVelocity=cmd.DifWheelMovement.LeftRotatingVelocity*Multiplier, RightRotatingVelocity = cmd.DifWheelMovement.RightRotatingVelocity*Multiplier, Duration=cmd.DifWheelMovement.Duration, }; yield return cmd as ICommand; }
public PWUnit(IActor actor) { actor = Compatibility.Check<IPWRobot>(this, actor); // actor.World.Clocks.AddTrigger(new TimerTrigger(UpdateSpeed, TriggerFrequency)); adding trigger example rules = Compatibility.Check<IPWRules>(this, actor.Rules); }
public void Use(IActor targetActor) { //get variables IChunk chunk = this.Chunk; int x = this.Position.X; int y = this.Position.Y; int z = this.Position.Z; IActor actor = targetActor; //permission check, is the Player allowed to open the door? Chunk castedChunk = chunk as Chunk; string nationName = castedChunk.NationOwner; if ((!string.IsNullOrEmpty(nationName) && (actor.Nation != nationName))) return; //get the index for the Block array from the given x, y and z int index = chunk.GetBlockIndex(x, y, z); //get the specific Block data by its index ushort currentBlock = chunk.Blocks[index]; //get baseDoorID (reason why the doorID has to be a multiple of 10, for this script to properly work) int baseDoorID = ((int)currentBlock / 10) * 10; int offset = (int)currentBlock - baseDoorID; //call ToggleDoors function with variables ToggleDoor(chunk, baseDoorID, offset, x, y, z); }
public void interact(IActor actor) { if (canInteract(actor)) { ICommand command = new PickUpCommand(actor, item); command.execute(); } }
private void Explore(IActor actor, ILocation location) { //If an exit location is found, print the path and continue to find another exit if (location is ExitLocation) { if ((location as ExitLocation).ExitPreviouslyFound) return; (location as ExitLocation).ExitPreviouslyFound = true; NumberOfExits++; TripRecorder.Instance.PrintTrip(); terrain.PathToExit(); terrain.TerrainPrinter(terrain.StartLocation); str= String.Format("{0} Number Of Exit(s) Found!", NumberOfExits); Console.WriteLine(str); Console.WriteLine("*****************************************************************"); return; } //When the location is dead end if (location.ListOfNeighbors().Count == 0) { (location as MarkedLocation).MarkRed(); return; } //traverses to all the neigbors of a location foreach (var neighbor in location.ListOfNeighbors()) { location.MoveToNeighbor(actor, neighbor.Key); Explore(actor, neighbor.Value); } //The location will be marked red when it backtracks (location as MarkedLocation).MarkRed(); }
public void Use(IActor targetActor) { //get variables IChunk chunk = this.Chunk; int x = this.Position.X; int y = this.Position.Y; int z = this.Position.Z; IActor actor = targetActor; //permission check, is the Player allowed to open the door? Chunk castedChunk = chunk as Chunk; string nationName = castedChunk.NationOwner; if ((!string.IsNullOrEmpty(nationName) && (actor.Nation != nationName))) return; //get the index for the Block array from the given x, y and z int index = chunk.GetBlockIndex(x, y, z); //get the specific Block data by its index ushort currentBlock = chunk.Blocks[index]; if (IsOdd((int)currentBlock)) { chunk.ChangeBlock((ushort)(currentBlock - 1), x, y, z); } else { chunk.ChangeBlock((ushort)(currentBlock + 1), x, y, z); } }
/// <summary> /// Method that get called when a player want to enter a location also notifies to trip /// recorder that player entered location /// </summary> /// <param name="actor"></param> /// <returns></returns> public virtual bool EnterLocation(IActor actor) { actor.CurrentLocation = this; //Console.WriteLine("cell {0} entered by actor {1}", LocationName, actor.Name); Recorder.EnterLocation(actor.Name, LocationName); return true; }
public IModifier CreateModifier(IActor target, IActor source, IStat stat, int amount) { IModifier modifier = this.CreateModifier(target, source, amount); modifier.SetAffectedStat(stat); return modifier; }
public IOutputPlug[] GetOutputPlugs(IActor actor, IInputPlug plug) { List<IOutputPlug> tempList = new List<IOutputPlug>(); foreach (IOutputPlug p in outputPlugs) { // Cases to add. if (plug != null) { if (p.IsCompatible(plug)) tempList.Add(p); } else if (actor != null) { foreach (IInputPlug ip in actor.GetInputPlugs(null, null)) { if (p.IsCompatible(ip)) { tempList.Add(p); break; } } } else { tempList.Add(p); } } return tempList.ToArray(); }
// Use this for initialization void Start() { m_Grid = GameObject.FindGameObjectWithTag("Grid").GetComponent<Grid>(); m_target = m_Grid.GetRandGrid(); m_actor = GetComponent<IActor>(); m_path = new List<GridNode>(); }
/// <summary> /// player can enter a location /// </summary> /// <param name="actor"></param> /// <returns></returns> public override bool EnterLocation(IActor actor) { if (base.EnterLocation(actor)) { actor.CurrentLocation = this; return true; } else return false; }
public SimpleSyncComponent(IActor actor, IConnectionManager connectionManager) { _actor = actor; _connectionManager = connectionManager; _connectionManager.ConnectionInitialized += new EventHandler<EventArgs<IConnection>>(_connectionManager_ConnectionInitialized); _connectionManager.ConnectionTerminated += new EventHandler<EventArgs<IConnection>>(_connectionManager_ConnectionTerminated); }
public PositionComponent(IActor actor, IServerSyncComponent syncComponent) : base(actor) { _syncComponent = syncComponent; _syncComponent.ConnectionEnteringRelevantSet += new EventHandler<Core.Utility.EventArgs<Core.Networking.IConnection>>(_syncComponent_ConnectionEnteringRelevantSet); sendPosition(); }
public PositionComponent(IActor actor, IClientSyncComponent syncComponent, ILogger logger) : base(actor) { _logger = logger; _syncComponent = syncComponent; _syncComponent.MessageReceived += new EventHandler<Core.Utility.EventArgs<Tuple<Core.Networking.IConnection, Core.Networking.Messages.ActorMessage>>>(_syncComponent_MessageReceived); }
public IModifier CreateModifier(IActor target, IActor source, IStat stat, int amount, int duration) { IModifier modifier = this.CreateModifier(target, source, stat, amount); modifier.SetAffectDuration(duration); return modifier; }
public void AddActor(int actorId, IActor actor) { lock (_lock) { _actors.Add(actorId, actor); } }
/// <summary> /// explores the terrain /// </summary> public void Explore(Terrain terrain, IActor actor) { this.terrain = terrain; //the Explore starts from the start location in the terrain Explore(terrain.StartLocation, actor); Console.WriteLine("**** There are no more Exits ************"); }
public static ConfigFileActor FindConfigFile(IActor actor) { if (actor.Environment != null) { IActor currentActor = actor.Environment.Owner; if (currentActor != null) { while (!(currentActor is ConfigFileActor)) { currentActor = currentActor.Environment.Owner; if (currentActor == null) break; } if (currentActor != null) { if (currentActor is ConfigFileActor) { return (ConfigFileActor)currentActor; } } } } return null; }
public override void ExitLocation(IActor player) { DeadEnd(_location); Exit(); _location.EnterLocation(player); _update = new UpdateRequest(player, _location, _check); }
public static Region GetRegionFromPosition(IActor actor) { Console.WriteLine(string.Format("posX {0} - posY {1}",actor.posX,actor.posY)); int indexX = GetIndex(actor.posX); int indexY = GetIndex(actor.posY); return Region.arrRegion[indexX, indexY]; }
private static DynamicMethod BuildDispatchingMethod(IActor handler, IStructSizeCounter counter, Func<Type, int> messageIdGetter) { var handlerType = handler.GetType(); var handleMethods = ActorRegistry.GetHandleMethods(handlerType) .ToDictionary(m => messageIdGetter(m.GetParameters()[1].ParameterType.GetElementType()), m => m) .OrderBy(kvp => kvp.Key) .ToArray(); var dm = new DynamicMethod("ReadMessagesFor_" + handlerType.Namespace.Replace(".", "_") + handlerType.Name, typeof (void), new[] {typeof (MessageReader), typeof (int), typeof (ByteChunk)}, handlerType.Assembly.Modules.First(), true); var actorField = typeof (MessageReader).GetFields(BindingFlags.NonPublic | BindingFlags.Instance) .Single(fi => fi.FieldType == typeof (IActor)); var il = dm.GetILGenerator(); // push handler il.Emit(OpCodes.Ldarg_0); il.Emit(OpCodes.Ldfld, actorField); il.Emit(OpCodes.Castclass, handlerType); var endLbl = il.DefineLabel(); // dispatch foreach (var method in handleMethods) { var lbl = il.DefineLabel(); il.Emit(OpCodes.Ldarg_1); // messageTypeId il.Emit(OpCodes.Ldc_I4, method.Key); il.Emit(OpCodes.Ceq); il.Emit(OpCodes.Brfalse_S, lbl); // push envelope il.Emit(OpCodes.Ldarg_2); il.Emit(OpCodes.Ldfld, typeof (ByteChunk).GetField("Pointer")); //var messageType = method.Value.GetParameters()[1].ParameterType.GetElementType(); //il.Emit(OpCodes.Ldc_I4, (int)Marshal.OffsetOf(messageType, Envelope.FieldName)); //il.Emit(OpCodes.Add); // push message il.Emit(OpCodes.Ldarg_2); il.Emit(OpCodes.Ldfld, typeof (ByteChunk).GetField("Pointer")); il.EmitCall(OpCodes.Callvirt, method.Value, null); il.Emit(OpCodes.Br_S, endLbl); il.MarkLabel(lbl); } // nothing was called, pop il.Emit(OpCodes.Pop); // end label il.MarkLabel(endLbl); il.Emit(OpCodes.Ret); return dm; }
// ================================================================================ // unity methods // -------------------------------------------------------------------------------- void Awake() { _transform = transform; _self = _transform.GetInterface<IActor>(); if (_self == null && _transform.parent != null) _self = _transform.parent.GetInterface<IActor>(); }
public ActorMethodInvocationHandler(IActor root, object wrapped, MethodCaller methodCaller, ProxyFactory proxyFactory, Type returnType, MethodInfo targetMethod) : base(proxyFactory, methodCaller, wrapped) { m_Root = root; m_MethodCaller = methodCaller; m_ProxyFactory = proxyFactory; m_TargetMethod = targetMethod; }
/// <summary> /// Returns empty BusinessRuleCollection indicating that the actor has permissions to save the current object. /// </summary> /// <param name="actor">Actor whose data-access permissions are to be checked.</param> /// <returns>Collection of permissions (broken rules) that the actor has failed.</returns> /// <remarks>Override in derived classes to add security checks.</remarks> public virtual BusinessRuleCollection GrantSave(IActor actor) { BusinessRuleCollection rules = new BusinessRuleCollection(); BusinessRule rule = new BusinessRule("Entity_GrantSave", actor.HasPermission(Permissions.ProductModelProductDescription_Update), "Update denied on this object.", 1); rules.Add(rule); return rules; }
/// <summary> /// Returns empty BusinessRuleCollection indicating that the actor has permissions to fetch the data requested. /// </summary> /// <param name="actor">Actor whose data-access permissions are to be checked.</param> /// <returns>Collection of permissions (broken rules) that the actor has failed.</returns> /// <remarks>Override in derived classes to add security checks.</remarks> public virtual BusinessRuleCollection GrantFetch(IActor actor) { BusinessRuleCollection rules = new BusinessRuleCollection(); BusinessRule rule = new BusinessRule("Entity_GrantFetch", actor.HasPermission(Permissions.Address_Read), "Fetch denied on this object.", 1); rules.Add(rule); return rules; }
/// <summary> /// Returns empty BusinessRuleCollection indicating that the actor has permissions to delete the data requested. /// </summary> /// <param name="actor">Actor whose data-access permissions are to be checked.</param> /// <returns>Collection of permissions (broken rules) that the actor has failed.</returns> /// <remarks>Override in derived classes to add security checks.</remarks> public virtual BusinessRuleCollection GrantDelete(IActor actor) { BusinessRuleCollection rules = new BusinessRuleCollection(); BusinessRule rule = new BusinessRule("Entity_GrantDelete", actor.HasPermission(Permissions.CustomerAddress_Delete), "Delete denied on this object.", 1); rules.Add(rule); return rules; }
//enters location only if exitpreviouslyfound is false public override bool EnterLocation(IActor actor) { Location.EnterLocation(actor); actor.CurrentLocation = this;//set the current location if (!ExitPreviouslyFound) return Location.EnterLocation(actor); return false; }
//to exit a location, the actor has to move to another location (enters another location) public override bool MoveToNeighbor(IActor actor, Directions direction) { var neighbor = this.ListOfNeighbors()[direction]; if (neighbor == null) return false; return Location.MoveToNeighbor(actor, direction); }
public void Update(IActor Actor) { if (state != null) { state.Execute(Actor); } if (globalState != null) { globalState.Execute(Actor); } }
/// <summary> /// Returns empty BusinessRuleCollection indicating that the actor has permissions to save the current object. /// </summary> /// <param name="actor">Actor whose data-access permissions are to be checked.</param> /// <returns>Collection of permissions (broken rules) that the actor has failed.</returns> /// <remarks>Override in derived classes to add security checks.</remarks> public virtual BusinessRuleCollection GrantSave(IActor actor) { BusinessRuleCollection rules = new BusinessRuleCollection(); BusinessRule rule = new BusinessRule("Entity_GrantSave", actor.HasPermission(Permissions.SalesOrderDetail_Update), "Update denied on this object.", 1); rules.Add(rule); return rules; }
protected override void OnInitialize(IActor owner) { _transform = Owner.GetGameObject().transform; }
protected override ILogicStrategy GetLogicStrategy(IActor actor) { return(new LogicTreeStrategy(actor, LogicStateTreePatterns.Monster)); }
public void OnEquip(IActor user) { this.BehaviorDefinition?.OnEquip?.Invoke(new ItemInteractionArgs(this, user)); }
/// <summary> /// Returns the actor instance, as an <see cref="IGivenActor"/>, in order to perform precondition actions. /// </summary> /// <param name="actor">The actor.</param> public IGivenActor Given(IActor actor) => StepComposer.Given(actor);
public EnemyActor(IActor actor) { Actor = actor; }
internal void DoStat(IActor sender) { CheckArg.Actor(sender); sender.SendMessage("Host entries " + _uri2Actor.Count.ToString(CultureInfo.InvariantCulture)); }
public static void Unregister(IActor anActor) { CheckArg.Actor(anActor); GetInstance().SendMessage((Action <IActor>)GetInstance().DoUnregister, anActor); }
public WADUnit(IActor actor) { this.actor = Compatibility.Check <IWADRobot>(this, actor); rules = Compatibility.Check <IWADRules>(this, this.actor.Rules); }
internal void DoRegister(IActor anActor) { CheckArg.Actor(anActor); _uri2Actor[anActor.Tag.Key()] = anActor; }
public virtual void Impersonate(IActor actor) { this.Impersonate(actor, ImpersonationMode.Approximately); }
/// <summary> /// Clicks the web element. /// Use browser actions instead of direct click (due to IE). /// </summary> /// <param name="actor">The screenplay actor.</param> /// <param name="driver">The WebDriver.</param> public override void PerformAs(IActor actor, IWebDriver driver) => actor.Calls(JavaScript.On(Locator, "arguments[0].click();"));
/// <summary> /// Returns the actor instance, as an <see cref="IThenActor"/>, in order to perform actions which asserts that /// the desired outcome has come about. /// </summary> /// <param name="actor">The actor.</param> public IThenActor Then(IActor actor) => StepComposer.Then(actor);
/// <summary> /// Returns the actor instance, as an <see cref="IWhenActor"/>, in order to perform actions which exercise the /// application. /// </summary> /// <param name="actor">The actor.</param> public IWhenActor When(IActor actor) => StepComposer.When(actor);
private void Awake() { _actor = GetComponent <IActor>(); }
public void Register <T>(IActor actor) where T : class, IActorMessage { this.Register <T>((msg) => actor.OnMessageRecieved <T>(msg)); }
public bool WithinReachOf(IActor actor) { return(_collisionDescriptor.Collides(actor)); }
private void CheckForAndRunExceptionHandler(Exception ex, IActor actor, IActorMessage msg) { List <Exception> exceptions = new List <Exception>(); if (null != ex) { exceptions.Add(ex); } try { Exception foundEx = null; Func <Exception, IActor, IActorMessage, IActorInvocation, IActor> handler; handler = this.FindExceptionHandler(_exceptionTypeToHandler, ex, actor, msg, out foundEx); if (null != foundEx && foundEx != ex) { exceptions.Add(foundEx); } if (null == handler) { return; } IActorInvocation invoker = null; IActor newActor = handler.Invoke(foundEx, actor, msg, invoker); if (null == newActor || newActor == actor) { return; } _messageTypeToActor.TryUpdate(msg.GetType(), newActor, actor); } catch (NotImplementedException ne) { exceptions.Add(ne); Console.Error.WriteLine(ne); System.Diagnostics.Debug.Assert(false); throw; } catch (Exception exp) { exceptions.Add(exp); Console.Error.WriteLine(exp); //TODO fail hard!!! System.Diagnostics.Debug.Assert(false); } finally { if (null != msg.Status && exceptions.Any()) { try { msg.Status.SetException(exceptions); } catch (System.InvalidOperationException) { // The underlying System.Threading.Tasks.Task`1 is already in one of the three final // states: System.Threading.Tasks.TaskStatus.RanToCompletion, System.Threading.Tasks.TaskStatus.Faulted, // or System.Threading.Tasks.TaskStatus.Canceled. } } } }
protected override void OnInitialize(IActor owner) { }
public PlayerActor(IActor actor) { Actor = actor; }
public ActorPathFindingContext(IActor actor, ISectorMap map, IGraphNode targetNode) { Actor = actor ?? throw new ArgumentNullException(nameof(actor)); _map = map ?? throw new ArgumentNullException(nameof(map)); TargetNode = targetNode ?? throw new ArgumentNullException(nameof(targetNode)); }
internal bool OwnsActor(IActor actor) { return(FindActor(actor.Id) != null); }
public SarnadoAction(IActor actor, Status status, IEnumerable <IActionApproveOption> actionApproveOption) { Actor = actor ?? throw new ArgumentNullException(nameof(actor)); Status = status; _actionApprover = new ActionApprovers.Entities.ActionApprover(actionApproveOption); }
public bool ActorInMap(IActor <IActorDescriptor> actor) { return(_actors.ContainsKey(actor.UniqueID)); }
public FsmBehaviors <TState, TEvent> AddRule(TState startState, Func <TEvent, bool> aCondition, Action <TEvent> anAction, TState reachedState, IActor traceActor) { if (!fBehaviorSet) { _current = startState; BecomeBehavior(new Behavior <IFuture <TState> >(GetCurrentState)); fBehaviorSet = true; } AddBehavior(new FsmBehavior <TState, TEvent> ( startState, reachedState, anAction, aCondition, traceActor )); return(this); }
public LoopAction(IActor conditionActor, Func <bool> condition, ActionChain body) { Body = body; Condition = condition; body.AddAction(conditionActor, this); }
internal void DoUnregister(IActor anActor) { CheckArg.Actor(anActor); _uri2Actor.Remove(anActor.Tag.Key()); }
/// <summary> /// Waits until the question's answer value meets the condition. /// If the expected condition is not met within the time limit, then an exception is thrown. /// </summary> /// <param name="actor">The actor.</param> /// <returns></returns> public void PerformAs(IActor actor) => WaitForValue(actor);
public virtual void Initialize(IActor actor) { Actor = Compatibility.Check <TActor>(this, actor); }
public VisualEventInfo(IActor actor, EventArgs eventArgs, string eventName) { Actor = actor ?? throw new ArgumentNullException(nameof(actor)); EventArgs = eventArgs ?? throw new ArgumentNullException(nameof(eventArgs)); EventName = eventName ?? throw new ArgumentNullException(nameof(eventName)); }
public void AttackTarget(IActor actor) { throw new NotImplementedException(); }