public InterpretingScriptExecutor(ScenarioTag scenario) { this.executionStates = new ExecutionState[scenario.ScriptMethods.Length]; this.interpreter = new ScriptIterativeInterpreter(scenario, this); for (int i = 0; i < scenario.ScriptMethods.Length; i++) { var method = scenario.ScriptMethods[i]; var initialStatus = method.Lifecycle switch { Lifecycle.Startup => ScriptStatus.RunOnce, Lifecycle.Dormant => ScriptStatus.Terminated, Lifecycle.Continuous => ScriptStatus.RunContinuous, Lifecycle.Static => ScriptStatus.Terminated, Lifecycle.Stub => ScriptStatus.Terminated, Lifecycle.CommandScript => ScriptStatus.Terminated, _ => throw new NotImplementedException() }; this.interpreter.CreateState(method.SyntaxNodeIndex, out var interpreterState); var state = new ExecutionState { MethodId = i, Status = initialStatus, InterpreterState = interpreterState, Description = method.Description }; executionStates[i] = state; } }
public static TriggerVolume FromScenarioTriggerVolume(ScenarioTag tag, ScenarioTag.TriggerVolume tvDefinition) { var ent = new TriggerVolume(); ent.FriendlyName = tvDefinition.Description; var orient = GetOrientation(tvDefinition.Orientation, tvDefinition.OrientationAxis); var xform = new TransformComponent(ent, tvDefinition.Position, orient); var renderModel = ModelFactory.Cuboid(Vector3.Zero, tvDefinition.Size, new Vector4(1f, 1f, 0f, 0.5f)); renderModel.Flags = ModelFlags.IsTransparent; renderModel.RenderLayer = RenderLayers.Scripting; var wireframeRenderModel = ModelFactory.Cuboid(Vector3.Zero, tvDefinition.Size, new Vector4(1f, 1f, 0f, 1f)); wireframeRenderModel.Flags = ModelFlags.Wireframe; wireframeRenderModel.RenderLayer = RenderLayers.Scripting; ent.SetComponents(xform, TriggerGeometryComponent.Cuboid(ent, xform, tvDefinition.Size, tvDefinition.Description), new RenderModelComponent(ent, renderModel), new RenderModelComponent(ent, wireframeRenderModel)); return(ent); Quaternion GetOrientation(Vector3 angle, Vector3 axis) { //BUG? The Z value of the angle vector is not used here, and is present in ~5 triggers in the game var a = MathF.Atan2(angle.Y, angle.X); return(Quaternion.CreateFromAxisAngle(axis, a)); } }
public void CreateDataInitializer(ScenarioTag scnr) { var scenarioParam = Identifier("scenarioTag"); var sceneParam = Identifier("scene"); var statements = new List <StatementSyntax>(); statements.Add(ExpressionStatement(AssignmentExpression(SyntaxKind.SimpleAssignmentExpression, MemberAccessExpression(SyntaxKind.SimpleMemberAccessExpression, ThisExpression(), IdentifierName(nameof(ScenarioScriptBase.Scenario))), IdentifierName(scenarioParam)))); for (int i = 0; i < scnr.WellKnownItems.Length; i++) { var externalRef = scnr.WellKnownItems[i]; if (externalRef.ItemType != ScenarioTag.WellKnownVarType.Undef && externalRef.Index != ushort.MaxValue) { var varType = SyntaxUtil.WellKnownTypeSyntax(externalRef.ItemType); statements.Add(CreateWellKnownAssignment(varType, externalRef.Identifier, i)); } } AddSquadInitialization(statements, scnr); this.methods.Add( MethodDeclaration( PredefinedType(Token(SyntaxKind.VoidKeyword)), nameof(ScenarioScriptBase.InitializeData)) .AddParameterListParameters( Parameter(scenarioParam).WithType(ParseTypeName(nameof(ScenarioTag))), Parameter(sceneParam).WithType(ParseTypeName(nameof(Scene)))) .AddModifiers(Token(SyntaxKind.PublicKeyword), Token(SyntaxKind.OverrideKeyword)) .WithBody(Block(statements))); }
public ScriptCSharpGenerator(ScenarioTag scnr, MemberNameRepository nameRepo, string[] refrences = null, AttributeSyntax[] classAttributes = null) { this.scenario = scnr; this.nameRepo = nameRepo; var scenarioParts = scnr.Name.Split('\\', StringSplitOptions.RemoveEmptyEntries); var ns = "OpenH2.Scripts.Generated" + string.Join(".", scenarioParts.Take(2)); this.nsDecl = NamespaceDeclaration(ParseName(ns)); var classModifiers = SyntaxTokenList.Create(Token(SyntaxKind.PublicKeyword)) .Add(Token(SyntaxKind.PartialKeyword)); this.classDecl = ClassDeclaration("scnr_" + scenarioParts.Last()) .WithModifiers(classModifiers); if (classAttributes != null && classAttributes.Any()) { var classAttrs = List <AttributeListSyntax>() .Add(AttributeList(SeparatedList(classAttributes))); this.classDecl = this.classDecl.WithAttributeLists(classAttrs); } }
public override void InitializeData(ScenarioTag scenarioTag, Scene scene) { this.Scenario = scenarioTag; crate_left00 = new ScenarioEntity <IBloc>(0, scenarioTag.WellKnownItems[0]); crate_right00 = new ScenarioEntity <IBloc>(1, scenarioTag.WellKnownItems[1]); crate_left01 = new ScenarioEntity <IBloc>(2, scenarioTag.WellKnownItems[2]); crate_left02 = new ScenarioEntity <IBloc>(3, scenarioTag.WellKnownItems[3]); crate_left03 = new ScenarioEntity <IBloc>(4, scenarioTag.WellKnownItems[4]); crate_left04 = new ScenarioEntity <IBloc>(5, scenarioTag.WellKnownItems[5]); crate_left05 = new ScenarioEntity <IBloc>(6, scenarioTag.WellKnownItems[6]); crate_left06 = new ScenarioEntity <IBloc>(7, scenarioTag.WellKnownItems[7]); crate_left07 = new ScenarioEntity <IBloc>(8, scenarioTag.WellKnownItems[8]); crate_left08 = new ScenarioEntity <IBloc>(9, scenarioTag.WellKnownItems[9]); crate_left09 = new ScenarioEntity <IBloc>(10, scenarioTag.WellKnownItems[10]); crate_left10 = new ScenarioEntity <IBloc>(11, scenarioTag.WellKnownItems[11]); crate_left11 = new ScenarioEntity <IBloc>(12, scenarioTag.WellKnownItems[12]); crate_right01 = new ScenarioEntity <IBloc>(13, scenarioTag.WellKnownItems[13]); crate_right02 = new ScenarioEntity <IBloc>(14, scenarioTag.WellKnownItems[14]); crate_right03 = new ScenarioEntity <IBloc>(15, scenarioTag.WellKnownItems[15]); crate_right04 = new ScenarioEntity <IBloc>(16, scenarioTag.WellKnownItems[16]); crate_right05 = new ScenarioEntity <IBloc>(17, scenarioTag.WellKnownItems[17]); crate_right06 = new ScenarioEntity <IBloc>(18, scenarioTag.WellKnownItems[18]); crate_right07 = new ScenarioEntity <IBloc>(19, scenarioTag.WellKnownItems[19]); crate_right08 = new ScenarioEntity <IBloc>(20, scenarioTag.WellKnownItems[20]); crate_right09 = new ScenarioEntity <IBloc>(21, scenarioTag.WellKnownItems[21]); crate_right10 = new ScenarioEntity <IBloc>(22, scenarioTag.WellKnownItems[22]); crate_right11 = new ScenarioEntity <IBloc>(23, scenarioTag.WellKnownItems[23]); }
public FieldGetContext(ScenarioTag scenario, ScenarioTag.ScriptSyntaxNode node, MemberNameRepository nameRepo) : base(node) { this.OwnDataType = node.DataType; if (node.NodeString == 0) { accessor = SyntaxFactory.DefaultExpression(SyntaxUtil.ScriptTypeSyntax(node.DataType)); } else { var stringVal = SyntaxUtil.GetScriptString(scenario, node); if (stringVal == "none") { accessor = SyntaxFactory.DefaultExpression(SyntaxUtil.ScriptTypeSyntax(node.DataType)); } else { if (nameRepo.TryGetName(stringVal, node.DataType.ToString(), node.NodeData_H16, out var finalName)) { accessor = SyntaxFactory.IdentifierName(finalName); } else { accessor = SyntaxFactory.IdentifierName(SyntaxUtil.SanitizeIdentifier(stringVal)); } } } accessor = accessor.WithAdditionalAnnotations(ScriptGenAnnotations.TypeAnnotation(node.DataType)); }
public override void InitializeData(ScenarioTag scenarioTag, Scene scene) { this.Scenario = scenarioTag; alpha_lift = new ScenarioEntity <IBloc>(0, scenarioTag.WellKnownItems[0]); beta_lift = new ScenarioEntity <IBloc>(1, scenarioTag.WellKnownItems[1]); alpha_ctf_terr = new ScenarioEntity <IScenery>(14, scenarioTag.WellKnownItems[14]); bravo_ctf_terr = new ScenarioEntity <IScenery>(15, scenarioTag.WellKnownItems[15]); hall1_terr = new ScenarioEntity <IScenery>(17, scenarioTag.WellKnownItems[17]); hall2_terr = new ScenarioEntity <IScenery>(18, scenarioTag.WellKnownItems[18]); center_low = new ScenarioEntity <IScenery>(72, scenarioTag.WellKnownItems[72]); blue_effect = new ScenarioEntity <IScenery>(78, scenarioTag.WellKnownItems[78]); red_effect = new ScenarioEntity <IScenery>(79, scenarioTag.WellKnownItems[79]); drips_1 = new ScenarioEntity <IScenery>(113, scenarioTag.WellKnownItems[113]); drips_2 = new ScenarioEntity <IScenery>(114, scenarioTag.WellKnownItems[114]); drips_3 = new ScenarioEntity <IScenery>(115, scenarioTag.WellKnownItems[115]); drips_4 = new ScenarioEntity <IScenery>(116, scenarioTag.WellKnownItems[116]); drips_5 = new ScenarioEntity <IScenery>(117, scenarioTag.WellKnownItems[117]); drips_6 = new ScenarioEntity <IScenery>(118, scenarioTag.WellKnownItems[118]); drips_7 = new ScenarioEntity <IScenery>(119, scenarioTag.WellKnownItems[119]); lametrees = new ScenarioEntity <IScenery>(120, scenarioTag.WellKnownItems[120]); red = new ScenarioEntity <ISound>(121, scenarioTag.WellKnownItems[121]); blue = new ScenarioEntity <ISound>(122, scenarioTag.WellKnownItems[122]); throb = new ScenarioEntity <ISound>(123, scenarioTag.WellKnownItems[123]); redf = new ScenarioEntity <ISound>(124, scenarioTag.WellKnownItems[124]); bluef = new ScenarioEntity <ISound>(125, scenarioTag.WellKnownItems[125]); drips_8 = new ScenarioEntity <IScenery>(126, scenarioTag.WellKnownItems[126]); cool_middle = new ScenarioEntity <ISound>(127, scenarioTag.WellKnownItems[127]); }
public override void InitializeData(ScenarioTag scenarioTag, Scene scene) { this.Scenario = scenarioTag; core1 = new ScenarioEntity <ISound>(0, scenarioTag.WellKnownItems[0]); core2 = new ScenarioEntity <ISound>(1, scenarioTag.WellKnownItems[1]); core3 = new ScenarioEntity <ISound>(2, scenarioTag.WellKnownItems[2]); core4 = new ScenarioEntity <ISound>(3, scenarioTag.WellKnownItems[3]); }
public override void InitializeData(ScenarioTag scenarioTag, Scene scene) { this.Scenario = scenarioTag; alpha = new ScenarioEntity <IScenery>(0, scenarioTag.WellKnownItems[0]); charlie = new ScenarioEntity <IScenery>(1, scenarioTag.WellKnownItems[1]); bravo = new ScenarioEntity <IScenery>(2, scenarioTag.WellKnownItems[2]); delta = new ScenarioEntity <IScenery>(3, scenarioTag.WellKnownItems[3]); neutral = new ScenarioEntity <IScenery>(4, scenarioTag.WellKnownItems[4]); }
public static Machine FromTag(H2vMap map, ScenarioTag scenario, ScenarioTag.MachineryInstance instance) { var scenery = new Machine(); scenery.FriendlyName = "Machine_" + instance.MachineryDefinitionIndex; if (instance.MachineryDefinitionIndex == ushort.MaxValue) { Console.WriteLine($"MACH index out of range"); return(scenery); } var id = scenario.MachineryDefinitions[instance.MachineryDefinitionIndex].Machinery; var tag = map.GetTag(id); scenery.FriendlyName = tag.Name; var orientation = QuaternionExtensions.FromH2vOrientation(instance.Orientation); var xform = new TransformComponent(scenery, instance.Position, orientation); var components = new List <Component>(); if (tag.Model != uint.MaxValue) { components.Add(new RenderModelComponent(scenery, new Model <BitmapTag> { Note = $"[{tag.Id}] {tag.Name}", Meshes = MeshFactory.GetRenderModel(map, tag.Model), Flags = ModelFlags.Diffuse | ModelFlags.CastsShadows | ModelFlags.ReceivesShadows })); components.Add(new RenderModelComponent(scenery, new Model <BitmapTag> { Note = $"[{tag.Id}] {tag.Name} bones", Meshes = MeshFactory.GetBonesModel(map, tag.Model), Flags = ModelFlags.Wireframe, RenderLayer = RenderLayers.Debug })); var body = PhysicsComponentFactory.CreateKinematicRigidBody(scenery, xform, map, tag.Model); if (body != null) { components.Add(body); components.Add(new RenderModelComponent(scenery, new Model <BitmapTag> { Meshes = MeshFactory.GetRenderModel(body.Collider, new Vector4(1f, 0f, 1f, 1f)), Flags = ModelFlags.Wireframe | ModelFlags.IsStatic, RenderLayer = RenderLayers.Collision })); } } scenery.SetComponents(xform, components.ToArray()); return(scenery); }
public override void InitializeData(ScenarioTag scenarioTag, Scene scene) { this.Scenario = scenarioTag; ramps = new ScenarioEntity <IScenery>(0, scenarioTag.WellKnownItems[0]); crap = new ScenarioEntity <IScenery>(1, scenarioTag.WellKnownItems[1]); shroud_01 = new ScenarioEntity <IDevice>(2, scenarioTag.WellKnownItems[2]); shroud_02 = new ScenarioEntity <IDevice>(3, scenarioTag.WellKnownItems[3]); gate = new ScenarioEntity <IDevice>(4, scenarioTag.WellKnownItems[4]); tele_switch = new ScenarioEntity <IDevice>(5, scenarioTag.WellKnownItems[5]); }
public override void InitializeData(ScenarioTag scenarioTag, Scene scene) { this.Scenario = scenarioTag; base_gate_machine_0 = new ScenarioEntity <IDevice>(0, scenarioTag.WellKnownItems[0]); base_gate_machine_1 = new ScenarioEntity <IDevice>(1, scenarioTag.WellKnownItems[1]); group_2 = new ScenarioEntity <IDevice>(2, scenarioTag.WellKnownItems[2]); group_3 = new ScenarioEntity <IDevice>(3, scenarioTag.WellKnownItems[3]); base_switch_1 = new ScenarioEntity <IDevice>(4, scenarioTag.WellKnownItems[4]); base_swtich_0 = new ScenarioEntity <IDevice>(5, scenarioTag.WellKnownItems[5]); }
public ScriptInvocationContext(ScenarioTag scenario, ScenarioTag.ScriptSyntaxNode node) : base(node) { var method = scenario.ScriptMethods[node.OperationId]; invocation = SyntaxFactory.InvocationExpression( SyntaxFactory.MemberAccessExpression( SyntaxKind.SimpleMemberAccessExpression, SyntaxFactory.ThisExpression(), SyntaxFactory.IdentifierName( SyntaxUtil.SanitizeIdentifier(method.Description)))) .WithAdditionalAnnotations(ScriptGenAnnotations.TypeAnnotation(method.ReturnType)); }
public static Scenery FromTag(H2vMap map, ScenarioTag scenario, ScenarioTag.SkyboxInstance instance) { var scenery = new Scenery(); scenery.FriendlyName = "Skybox_" + instance.Skybox.Id; var tag = map.GetTag(instance.Skybox); if (map.TryGetTag(tag.Model, out var model) == false) { Console.WriteLine($"No MODE[{tag.Model}] found for SKY[{instance.Skybox}]"); return(scenery); } var meshes = new List <ModelMesh>(); var partIndex = model.Components.First().DamageLevels.First().HighestPieceIndex; meshes.AddRange(model.Parts[partIndex].Model.Meshes); var renderModelMeshes = new List <Mesh <BitmapTag> >(meshes.Count); foreach (var mesh in meshes) { var mat = map.CreateMaterial(mesh); renderModelMeshes.Add(new Mesh <BitmapTag>() { Compressed = mesh.Compressed, ElementType = mesh.ElementType, Indicies = mesh.Indices, Note = mesh.Note, RawData = mesh.RawData, Verticies = mesh.Verticies, Material = mat }); } var comp = new RenderModelComponent(scenery, new Model <BitmapTag> { Note = $"[{tag.Id}] {tag.Name}", Meshes = renderModelMeshes.ToArray(), Flags = ModelFlags.IsSkybox }); var components = new List <Component>(); components.Add(comp); scenery.SetComponents(components.ToArray()); return(scenery); }
public override void InitializeData(ScenarioTag scenarioTag, Scene scene) { this.Scenario = scenarioTag; assault = new ScenarioEntity <IScenery>(0, scenarioTag.WellKnownItems[0]); territories = new ScenarioEntity <IScenery>(1, scenarioTag.WellKnownItems[1]); territories_2 = new ScenarioEntity <IScenery>(2, scenarioTag.WellKnownItems[2]); territories_3 = new ScenarioEntity <IScenery>(3, scenarioTag.WellKnownItems[3]); eastbound_train = new ScenarioEntity <IDevice>(4, scenarioTag.WellKnownItems[4]); westbound_train = new ScenarioEntity <IDevice>(5, scenarioTag.WellKnownItems[5]); eastbound_death = new ScenarioEntity <IDevice>(6, scenarioTag.WellKnownItems[6]); westbound_death = new ScenarioEntity <IDevice>(7, scenarioTag.WellKnownItems[7]); }
public static Bloc FromTag(H2vMap map, ScenarioTag scenario, ScenarioTag.BlocInstance instance) { var scenery = new Bloc(); var components = new List <Component>(); var bloc = scenario.BlocDefinitions[instance.BlocDefinitionIndex].Bloc; var tag = map.GetTag(bloc); scenery.FriendlyName = tag.Name; components.Add(new RenderModelComponent(scenery, new Model <BitmapTag> { Note = $"[{tag.Id}] {tag.Name}", Flags = ModelFlags.Diffuse | ModelFlags.CastsShadows | ModelFlags.ReceivesShadows, Meshes = MeshFactory.GetRenderModel(map, tag.PhysicalModel), ColorChangeData = PackColorChange(instance) })); var orientation = QuaternionExtensions.FromH2vOrientation(instance.Orientation); var xform = new TransformComponent(scenery, instance.Position, orientation); var body = PhysicsComponentFactory.CreateDynamicRigidBody(scenery, xform, map, tag.PhysicalModel); if (body != null) { components.Add(body); components.Add(new RenderModelComponent(scenery, new Model <BitmapTag> { Note = $"bloc//{scenery.FriendlyName}-collision", Meshes = MeshFactory.GetRenderModel(body.Collider, new Vector4(0.19f, 0.47f, 0.15f, 1f)), Flags = ModelFlags.Wireframe | ModelFlags.IsStatic, RenderLayer = RenderLayers.Collision })); } var comOffset = Vector3.Zero; if (map.TryGetTag(tag.PhysicalModel, out var hlmt) && map.TryGetTag(hlmt.PhysicsModel, out var phmo) && phmo.BodyParameters.Length > 0) { comOffset = phmo.BodyParameters[0].CenterOfMass; } components.Add(new BoundsComponent(scenery, comOffset - new Vector3(0.02f), comOffset + new Vector3(0.02f), new Vector4(1f, 1f, 0, 1f))); components.Add(new BoundsComponent(scenery, new Vector3(-0.02f), new Vector3(0.02f), new Vector4(0, 1f, 0, 1f))); components.Add(new OriginalTagComponent(scenery, instance)); scenery.SetComponents(xform, components.ToArray()); return(scenery); }
public VariableAccessContext(ScenarioTag tag, ScenarioTag.ScriptSyntaxNode node) : base(node) { this.OwnDataType = node.DataType; access = SyntaxFactory.MemberAccessExpression( SyntaxKind.SimpleMemberAccessExpression, SyntaxFactory.ThisExpression(), SyntaxFactory.IdentifierName( SyntaxUtil.SanitizeIdentifier( SyntaxUtil.GetScriptString(tag, node)))) .WithAdditionalAnnotations(ScriptGenAnnotations.TypeAnnotation(node.DataType)); }
public TagGetContext(ScenarioTag scenario, ScenarioTag.ScriptSyntaxNode node) : base(node) { this.OwnDataType = node.DataType; invocation = InvocationExpression(MemberAccessExpression(SyntaxKind.SimpleMemberAccessExpression, IdentifierName("Engine"), GenericName(Identifier(nameof(IScriptEngine.GetTag))) .WithTypeArgumentList(TypeArgumentList(SingletonSeparatedList( SyntaxUtil.ScriptTypeSyntax(this.OwnDataType.Value)))))) .AddArgumentListArguments( Argument(SyntaxUtil.LiteralExpression(SyntaxUtil.GetScriptString(scenario, node))), Argument(SyntaxUtil.LiteralExpression(node.NodeData_32))) .WithAdditionalAnnotations(ScriptGenAnnotations.TypeAnnotation(node.DataType)); }
public LiteralContext(ScenarioTag scenario, ScenarioTag.ScriptSyntaxNode node, Scope containing) : base(node) { this.OwnDataType = node.DataType; var dest = node.DataType; if (SyntaxUtil.NumericLiteralTypes.Contains(node.DataType) && containing.Context is BinaryOperatorContext bin && SyntaxUtil.NumericLiteralTypes.Contains(bin.OwnDataType.Value)) { dest = bin.OwnDataType.Value; } this.literal = SyntaxUtil.LiteralExpression(scenario, node, dest); }
public override void InitializeData(ScenarioTag scenarioTag, Scene scene) { this.Scenario = scenarioTag; tram = new ScenarioEntity <IDevice>(0, scenarioTag.WellKnownItems[0]); door_tram_1 = new ScenarioEntity <IDevice>(1, scenarioTag.WellKnownItems[1]); door_tram_3 = new ScenarioEntity <IDevice>(2, scenarioTag.WellKnownItems[2]); door_tram_4 = new ScenarioEntity <IDevice>(3, scenarioTag.WellKnownItems[3]); zapper_control = new ScenarioEntity <IDevice>(4, scenarioTag.WellKnownItems[4]); starting_cage = new ScenarioEntity <IDevice>(5, scenarioTag.WellKnownItems[5]); door_elevator_tram_bot = new ScenarioEntity <IDevice>(6, scenarioTag.WellKnownItems[6]); looker_light_bottom_red = new ScenarioEntity <IDevice>(7, scenarioTag.WellKnownItems[7]); looker_light_right_red = new ScenarioEntity <IDevice>(8, scenarioTag.WellKnownItems[8]); looker_light_left_red = new ScenarioEntity <IDevice>(9, scenarioTag.WellKnownItems[9]); looker_light_top_red = new ScenarioEntity <IDevice>(10, scenarioTag.WellKnownItems[10]); elevator_tram = new ScenarioEntity <IDevice>(11, scenarioTag.WellKnownItems[11]); wall_elevator_tram_bot = new ScenarioEntity <IDevice>(12, scenarioTag.WellKnownItems[12]); door_tram_2 = new ScenarioEntity <IDevice>(13, scenarioTag.WellKnownItems[13]); inamberclad = new ScenarioEntity <IScenery>(14, scenarioTag.WellKnownItems[14]); zapper_cage = new ScenarioEntity <IDevice>(15, scenarioTag.WellKnownItems[15]); inhibitor = new ScenarioEntity <IDevice>(16, scenarioTag.WellKnownItems[16]); wall_tram = new ScenarioEntity <IDevice>(17, scenarioTag.WellKnownItems[17]); wall_platform_1 = new ScenarioEntity <IDevice>(18, scenarioTag.WellKnownItems[18]); wall_platform_2 = new ScenarioEntity <IDevice>(19, scenarioTag.WellKnownItems[19]); wall_platform_3 = new ScenarioEntity <IDevice>(20, scenarioTag.WellKnownItems[20]); wall_platform_4 = new ScenarioEntity <IDevice>(21, scenarioTag.WellKnownItems[21]); looker_light_top_green = new ScenarioEntity <IDevice>(22, scenarioTag.WellKnownItems[22]); looker_light_bottom_green = new ScenarioEntity <IDevice>(23, scenarioTag.WellKnownItems[23]); looker_light_right_green = new ScenarioEntity <IDevice>(24, scenarioTag.WellKnownItems[24]); looker_light_left_green = new ScenarioEntity <IDevice>(25, scenarioTag.WellKnownItems[25]); wall_platform_5 = new ScenarioEntity <IDevice>(26, scenarioTag.WellKnownItems[26]); zapper = new ScenarioEntity <IDevice>(27, scenarioTag.WellKnownItems[27]); iac_intro = new ScenarioEntity <IDevice>(28, scenarioTag.WellKnownItems[28]); iac_tram = new ScenarioEntity <IDevice>(29, scenarioTag.WellKnownItems[29]); cookiesncream = new ScenarioEntity <IWeapon>(30, scenarioTag.WellKnownItems[30]); tram_marine_1 = new ScenarioEntity <IUnit>(31, scenarioTag.WellKnownItems[31]); tram_marine_2 = new ScenarioEntity <IUnit>(32, scenarioTag.WellKnownItems[32]); tram_marine_3 = new ScenarioEntity <IUnit>(33, scenarioTag.WellKnownItems[33]); tram_marine_4 = new ScenarioEntity <IUnit>(34, scenarioTag.WellKnownItems[34]); tram_marine_5 = new ScenarioEntity <IUnit>(35, scenarioTag.WellKnownItems[35]); tram_marine_6 = new ScenarioEntity <IUnit>(36, scenarioTag.WellKnownItems[36]); tram_marine_7 = new ScenarioEntity <IUnit>(37, scenarioTag.WellKnownItems[37]); guns = new Squad_guns(scenarioTag); johnson = new Squad_johnson(scenarioTag); tracker_elite = new Squad_tracker_elite(scenarioTag); atr1_mar = new Squad_atr1_mar(scenarioTag); mid_mar = new Squad_mid_mar(scenarioTag); atr2_mar = new Squad_atr2_mar(scenarioTag); }
public override void InitializeData(ScenarioTag scenarioTag, Scene scene) { this.Scenario = scenarioTag; beam_low = new ScenarioEntity <ISound>(1, scenarioTag.WellKnownItems[1]); island = new ScenarioEntity <ISound>(2, scenarioTag.WellKnownItems[2]); blue_flag = new ScenarioEntity <IScenery>(3, scenarioTag.WellKnownItems[3]); red_flag = new ScenarioEntity <IScenery>(4, scenarioTag.WellKnownItems[4]); n_flag = new ScenarioEntity <IScenery>(5, scenarioTag.WellKnownItems[5]); terr1 = new ScenarioEntity <IScenery>(6, scenarioTag.WellKnownItems[6]); terr2 = new ScenarioEntity <IScenery>(7, scenarioTag.WellKnownItems[7]); terr4 = new ScenarioEntity <IScenery>(8, scenarioTag.WellKnownItems[8]); terr3 = new ScenarioEntity <IScenery>(9, scenarioTag.WellKnownItems[9]); terr5 = new ScenarioEntity <IScenery>(10, scenarioTag.WellKnownItems[10]); beam_main = new ScenarioEntity <ISound>(11, scenarioTag.WellKnownItems[11]); beam_outer = new ScenarioEntity <ISound>(12, scenarioTag.WellKnownItems[12]); }
public override void InitializeData(ScenarioTag scenarioTag, Scene scene) { this.Scenario = scenarioTag; bob = new ScenarioEntity <IScenery>(0, scenarioTag.WellKnownItems[0]); bob1 = new ScenarioEntity <IScenery>(1, scenarioTag.WellKnownItems[1]); bob2 = new ScenarioEntity <IScenery>(2, scenarioTag.WellKnownItems[2]); bob3 = new ScenarioEntity <IScenery>(3, scenarioTag.WellKnownItems[3]); rifle = new ScenarioEntity <IScenery>(4, scenarioTag.WellKnownItems[4]); blade = new ScenarioEntity <IScenery>(5, scenarioTag.WellKnownItems[5]); e3_coil_01 = new ScenarioEntity <IBloc>(6, scenarioTag.WellKnownItems[6]); e3_coil_02 = new ScenarioEntity <IBloc>(7, scenarioTag.WellKnownItems[7]); e3_coil_03 = new ScenarioEntity <IBloc>(8, scenarioTag.WellKnownItems[8]); elite = new ScenarioEntity <IUnit>(9, scenarioTag.WellKnownItems[9]); chief = new ScenarioEntity <IUnit>(10, scenarioTag.WellKnownItems[10]); e3_flag = new ScenarioEntity <IWeapon>(11, scenarioTag.WellKnownItems[11]); house_gate = new ScenarioEntity <IDevice>(14, scenarioTag.WellKnownItems[14]); }
public GameDifficultyContext(ScenarioTag scenario, ScenarioTag.ScriptSyntaxNode node, Scope containing) : base(node) { this.OwnDataType = node.DataType; var difficulty = node.NodeData_H16 switch { 0 => nameof(GameDifficulty.Easy), 1 => nameof(GameDifficulty.Normal), 2 => nameof(GameDifficulty.Heroic), 3 => nameof(GameDifficulty.Legendary), _ => throw new NotSupportedException() }; this.literal = InvocationExpression(MemberAccessExpression(SyntaxKind.SimpleMemberAccessExpression, IdentifierName(nameof(GameDifficulty)), IdentifierName(difficulty))); }
public ScriptInterpreter( ScenarioTag scenario, IScriptEngine scriptEngine) { this.scenario = scenario; this.scriptEngine = scriptEngine; if (scenario.ScriptVariables?.Length > 0) { this.variables = new Result[scenario.ScriptVariables.Length]; InitializeVariables(); } else { this.variables = Array.Empty <Result>(); } }
public override void InitializeData(ScenarioTag scenarioTag, Scene scene) { this.Scenario = scenarioTag; crane = new ScenarioEntity <IScenery>(0, scenarioTag.WellKnownItems[0]); control_room = new ScenarioEntity <IScenery>(1, scenarioTag.WellKnownItems[1]); center = new ScenarioEntity <IScenery>(2, scenarioTag.WellKnownItems[2]); red_tower = new ScenarioEntity <IScenery>(3, scenarioTag.WellKnownItems[3]); blue_tower = new ScenarioEntity <IScenery>(4, scenarioTag.WellKnownItems[4]); bunker = new ScenarioEntity <IScenery>(5, scenarioTag.WellKnownItems[5]); hvac_lift = new ScenarioEntity <IBloc>(6, scenarioTag.WellKnownItems[6]); end_of_canal_water___office = new ScenarioEntity <ISound>(8, scenarioTag.WellKnownItems[8]); end_of_canal_water___storage = new ScenarioEntity <ISound>(9, scenarioTag.WellKnownItems[9]); center_high_terries = new ScenarioEntity <IScenery>(10, scenarioTag.WellKnownItems[10]); crane_base = new ScenarioEntity <ISound>(11, scenarioTag.WellKnownItems[11]); crane_tower_cylinder = new ScenarioEntity <ISound>(41, scenarioTag.WellKnownItems[41]); garage_ambience = new ScenarioEntity <ISound>(42, scenarioTag.WellKnownItems[42]); city_on_fire = new ScenarioEntity <ISound>(43, scenarioTag.WellKnownItems[43]); control_desk = new ScenarioEntity <ISound>(45, scenarioTag.WellKnownItems[45]); vending_machine = new ScenarioEntity <ISound>(46, scenarioTag.WellKnownItems[46]); storage1 = new ScenarioEntity <ISound>(48, scenarioTag.WellKnownItems[48]); storage2 = new ScenarioEntity <ISound>(49, scenarioTag.WellKnownItems[49]); storage3 = new ScenarioEntity <ISound>(50, scenarioTag.WellKnownItems[50]); vertical_pipes = new ScenarioEntity <ISound>(52, scenarioTag.WellKnownItems[52]); high_vent_1 = new ScenarioEntity <ISound>(53, scenarioTag.WellKnownItems[53]); high_vent_2 = new ScenarioEntity <ISound>(54, scenarioTag.WellKnownItems[54]); high_vent_6 = new ScenarioEntity <ISound>(55, scenarioTag.WellKnownItems[55]); high_vent_5 = new ScenarioEntity <ISound>(56, scenarioTag.WellKnownItems[56]); high_vent_4 = new ScenarioEntity <ISound>(57, scenarioTag.WellKnownItems[57]); high_vent_3 = new ScenarioEntity <ISound>(58, scenarioTag.WellKnownItems[58]); platform = new ScenarioEntity <IScenery>(60, scenarioTag.WellKnownItems[60]); storage = new ScenarioEntity <IScenery>(61, scenarioTag.WellKnownItems[61]); steam = new ScenarioEntity <ISound>(64, scenarioTag.WellKnownItems[64]); steamcloseup = new ScenarioEntity <ISound>(65, scenarioTag.WellKnownItems[65]); broken_light = new ScenarioEntity <ISound>(66, scenarioTag.WellKnownItems[66]); vertical_pipe2 = new ScenarioEntity <ISound>(67, scenarioTag.WellKnownItems[67]); vertical_pipe_3 = new ScenarioEntity <ISound>(68, scenarioTag.WellKnownItems[68]); pipesvent1 = new ScenarioEntity <ISound>(69, scenarioTag.WellKnownItems[69]); pipesvent2 = new ScenarioEntity <ISound>(70, scenarioTag.WellKnownItems[70]); roofwalkvent = new ScenarioEntity <ISound>(71, scenarioTag.WellKnownItems[71]); bigwallvent = new ScenarioEntity <ISound>(72, scenarioTag.WellKnownItems[72]); bluebasepipes1 = new ScenarioEntity <ISound>(73, scenarioTag.WellKnownItems[73]); bluebasepipes2 = new ScenarioEntity <ISound>(74, scenarioTag.WellKnownItems[74]); matthole = new ScenarioEntity <ISound>(75, scenarioTag.WellKnownItems[75]); }
public static Vehicle CreateFromVehicleInstance(H2vMap map, ScenarioTag scenario, ScenarioTag.VehicleInstance instance) { var item = new Vehicle(); item.FriendlyName = "Vehicle_" + instance.Index; var def = scenario.VehicleDefinitions[instance.Index]; if (map.TryGetTag(def.Vehicle, out var vehi) == false) { throw new Exception("No tag found for vehi reference"); } var xform = new TransformComponent(item, instance.Position, QuaternionExtensions.FromH2vOrientation(instance.Orientation)); PopulateVehicle(item, map, xform, vehi); return(item); }
public UnknownContext(ScenarioTag scenario, ScenarioTag.ScriptSyntaxNode node) : base(node) { this.OwnDataType = node.DataType; string unknownDescription = ""; if (node.NodeString > 0 && node.NodeString < scenario.ScriptStrings.Length && scenario.ScriptStrings[node.NodeString - 1] == 0) { unknownDescription = SyntaxUtil.GetScriptString(scenario, node); } unknownDescription += $" -{node.NodeType}<{node.DataType}>"; invocation = SyntaxFactory.InvocationExpression( SyntaxFactory.IdentifierName("UNKNOWN"), SyntaxFactory.ArgumentList( SyntaxFactory.SingletonSeparatedList( SyntaxFactory.Argument(SyntaxUtil.LiteralExpression(unknownDescription))))); }
public override void InitializeData(ScenarioTag scenarioTag, Scene scene) { this.Scenario = scenarioTag; hanger_can_01 = new ScenarioEntity <IBloc>(0, scenarioTag.WellKnownItems[0]); static_01 = new ScenarioEntity <IBloc>(1, scenarioTag.WellKnownItems[1]); static_02 = new ScenarioEntity <IBloc>(2, scenarioTag.WellKnownItems[2]); static_03 = new ScenarioEntity <IBloc>(3, scenarioTag.WellKnownItems[3]); static_04 = new ScenarioEntity <IBloc>(4, scenarioTag.WellKnownItems[4]); hanger_can_07 = new ScenarioEntity <IBloc>(5, scenarioTag.WellKnownItems[5]); hanger_can_02 = new ScenarioEntity <IBloc>(6, scenarioTag.WellKnownItems[6]); hanger_can_03 = new ScenarioEntity <IBloc>(7, scenarioTag.WellKnownItems[7]); hanger_can_04 = new ScenarioEntity <IBloc>(8, scenarioTag.WellKnownItems[8]); hanger_can_05 = new ScenarioEntity <IBloc>(9, scenarioTag.WellKnownItems[9]); hanger_can_06 = new ScenarioEntity <IBloc>(10, scenarioTag.WellKnownItems[10]); hanger_can_08 = new ScenarioEntity <IBloc>(11, scenarioTag.WellKnownItems[11]); hanger_can_09 = new ScenarioEntity <IBloc>(12, scenarioTag.WellKnownItems[12]); hanger_can_10 = new ScenarioEntity <IBloc>(13, scenarioTag.WellKnownItems[13]); hanger_can_11 = new ScenarioEntity <IBloc>(14, scenarioTag.WellKnownItems[14]); hanger_can_12 = new ScenarioEntity <IBloc>(15, scenarioTag.WellKnownItems[15]); }
private void AddSquadInitialization(List <StatementSyntax> statements, ScenarioTag tag) { for (var i = 0; i < tag.AiSquadDefinitions.Length; i++) { var squad = tag.AiSquadDefinitions[i]; if (nameRepo.TryGetName(squad.Description, ScriptDataType.AI.ToString(), i, out var squadPropName) == false) { return; } var squadTypeName = "Squad_" + squadPropName; var squadItem = ObjectCreationExpression(ParseTypeName(squadTypeName)) .AddArgumentListArguments(Argument(IdentifierName("scenarioTag"))); var squadItemAssignment = AssignmentExpression(SyntaxKind.SimpleAssignmentExpression, IdentifierName(squadPropName), squadItem); statements.Add(ExpressionStatement(squadItemAssignment)); } }
public EntityGetContext(ScenarioTag scenario, ScenarioTag.ScriptSyntaxNode node, MemberNameRepository nameRepo) : base(node) { this.OwnDataType = node.DataType; if (node.NodeString == 0) { accessor = SyntaxFactory.DefaultExpression(SyntaxUtil.ScriptTypeSyntax(node.DataType)); } else { var stringVal = SyntaxUtil.GetScriptString(scenario, node); if (stringVal == "none") { accessor = SyntaxFactory.DefaultExpression(SyntaxUtil.ScriptTypeSyntax(node.DataType)); } else { if (nameRepo.TryGetName(stringVal, nameof(ScenarioTag.EntityReference), node.NodeData_H16, out var finalName)) { accessor = SyntaxFactory.IdentifierName(finalName); } else { accessor = SyntaxFactory.IdentifierName(SyntaxUtil.SanitizeIdentifier(stringVal)); } if (node.DataType != ScriptDataType.EntityIdentifier) { accessor = SyntaxFactory.MemberAccessExpression(SyntaxKind.SimpleMemberAccessExpression, accessor, SyntaxFactory.IdentifierName(nameof(ScenarioEntity <object> .Entity))); } } } accessor = accessor.WithAdditionalAnnotations(ScriptGenAnnotations.TypeAnnotation(node.DataType)); }