public GameObjectGameComponent(GameObjectSettings settings, IWorldCoreGameComponentContext worldContext) : base(settings, worldContext) { _hostEndpointsRegistry = new EndpointsRegistry(Logger); var platformEndpointsList = EndpointDescriber.GetEndpointsInfoList(settings.HostListener); _hostEndpointsRegistry.AddEndpointsRange(platformEndpointsList); }
public override void Awake() { _logger.Log("Begin"); var platformListener = new TstPlatformHostListener(); var settings = new GameObjectSettings(); _id = "#Gun 1"; settings.Id = _id; settings.InstanceId = 2; settings.HostFile = Path.Combine(Directory.GetCurrentDirectory(), @"Source\Npcs\Barrel\Barrel.sobj"); settings.HostListener = platformListener; _gameObject = WorldFactory.WorldInstance.GetGameObject(settings); _logger.Log("End"); }
public void Run() { _logger.Log("Begin"); var complexContext = TstEngineContextHelper.CreateAndInitContext(); var context = complexContext.EngineContext; var worldContext = complexContext.WorldContext; //var dictionary = context.Dictionary; var platformListener = new TstPlatformHostListener(); var npcSettings = new HumanoidNPCSettings(); npcSettings.Id = "#020ED339-6313-459A-900D-92F809CEBDC5"; //npcSettings.HostFile = Path.Combine(Directory.GetCurrentDirectory(), @"Source\Hosts\PeaceKeeper\PeaceKeeper.host"); npcSettings.LogicFile = Path.Combine(Directory.GetCurrentDirectory(), @"Source\Apps\PeaceKeeper\PeaceKeeper.sobj"); npcSettings.HostListener = platformListener; npcSettings.PlatformSupport = new PlatformSupportCLIStub(); _logger.Log($"npcSettings = {npcSettings}"); var tstBaseManualControllingGameComponent = new TstBaseManualControllingGameComponent(npcSettings, worldContext); var methodName = NameHelper.CreateName("go"); var command = new Command(); command.Name = methodName; command.ParamsDict = new Dictionary <StrongIdentifierValue, Value>(); var param1Value = new WaypointValue(25, 36, context); var param1Name = NameHelper.CreateName("to"); command.ParamsDict[param1Name] = param1Value; var param2Value = new NumberValue(12.4); var param2Name = NameHelper.CreateName("speed"); command.ParamsDict[param2Name] = param2Value; _logger.Log($"command = {command}"); //ExecuteCommand(tstBaseManualControllingGameComponent, command); methodName = NameHelper.CreateName("shoot"); command = new Command(); command.Name = methodName; ExecuteCommand(tstBaseManualControllingGameComponent, command); var gameObjectSettings = new GameObjectSettings(); gameObjectSettings.Id = "#120ED339-6313-459A-900D-92F809CEBDC5"; var gunPlatformHostListener = new TstGunPlatformHostListener(); gameObjectSettings.HostListener = gunPlatformHostListener; _logger.Log($"gameObjectSettings = {gameObjectSettings}"); var gameObject = new GameObjectImplementation(gameObjectSettings, worldContext); tstBaseManualControllingGameComponent.AddToManualControl(gameObject, 12); methodName = NameHelper.CreateName("shoot"); command = new Command(); command.Name = methodName; ExecuteCommand(tstBaseManualControllingGameComponent, command); var manualControlledObjectsList = tstBaseManualControllingGameComponent.GetManualControlledObjects(); //_logger.Log($"manualControlledObjectsList = {manualControlledObjectsList.WriteListToString()}"); _logger.Log($"manualControlledObjectsList.Count = {manualControlledObjectsList.Count}"); tstBaseManualControllingGameComponent.RemoveFromManualControl(gameObject); manualControlledObjectsList = tstBaseManualControllingGameComponent.GetManualControlledObjects(); _logger.Log($"manualControlledObjectsList.Count = {manualControlledObjectsList.Count}"); _logger.Log("End"); }
public override void Init(int nGPU) { int[] avatarIds = Owner.GameCtrl.GetAvatarIds(); if (avatarIds.Length == 0) { MyLog.ERROR.WriteLine("No avatar found in map!"); return; } // Setup controllers int myAvatarId = avatarIds[0]; Owner.AvatarCtrl = Owner.GameCtrl.GetAvatarController(myAvatarId); // Setup render requests GameObjectSettings gameObjects = new GameObjectSettings(RenderRequestGameObject.TileLayers | RenderRequestGameObject.ObjectLayers) { Use3D = Owner.Use3D }; EffectSettings? effects = null; PostprocessingSettings?post = null; // Overlays are not used for now (no BrainSim property to switch them on) because there is a separate renderrequest for inventory Tool // Setup effects RenderRequestEffect enabledEffects = RenderRequestEffect.None; if (Owner.EnableDayAndNightCycle) { enabledEffects |= RenderRequestEffect.DayNight; } if (Owner.DrawLights) { enabledEffects |= RenderRequestEffect.Lights; } if (Owner.DrawSmoke) { enabledEffects |= RenderRequestEffect.Smoke; } if (enabledEffects != RenderRequestEffect.None) { effects = new EffectSettings(enabledEffects) { SmokeIntensityCoefficient = Owner.SmokeIntensity, SmokeScaleCoefficient = Owner.SmokeScale, SmokeTransformationSpeedCoefficient = Owner.SmokeTransformationSpeed, } } ; // Setup postprocessing RenderRequestPostprocessing enabledPostprocessing = RenderRequestPostprocessing.None; if (Owner.DrawNoise) { enabledPostprocessing |= RenderRequestPostprocessing.Noise; } if (enabledPostprocessing != RenderRequestPostprocessing.None) { post = new PostprocessingSettings(enabledPostprocessing) { NoiseIntensityCoefficient = Owner.NoiseIntensity, } } ; // Get and setup RRs Owner.FovRR = ObtainRR <IFovAvatarRR>(Owner.VisualFov, Owner.VisualFovDepth, myAvatarId, rr => { rr.Size = new SizeF(Owner.FoVSize, Owner.FoVSize); rr.Resolution = new Size(Owner.FoVResWidth, Owner.FoVResHeight); rr.MultisampleLevel = Owner.FoVMultisampleLevel; rr.RotateMap = Owner.RotateMap; rr.GameObjects = gameObjects; rr.Effects = effects ?? new EffectSettings(RenderRequestEffect.None); rr.Postprocessing = post ?? new PostprocessingSettings(RenderRequestPostprocessing.None); }); Owner.FofRR = ObtainRR <IFofAvatarRR>(Owner.VisualFof, Owner.VisualFofDepth, myAvatarId, rr => { rr.FovAvatarRenderRequest = Owner.FovRR; rr.Size = new SizeF(Owner.FoFSize, Owner.FoFSize); rr.Resolution = new Size(Owner.FoFResWidth, Owner.FoFResHeight); rr.MultisampleLevel = Owner.FoFMultisampleLevel; rr.RotateMap = Owner.RotateMap; rr.GameObjects = gameObjects; rr.Effects = effects ?? new EffectSettings(RenderRequestEffect.None); rr.Postprocessing = post ?? new PostprocessingSettings(RenderRequestPostprocessing.None); }); Owner.FreeRR = ObtainRR <IFreeMapRR>(Owner.VisualFree, Owner.VisualFreeDepth, rr => { rr.Size = new SizeF(Owner.Width, Owner.Height); rr.Resolution = new Size(Owner.ResolutionWidth, Owner.ResolutionHeight); rr.MultisampleLevel = Owner.FreeViewMultisampleLevel; rr.SetPositionCenter(Owner.CenterX, Owner.CenterY); rr.GameObjects = gameObjects; // no noise, smoke, postprocessing or overlays -- this view is for the researcher }); Owner.ToolRR = ObtainRR <IToolAvatarRR>(Owner.VisualTool, null, myAvatarId, rr => { rr.Size = new SizeF(Owner.ToolSize, Owner.ToolSize); rr.Resolution = new Size(Owner.ToolResWidth, Owner.ToolResHeight); rr.Overlay = new OverlaySettings(RenderRequestOverlay.InventoryTool) { ToolBackground = Owner.ToolBackgroundType, }; // None of the other settings have any effect }); Owner.WorldInitialized(this, EventArgs.Empty); }
public GameObjectImplementation(GameObjectSettings settings) { _settings = settings; }
public GameObjectImplementation(GameObjectSettings settings, IWorldCoreGameComponentContext context) { _gameComponent = new GameObjectGameComponent(settings, context); }