public void CloseComputation(AccumulatedAttributeTransform accumulatedResult) { applyAttributeUpdates(accumulatedResult); if (ComputedResult != null) { ComputedResult(this, accumulatedResult); } }
private void InvokeTopicHandlers(string topicName, AccumulatedAttributeTransform initialAccumulation) { foreach (TransformationAction transformAction in topicSubscriptions[topicName]) { ThreadPool.QueueUserWorkItem(action => transformAction.Execute(initialAccumulation) ); } }
private void applyAttributeUpdates(AccumulatedAttributeTransform accumulatedResult) { Entity changedEntity = accumulatedResult.Entity; var accumulatedTransformations = accumulatedResult.AccumulatedTransformations; foreach (KeyValuePair<string, Dictionary<string, object>> changedComponent in accumulatedTransformations) { foreach(KeyValuePair<string, object> changedAttribute in changedComponent.Value) { changedEntity[changedComponent.Key][changedAttribute.Key].Value = changedAttribute.Value; } } }
public void Execute(AccumulatedAttributeTransform accumulatedTransformations) { var transformationResult = TransformationFunction(accumulatedTransformations); if (HasNext) { next.Execute(transformationResult); } else { ServiceBus.CloseComputation(transformationResult); } }
private void applyAttributeUpdates(AccumulatedAttributeTransform accumulatedResult) { Entity changedEntity = accumulatedResult.Entity; var accumulatedTransformations = accumulatedResult.AccumulatedTransformations; foreach (KeyValuePair <string, Dictionary <string, object> > changedComponent in accumulatedTransformations) { foreach (KeyValuePair <string, object> changedAttribute in changedComponent.Value) { changedEntity[changedComponent.Key][changedAttribute.Key].Value = changedAttribute.Value; } } }
private void HandleTransformation(object sender, ProposeAttributeChangeEventArgs transform) { Dictionary <string, Dictionary <string, object> > initialAccumulation = new Dictionary <string, Dictionary <string, object> >(); Dictionary <string, object> initialAttributeUpdates = new Dictionary <string, object>(); initialAttributeUpdates.Add(transform.AttributeName, transform.Value); initialAccumulation.Add(transform.ComponentName, initialAttributeUpdates); AccumulatedAttributeTransform initialTransform = new AccumulatedAttributeTransform(transform.Entity, initialAccumulation); string topic = transform.ComponentName + "." + transform.AttributeName; if (topicSubscriptions.ContainsKey(topic) && topicSubscriptions[topic].Count > 0) { InvokeTopicHandlers(topic, initialTransform); } else { CloseComputation(initialTransform); } }
public static void CloseComputation(AccumulatedAttributeTransform accumulatedResult) { Instance.CloseComputation(accumulatedResult); }
private AccumulatedAttributeTransform InvokeSpin(AccumulatedAttributeTransform accumulatedTransforms) { var rotVelocity = (AxisAngle)accumulatedTransforms.CurrentAttributeValue("motion", "rotVelocity"); if (rotVelocity.angle != 0 && !(rotVelocity.axis.x == 0 && rotVelocity.axis.y == 0 && rotVelocity.axis.z == 0)) { lock (ongoingSpin) { if (!ongoingSpin.Contains(accumulatedTransforms.Entity)) ongoingSpin.Add(accumulatedTransforms.Entity); } } else { lock (ongoingSpin) { if (ongoingSpin.Contains(accumulatedTransforms.Entity)) ongoingSpin.Remove(accumulatedTransforms.Entity); } } return accumulatedTransforms; }
private AccumulatedAttributeTransform InvokeMotion(AccumulatedAttributeTransform accumulatedTransforms) { var velocity = (Vector)accumulatedTransforms.CurrentAttributeValue("motion", "velocity"); if(velocity.x != 0 || velocity.y != 0 || velocity.z != 0) { lock (ongoingMotion) { if (!ongoingMotion.Contains(accumulatedTransforms.Entity)) ongoingMotion.Add(accumulatedTransforms.Entity); } } else { lock (ongoingMotion) { if (ongoingMotion.Contains(accumulatedTransforms.Entity)) ongoingMotion.Remove(accumulatedTransforms.Entity); } } return accumulatedTransforms; }
/// <summary> /// Checks if position of entity has changed and sets y attribute to ground level if y and ground level /// are different /// </summary> /// <param name="accumulatedTransforms">Accumulated transformation that happened in the service chain</param> /// <returns>Accumulated changes with adaptions added by AvatarCollison</returns> internal AccumulatedAttributeTransform Transform(AccumulatedAttributeTransform accumulatedTransforms) { if (!accumulatedTransforms.Entity.ContainsComponent("avatar")) return accumulatedTransforms; Vector entityPosition = (Vector)accumulatedTransforms.CurrentAttributeValue("location", "position"); Vector adaptedPosition = new Vector (entityPosition.x, (float)accumulatedTransforms.Entity["avatarCollision"]["groundLevel"].Value, entityPosition.z); accumulatedTransforms.AddAttributeTransformation("location", "position", adaptedPosition); return accumulatedTransforms; }
public void CloseComputation(AccumulatedAttributeTransform accumulatedResult) { applyAttributeUpdates(accumulatedResult); if (ComputedResult != null) ComputedResult(this, accumulatedResult); }
private void HandleTransformation(object sender, ProposeAttributeChangeEventArgs transform) { Dictionary<string, Dictionary<string, object>> initialAccumulation = new Dictionary<string, Dictionary<string, object>>(); Dictionary<string, object> initialAttributeUpdates = new Dictionary<string, object>(); initialAttributeUpdates.Add(transform.AttributeName, transform.Value); initialAccumulation.Add(transform.ComponentName, initialAttributeUpdates); AccumulatedAttributeTransform initialTransform = new AccumulatedAttributeTransform(transform.Entity, initialAccumulation); string topic = transform.ComponentName + "." + transform.AttributeName; if (topicSubscriptions.ContainsKey(topic) && topicSubscriptions[topic].Count > 0) { InvokeTopicHandlers(topic, initialTransform); } else { CloseComputation(initialTransform); } }