/// <summary> /// Initialize the Service /// </summary> /// <param name="context">The executable context</param> public override void Init(IExecutableContext context) { KeyTopicDictionary = new Dictionary <Key, string>(); handler = new InputHandler(); base.Init(context); }
/// <summary> /// Initialize the World (Read in Entities and Components) /// </summary> public void Init(IExecutableContext context) { mLogger.Info(string.Format("Initializing world '{0}'", mData.Name)); mContext = context; mContext.World = this; //The world is given a list of Entities in it, we need to parse through it and create Entity objects foreach (EntityData entityData in mData.Entities) { try { mLogger.Info(string.Format("Creating Entity '{0}' of Type '{1}' and Assembly '{2}'", entityData.Name, entityData.Type, entityData.Assembly)); Type entityType = Type.GetType(entityData.Assembly); Object[] objArray = { entityData }; IEntity entity = (IEntity)Activator.CreateInstance(entityType, objArray); AddEntity(entity); entity.Init(mContext); } catch (Exception e) { mLogger.Error(string.Format("Failed to create entity '{0}'", entityData.Name), e); } } mContext.MessageRouter.RegisterTopic(mData.Name, this); mContext.MessageRouter.RegisterTopic(MessagingConstants.ACTIVE_WORLD, this); mLogger.Info(string.Format("Done initializing world '{0}'", mData.Name)); }
/// <summary> /// Initialize the Entity /// </summary> /// <param name="Context">The executable context of the entity</param> public virtual void Init(IExecutableContext Context) { mLogger.Info(string.Format("Initializing Entity '{0}'", mName)); mContext = Context; mContext.Entity = this; //Read in the entities components here string path = Context.ConfigManager.FindEntityType(mData.Type); EntityTypeData typeData = DataContractFactory.DeserializeObject <EntityTypeData>(path); foreach (string entry in typeData.Components) { try { mLogger.Info(string.Format("Creating component '{0}' for entity '{1}'", entry, mName)); Type componentType = Type.GetType(entry); Object[] objArray = {}; IComponent component = (IComponent)Activator.CreateInstance(componentType, objArray); component.Init(mContext, mData.DataSet); mComponents.Add(component); } catch (Exception e) { mLogger.Error(string.Format("Failed to create component '{0}' for entity '{1}", entry, mName), e); } } mContext.MessageRouter.RegisterTopic(mName, this); mLogger.Info(string.Format("Finished Initializing Entity '{0}'", mName)); }
/// <inheritdoc /> public void Execute(IEnumerable <TExtension> extensions, IExecutableContext executableContext) { Ensure.ArgumentNotNull(executableContext, "executableContext"); Console.WriteLine("::: Executing executable {0}", executableContext.Name); this.decoratedExecutable.Execute(extensions, executableContext); Console.WriteLine("::: Executed executable {0}", executableContext.Name); }
public ActionOnExtensionWithInitializerExecutableTest() { this.executableContext = A.Fake <IExecutableContext>(); this.context = new object(); this.testee = new ActionOnExtensionWithInitializerExecutable <object, ICustomExtension>( () => this.CountAccessToContext(), (x, i) => x.SomeMethod(i), (aware, ctx) => { this.interceptedBehaviorAware = aware; }); }
/// <inheritdoc /> public void Execute(ISyntax <TExtension> syntax, IEnumerable <TExtension> extensions, IExecutionContext executionContext) { Ensure.ArgumentNotNull(syntax, "syntax"); Ensure.ArgumentNotNull(executionContext, "executionContext"); foreach (IExecutable <TExtension> executable in syntax) { IExecutableContext executableContext = executionContext.CreateExecutableContext(executable); executable.Execute(extensions, executableContext); } }
/// <summary> /// Initialize the component /// </summary> /// <param name="Context">The context</param> /// <param name="data">entity data</param> public override void Init(IExecutableContext Context, DataSet data = null) { base.Init(Context, data); Pos = new Vector3d(); mvpMatrix = Matrix4d.Identity; Pos.X = double.Parse(data[BaseConstants.POS_X]); Pos.Y = double.Parse(data[BaseConstants.POS_Y]); Pos.Z = double.Parse(data[BaseConstants.POS_Z]); mContext.MessageRouter.RegisterTopic(MessagingConstants.CAMERA_MATRIX_TOPIC, this); }
/// <inheritdoc /> public void Execute(IEnumerable <TExtension> extensions, IExecutableContext executableContext) { Ensure.ArgumentNotNull(executableContext, "executableContext"); foreach (IBehavior <TExtension> behavior in this.behaviors) { executableContext.CreateBehaviorContext(behavior); behavior.Behave(extensions); } this.action(); }
/// <summary> /// Creates an instance of a World from a config file /// </summary> /// <param name="path">the path to the File defining the world to create</param> /// <returns>an IWorld object</returns> public static IWorld CreateWorld(string worldName, IExecutableContext context) { string path = context.ConfigManager.FindWorld(worldName); WorldData worldData = DataContractFactory.DeserializeObject <WorldData>(path); Type worldType = Type.GetType(worldData.Assembly); Object[] objArray = { worldData }; IWorld world = (IWorld)Activator.CreateInstance(worldType, objArray); world.Init(context); return(world); }
/// <summary> /// Initialize the Component /// </summary> /// <param name="Context">The component's executable context</param> /// <param name="data">Optional data for the Component</param> public virtual void Init(IExecutableContext Context, DataSet data = null) { if (Context == null) { throw new NullReferenceException("Context"); } if (data == null) { mDataSet = new DataSet(); } else { mDataSet = data; } mContext = Context; mName = string.Format("{0}@{1}", this.GetType().Name, mContext.Entity.Name); mLogger = LoggerFactory.CreateLogger(mName); mEntity = mContext.Entity; mContext.MessageRouter.RegisterTopic(mName, this); }
/// <inheritdoc /> public void Execute(ISyntax <IComplexExtension> syntax, IEnumerable <IComplexExtension> extensions, IExecutionContext executionContext) { Ensure.ArgumentNotNull(syntax, "syntax"); foreach (IExecutable <IComplexExtension> executable in syntax) { using (var worker = new Task( state => { var e = (IExecutable <IComplexExtension>)state; IExecutableContext executableContext = executionContext.CreateExecutableContext(e); e.Execute(extensions, executableContext); }, executable)) { worker.Start(); worker.Wait(); } } }
/// <inheritdoc /> public void Execute(IEnumerable <TExtension> extensions, IExecutableContext executableContext) { Ensure.ArgumentNotNull(extensions, "extensions"); Ensure.ArgumentNotNull(executableContext, "executableContext"); TContext context = this.initializer(); this.contextInterceptor(this, context); foreach (IBehavior <TExtension> behavior in this.behaviors) { executableContext.CreateBehaviorContext(behavior); behavior.Behave(extensions); } foreach (TExtension extension in extensions) { this.action(extension, context); } }
/// <summary> /// Initialize the Camera. Needs the following from the Dataset: /// CamPosX - The camera's X position /// CamPosY - The camera's Y position /// CamPosZ - The camera's Z position /// CamTargetX - The camera target's X position /// CamTargetY - The camera target's Y position /// CamTargetZ - The camera target's Z position /// CamUpX - The camera up vector's X component /// CamUpY - The camera up vector's Y component /// CamUpZ - The camera up vector's Z component /// CamNear - the Z value of the Near Plane /// CamFar - the Z value of the FarPlane /// CamType - {PERSPECTIVE | ORTHOGRAPHIC} /// If CameraType = PERSPECTIVE /// CamFOV - The field of view of the camera /// CamAspect - The aspect ratio of the camera /// If CameraType = ORTHOGRAHIC /// CamWidth - The width of the camera field /// CamHeight - the Height of the camera field /// </summary> /// <param name="Context"></param> /// <param name="data"></param> public override void Init(IExecutableContext Context, DataSet data = null) { base.Init(Context, data); //Get the Position Pos.X = double.Parse(data[ComponentConstants.CAMERA_POS_X]); Pos.Y = double.Parse(data[ComponentConstants.CAMERA_POS_Y]); Pos.Z = double.Parse(data[ComponentConstants.CAMERA_POS_Z]); //Get the Target vector Target.X = double.Parse(data[ComponentConstants.CAMERA_TARGET_X]); Target.Z = double.Parse(data[ComponentConstants.CAMERA_TARGET_Z]); Target.Y = double.Parse(data[ComponentConstants.CAMERA_TARGET_Y]); //Get the Up vector Up.X = double.Parse(data[ComponentConstants.CAMERA_UP_X]); Up.Y = double.Parse(data[ComponentConstants.CAMERA_UP_Y]); Up.Z = double.Parse(data[ComponentConstants.CAMERA_UP_Z]); //Get the near and far planes zNear = double.Parse(data[ComponentConstants.CAMERA_ZNEAR]); zFar = double.Parse(data[ComponentConstants.CAMERA_ZFAR]); //determine the type of camera the user selected cameraType = (ComponentConstants.CAM_TYPES)Enum.Parse(typeof(ComponentConstants.CAM_TYPES), data[ComponentConstants.CAMERA_TYPE]); if (cameraType == ComponentConstants.CAM_TYPES.ORTHOGRAPHIC) { cameraWidth = double.Parse(data[ComponentConstants.CAMERA_WIDTH]); cameraHeight = double.Parse(data[ComponentConstants.CAMERA_HEIGHT]); } else { cameraFOV = double.Parse(data[ComponentConstants.CAMERA_FOV]); cameraAspect = double.Parse(data[ComponentConstants.CAMERA_ASPECT]); } viewPerspectiveMatrix = generateMatrix(Pos, Up, Target, cameraType, zNear, zFar, cameraWidth, cameraHeight, cameraAspect, cameraFOV); isDirty = true; }
/// <summary> /// Initialize the Service /// </summary> /// <param name="context">the service's ExecutableContext</param> public virtual void Init(IExecutableContext context) { mLogger.Info(string.Format("Creating Service {0}", mName)); mContext = context; }
/// <summary> /// Initialize the Service. Register for all needed Topics /// </summary> /// <param name="context">the services executable context</param> public override void Init(IExecutableContext context) { base.Init(context); mContext.MessageRouter.RegisterTopic(MessagingConstants.SHADER_SERVICE_TOPIC, this); }
public ExecutableTest() { this.executableContext = A.Fake <IExecutableContext>(); }
public IBehaviorBuilder Executable(string name, string description) { this.currentExecutableContext = this.currentExecutionContext.CreateExecutableContext(new Describable(name, description)); return this; }
public IBehaviorBuilder Executable(string name, string description) { this.currentExecutableContext = this.currentExecutionContext.CreateExecutableContext(new Describable(name, description)); return(this); }
/// <summary> /// Initialize the Engine. Creates the World and all the Services /// </summary> /// <param name="PathToConfig">Path to the Config directory</param> /// <param name="world"></param> public void Init(string PathToConfig, string world) { mContext = new BaseExecutableContext(PathToConfig); string pathToEngineConfigFile = mContext.ConfigManager.FindEngineConfig(); EngineConfigDataContract engineConfig = DataContractFactory.DeserializeObject <EngineConfigDataContract>(pathToEngineConfigFile); //Initialize the Logger Type loggerType = Type.GetType(engineConfig.LoggerType); if (loggerType == null) { throw new NullReferenceException("loggerType"); } LoggerFactory.SetLoggerType(loggerType); LoggerFactory.SetLoggingLevel(engineConfig.LogLevel); mLogger = LoggerFactory.CreateLogger("ENGINE"); mLogger.Info(string.Format("Initializing engine with world: {0} and config path: {1}", world, PathToConfig)); foreach (string assembly in engineConfig.ServicesList) { try { mLogger.Debug(string.Format("Attempting to create service {0}", assembly)); Type assemblyType = Type.GetType(assembly); if (assembly == null) { throw new Exception(string.Format("Service assembly {0} not found!", assembly)); } IService service = (IService)Activator.CreateInstance(Type.GetType(assembly)); mServicesList.Add(service); mLogger.Debug(string.Format("Successfuly created service {0}", assembly)); } catch (Exception e) { mLogger.Warn("Error creating Service", e); } } foreach (IService service in mServicesList) { try { mLogger.Debug(string.Format("Initializing service {0}", service.ToString())); service.Init(mContext); mLogger.Debug(string.Format("Successfully initialized service {0}", service.ToString())); } catch (Exception e) { mLogger.Warn("Error initializing Service", e); } } try { mLogger.Debug(string.Format("Attempting to create world {0}", world)); mWorld = WorldFactory.CreateWorld(world, mContext); mLogger.Debug(string.Format("Successfully created world {0}", world)); } catch (Exception e) { mLogger.Warn("Error initializing world", e); } mLogger.Info("Done initializing Engine"); }
public ActionExecutableTest() { this.executableContext = A.Fake <IExecutableContext>(); this.testee = new ActionExecutable <IExtension>(() => this.SetWasExecuted()); }
/// <summary> /// Initialize the World /// </summary> /// <param name="context">unused</param> public void Init(IExecutableContext context) { //Do nothing }
public ActionOnExtensionExecutableTest() { this.executableContext = A.Fake <IExecutableContext>(); this.testee = new ActionOnExtensionExecutable <ICustomExtension>(x => x.Dispose()); }
/// <summary> /// Initialize the Thread /// </summary> /// <param name="context"></param> public virtual void Init(IExecutableContext context) { mContext = context; mLogger = LoggerFactory.CreateLogger(this.GetType().Name); }
/// <summary> /// Initialize the service /// </summary> /// <param name="context">The executable context of the service</param> public override void Init(IExecutableContext context) { base.Init(context); }
/// <summary> /// Initialize the null entity /// </summary> /// <param name="Context">unused</param> public void Init(IExecutableContext Context) { }