public Game1() { selectedStructure = null; oldState = Mouse.GetState(); newState = oldState; IsMouseVisible = true; Window.AllowUserResizing = false; Content.RootDirectory = "Content"; graphics = new GraphicsDeviceManager(this); IsFixedTimeStep = false; //vsync graphics.SynchronizeWithVerticalRetrace = false; //fpsCount FpsCounter = new FPSCounter(physicalMaxFPS); //graphical cords windowSizeXPlus12 = windowSizeX + 12; windowSizeXPlus46 = windowSizeX + 46; windowSizeXPlus37 = windowSizeX + 37; windowSizeXPlus6 = windowSizeX + 6; windowSizeXPlus4 = windowSizeX + 4; windowSizeXPlus27 = windowSizeX + 27; windowSizeXPlus50 = windowSizeX + 50; windowSizeXPlus1 = windowSizeX + 1; menuHeightMinus30 = menuHeight - 30; menuHeightMinus5 = menuHeight - 5; menuHeightPlus4 = menuHeight + 4; }
public bool UseNamespace(string ns, string declloc, IWarningLogger log) { if (bm == null) { // No bundle manager yet. Save the info; once our manager is // set, we can do all the loading and structure template instantiation. nsqueue[ns] = declloc; return(false); } // Standard initialization. UseRawNamespace("MBuildDynamic." + ns); // Now we load the associated structure template and instantiate // anything that needs instantiation. // XXX this was later before; why??? if (declloc == null) { throw ExHelp.App("! {0}, {1}", ns, declloc); } StructureTemplate st = bm.UseNamespaceTemplate(ns, declloc, log); if (st == null) { return(true); } known_structs[st.GetType()] = st; return(false); }
public void UseStructure(StructureTemplate st) { Type stype = st.GetType(); known_structs[stype] = st; UseRawNamespace(stype.Namespace); }
public void BuildTransition(StructureTemplateGroup dungeonTransitionGroup, WIGroup dungeonGroup) { //then add the children for (int j = 0; j < dungeonTransitionGroup.StaticStructureLayers.Count; j++) { StructureTemplate.InstantiateStructureLayer(dungeonTransitionGroup.StaticStructureLayers [j], transform); } //create and find triggers StructureTemplate.InstantiateGenericDynamic(dungeonTransitionGroup.GenericDynamic, TriggerParent, dungeonGroup); }
private void MouseManage() { sideMenuEtMouseFollowUp = sideMenu && mouseFollowUp; structureHover = selectedStructure != null && newState.X >= 0 && newState.X < windowSizeX && newState.Y >= 0 && newState.Y < windowSizeY; statePressed = newState.LeftButton == ButtonState.Pressed && oldState.LeftButton == ButtonState.Released && this.IsActive; if (statePressed) { if (structureHover) { if (newState.X < windowSizeX && newState.Y < windowSizeY) { for (int y = 0; y < selectedStructure.getHeight(arrowDirection); y++) { for (int x = 0; x < selectedStructure.getWidth(arrowDirection); x++) { if (selectedStructure.getValue(arrowDirection, x, y, structureFlipped) > 0) { JeuDeLaVieTable.setLife(x + newState.X - selectedStructure.getWidth(arrowDirection) / 2, y + newState.Y - selectedStructure.getHeight(arrowDirection) / 2, (byte)selectedStructure.getValue(arrowDirection, x, y, structureFlipped)); } } } } } if (sideMenuEtMouseFollowUp) { bool foundSomething = false; if (newState.X >= windowSizeXPlus12 && newState.Y >= menuHeightMinus30 && newState.X < windowSizeXPlus37 && newState.Y < menuHeightMinus5) { foundSomething = true; arrowDirection += 1; if (arrowDirection >= 4) { arrowDirection = 0; } generateStructureTexture(); generateArrowTexture(); } for (int y = 0, yCord = 0; !foundSomething && y < structureMgr.StructureTemplates.Count; y++, yCord += 22) { if (newState.X >= windowSizeXPlus6 && newState.Y >= menuHeight + yCord && newState.X < windowSizeXPlus46 && newState.Y < menuHeight + yCord + 22) { foundSomething = true; selectedStructure = structureMgr.StructureTemplates[y]; indexSelectedStructure = y; generateStructureTexture(); generateMenuTexture(); } } } } }
public void EditorSaveDungeonToTemplate( ) { if (!Manager.IsAwake <WorldItems> ()) { Manager.WakeUp <WorldItems> ("Frontiers_WorldItems"); } if (!Manager.IsAwake <Structures> ()) { Manager.WakeUp <Structures> ("Frontiers_Structures"); } if (!Manager.IsAwake <Mods> ()) { Manager.WakeUp <Mods> ("__MODS"); } Mods.Get.Editor.InitializeEditor(true); //make sure the dungeon is all set up CreateDungeonTransforms(); EditorFindDungeonPieces(); LinkOcclusionGroups(); DungeonTemplate newTemplate = new DungeonTemplate(); for (int i = 0; i < Modules.Count; i++) { DungeonModule module = Modules [i]; StructureTemplateGroup moduleInteriorGroup = new StructureTemplateGroup(); moduleInteriorGroup.GroupOffset = module.transform.localPosition; moduleInteriorGroup.GroupRotation = module.transform.localRotation.eulerAngles; module.EditorSaveModuleToTemplate(moduleInteriorGroup); newTemplate.Modules.InteriorVariants.Add(moduleInteriorGroup); } for (int i = 0; i < Transitions.Count; i++) { DungeonTransition transition = Transitions [i]; StructureTemplateGroup transitionInteriorGroup = new StructureTemplateGroup(); transitionInteriorGroup.GroupOffset = transition.transform.localPosition; transitionInteriorGroup.GroupRotation = transition.transform.localRotation.eulerAngles; StructureTemplate.AddStaticChildrenToStructureTemplate(transition.transform, transitionInteriorGroup.StaticStructureLayers); StructureTemplate.AddGenericDynamicToStructureTemplate(transition.TriggerParent, ref transitionInteriorGroup.GenericDynamic); newTemplate.Transitions.InteriorVariants.Add(transitionInteriorGroup); } Mods.Get.Editor.SaveMod <DungeonTemplate> (newTemplate, "Dungeon", GetTemplateName(gameObject.name)); }
public void CreateStructureFootprint() { StructureTemplate template = null; if (Mods.Get.Editor.LoadMod <StructureTemplate> (ref template, "Structure", StructureBuilder.GetTemplateName(name))) { GameObject footprint = gameObject.FindOrCreateChild("__FOOTPRINT").gameObject; GameObject shingle = gameObject.FindOrCreateChild("__SHINGLE").gameObject; shingle.transform.localPosition = template.CommonShingleOffset; for (int i = 0; i < template.Footprint.Count; i++) { GameObject fp = footprint.FindOrCreateChild("Footprint" + i.ToString()).gameObject; fp.transform.localPosition = template.Footprint [i].Position; fp.transform.localScale = template.Footprint [i].Scale; fp.GetOrAdd <StructureFootprint> (); } } }
protected IEnumerator InstanceMeshes( StructureTemplateGroup structureGroup, string childName, List <Renderer> renderers, List <Renderer> lodRenderers, float lodRatio) { renderers.Clear(); if (lodRenderers != null) { lodRenderers.Clear(); } StructurePiece = StructureBase.CreateChild(childName); StructurePiece.parent = null; if (Mode == BuilderMode.Minor) { //minor structures have to set their own offsets StructurePiece.position = MinorParent.Position; StructurePiece.rotation = Quaternion.Euler(MinorParent.Rotation); } else { StructurePiece.ResetLocal(); } StructurePiece.gameObject.layer = Globals.LayerNumSolidTerrain; //TODO this may be unnecessary for (int i = 0; i < structureGroup.StaticStructureLayers.Count; i++) { StructureTemplate.InstantiateStructureLayer(structureGroup.StaticStructureLayers [i], StructurePiece); } StructurePiece.parent = StructureBase.transform; if (Mode == BuilderMode.Minor) { StructurePiece.localPosition = MinorParent.Position; StructurePiece.localRotation = Quaternion.Euler(MinorParent.Rotation); } else { StructurePiece.ResetLocal(); } yield break; }
public void Reset() { StructureBase = null; StructurePiece = null; ParentStructure = null; MinorParent = null; if (MaterialLookup != null) { MaterialLookup.Clear(); } //if (Template != null) { //Template.Clear(); //} Template = null; if (gHelperTransform != null) { gHelperTransform.transform.parent = transform; } State = BuilderState.Dormant; }
public void EditorSaveModuleToTemplate(StructureTemplateGroup moduleInteriorGroup) { Transform normalFX = gameObject.FindOrCreateChild("__FX"); Transform normalCol = gameObject.FindOrCreateChild("__COLLIDERS"); Transform normalWIsGen = gameObject.FindOrCreateChild("__WORLDITEMS_GENERIC"); Transform normalWindowsGen = gameObject.FindOrCreateChild("__WINDOWS_GENERIC"); Transform normalDoorsGen = gameObject.FindOrCreateChild("__DOORS_GENERIC"); Transform normalWIsUnique = gameObject.FindOrCreateChild("__WORLDITEMS_UNIQUE"); Transform normalChrs = gameObject.FindOrCreateChild("__ACTION_NODES"); Transform normalDyn = gameObject.FindOrCreateChild("__DYNAMIC"); Transform normalStat = gameObject.FindOrCreateChild("__STATIC"); Transform normalSub = gameObject.FindOrCreateChild("__SUBSTRUCTURES"); Transform normalWindows = gameObject.FindOrCreateChild("__WINDOWS"); Transform normalTriggers = gameObject.FindOrCreateChild("__TRIGGERS"); StructureTemplate.AddStaticChildrenToStructureTemplate(normalStat, moduleInteriorGroup.StaticStructureLayers); StructureTemplate.AddGenericWorldItemsToStructureTemplate(normalWIsGen, ref moduleInteriorGroup.GenericWItems); StructureTemplate.AddUniqueWorldItemsToStructureTemplate(normalWIsUnique, moduleInteriorGroup.UniqueWorlditems); StructureTemplate.AddActionNodesToTemplate(normalChrs, moduleInteriorGroup.ActionNodes); StructureTemplate.AddTriggersToStructureTemplate(normalTriggers, moduleInteriorGroup.Triggers); }
public IEnumerator Initialize(Structure parentStructure, StructureTemplate template, StructureLoadPriority priority) { //if we're still doing another job (for some reason) wait for it to finish while (State != BuilderState.Dormant) { yield return(null); } Template = template; State = BuilderState.Initialized; Priority = priority; gHelperTransform = gameObject.FindOrCreateChild("StructureBuilderHelper_" + name); ParentStructure = parentStructure; if (ParentStructure == null) { Debug.LogError("Parent structure null in builder, proceeding normally"); State = BuilderState.Error; yield break; } if (ParentStructure.worlditem.Group == null) { Debug.Log("Parent structure worlditem group was null, proceeding normally"); State = BuilderState.Error; yield break; } if (ParentStructure.StructureGroup == null) { Debug.Log("Parent structure StructureGroup was null, waiting until group exists"); State = BuilderState.Error; yield break; } StructureBase = parentStructure.StructureGroup.gameObject; StructureChunk = parentStructure.worlditem.Group.GetParentChunk(); InteriorVariants.Clear(); InteriorVariants.Add(ParentStructure.State.BaseInteriorVariant); InteriorVariants.AddRange(ParentStructure.State.AdditionalInteriorVariants); yield break; }
public IEnumerator Initialize(MinorStructure minorParent, StructureTemplate template, StructureLoadPriority priority) { //if we're still doing another job (for some reason) wait for it to finish while (State != BuilderState.Dormant) { yield return(null); } gHelperTransform = gameObject.FindOrCreateChild("StructureBuilderHelper_" + name); try { MinorParent = minorParent; Template = template; State = BuilderState.Initialized; Priority = priority; StructureChunk = MinorParent.Chunk; StructureBase = MinorParent.StructureOwner.gameObject; } catch (Exception e) { Debug.LogException(e); State = BuilderState.Error; } yield break; }
// Use this for initialization void OnEnable() { // if (string.IsNullOrEmpty (StartStructure) || string.IsNullOrEmpty (EndStructure)) { // enabled = false; // return; // } // // NumStructuresSaved = 0; // FinishedSavingStructures = false; // builder.name = StartStructure; // RunEditorCoroutine (); if (!Manager.IsAwake <Mods> ()) { Manager.WakeUp <Mods> ("__MODS"); } Mods.Get.Editor.InitializeEditor(true); List <string> structuresToSave = Mods.Get.Editor.Available("Structure"); StructureTemplate currentTemplate = null; foreach (string structureToSave in structuresToSave) { if (Mods.Get.Editor.LoadMod <StructureTemplate> (ref currentTemplate, "Structure", structureToSave)) { // SaveStackItems (currentTemplate.Exterior.UniqueDoors); // SaveStackItems (currentTemplate.Exterior.UniqueDynamic); // SaveStackItems (currentTemplate.Exterior.UniqueWindows); // SaveStackItems (currentTemplate.Exterior.UniqueWorlditems); // foreach (StructureTemplateGroup intGroup in currentTemplate.InteriorVariants) { // SaveStackItems (intGroup.UniqueDoors); // SaveStackItems (intGroup.UniqueDynamic); // SaveStackItems (intGroup.UniqueWindows); // SaveStackItems (intGroup.UniqueWorlditems); // } Mods.Get.Editor.SaveMod <StructureTemplate> (currentTemplate, "Structure", structureToSave); } } }
protected static int AutoCalculateStructureValue(Structure structure) { //TODO this method sucks, do something better int structureValue = 1; //see how big the house is StructureTemplate template = null; if (Mods.Get.Editor.LoadMod <StructureTemplate> (ref template, "Structure", structure.State.TemplateName)) { int numDoorsAndWindows = template.Exterior.GenericDoors.Length + template.Exterior.GenericWindows.Length; int stackItems = template.Exterior.UniqueWorlditems.Count; List <ChildPiece> genericDoors = null; //new List<ChildPiece>(); List <ChildPiece> genericWindows = null; //new List<ChildPiece>(); if (StructureTemplate.ExtractChildPiecesFromLayer(ref genericDoors, template.Exterior.GenericDoors)) { numDoorsAndWindows += genericDoors.Count; } if (StructureTemplate.ExtractChildPiecesFromLayer(ref genericWindows, template.Exterior.GenericWindows)) { numDoorsAndWindows += genericWindows.Count; } for (int i = 0; i < template.InteriorVariants.Count; i++) { if (StructureTemplate.ExtractChildPiecesFromLayer(ref genericDoors, template.InteriorVariants [i].GenericDoors)) { numDoorsAndWindows += genericDoors.Count; } if (StructureTemplate.ExtractChildPiecesFromLayer(ref genericWindows, template.InteriorVariants [i].GenericWindows)) { numDoorsAndWindows += genericWindows.Count; } stackItems += template.InteriorVariants [i].UniqueWorlditems.Count; } structureValue += numDoorsAndWindows + stackItems; } return(structureValue); }
public StructureTemplateNature(StructureTemplate st, double percentageChance) : base(st.StructureMap, st.Id) { this.percentageChance = percentageChance; }
public void CreateFoundation() { if (!Manager.IsAwake <Mods> ()) { Manager.WakeUp <Mods> ("__MODS"); } Mods.Get.Editor.InitializeEditor(true); if (!Manager.IsAwake <Structures> ()) { Manager.WakeUp <Structures> ("Frontiers_Structures"); } Structures.Get.Initialize(); if (!Manager.IsAwake <WorldItems> ()) { Manager.WakeUp <WorldItems> ("Frontiers_WorldItems"); } WorldItems.Get.Initialize(); StructureTemplate template = null; if (Mods.Get.Editor.LoadMod <StructureTemplate> (ref template, "Structure", StructureBuilder.GetTemplateName(name))) { GameObject foundation = gameObject.FindOrCreateChild("__TEMP_FOUNDATION").gameObject; foreach (StructureLayer staticLayer in template.Exterior.StaticStructureLayers) { string prefabName = staticLayer.PrefabName.Trim().ToLower(); if (prefabName.Contains("foundation")) { StructurePackPrefab prefab = null; if (Structures.Get.PackStaticPrefab(staticLayer.PackName, staticLayer.PrefabName, out prefab)) { List <ChildPiece> staticPieces = null; if (StructureTemplate.ExtractChildPiecesFromLayer(ref staticPieces, staticLayer.Instances)) { //ChildPiece[] staticPieces = StructureTemplate.ExtractChildPiecesFromLayer(staticLayer.Instances); for (int i = 0; i < staticPieces.Count; i++) { ChildPiece piece = staticPieces [i]; GameObject instantiatedPrefab = UnityEditor.PrefabUtility.InstantiatePrefab(prefab.Prefab) as GameObject; //instantiate a new prefab - keep it as a prefab! instantiatedPrefab.name = prefab.Prefab.name; instantiatedPrefab.transform.parent = foundation.transform; instantiatedPrefab.tag = staticLayer.Tag; instantiatedPrefab.layer = staticLayer.Layer; //put it in the right place instantiatedPrefab.transform.localPosition = piece.Position; instantiatedPrefab.transform.localRotation = Quaternion.identity; instantiatedPrefab.transform.Rotate(piece.Rotation); instantiatedPrefab.transform.localScale = piece.Scale; Material[] variationsArray = null; if (staticLayer.Substitutions != null && staticLayer.Substitutions.Count > 0) { MeshRenderer pmr = prefab.MRenderer; variationsArray = pmr.sharedMaterials; string newMaterialName = string.Empty; for (int j = 0; j < variationsArray.Length; j++) { if (staticLayer.Substitutions.TryGetValue(variationsArray [j].name, out newMaterialName)) { Material sharedMaterial = null; if (Structures.Get.SharedMaterial(newMaterialName, out sharedMaterial)) { variationsArray [j] = sharedMaterial; } } } instantiatedPrefab.GetComponent <Renderer>().materials = variationsArray; } } staticPieces.Clear(); staticPieces = null; } } } } } }
public RegexMatcher() { stmpl = null; }
public override void AddContextStructure(StructureTemplate st) { namecontext.UseStructure(st); }
private void KeyManage() { if (wasTABDown) { if (!Keyboard.GetState().IsKeyDown(Keys.Tab)) { wasTABDown = false; } } else { if (Keyboard.GetState().IsKeyDown(Keys.Tab)) { wasTABDown = true; sideMenu = !sideMenu; if (sideMenu) { graphics.PreferredBackBufferWidth = windowSizeXPlus50; } else { graphics.PreferredBackBufferWidth = windowSizeX; } graphics.ApplyChanges(); } } if (wasQDown) { if (!Keyboard.GetState().IsKeyDown(Keys.Q)) { wasQDown = false; } } else { if (sideMenuEtMouseFollowUp && Keyboard.GetState().IsKeyDown(Keys.Q)) { wasQDown = true; arrowDirection += 1; if (arrowDirection >= 4) { arrowDirection = 0; } generateArrowTexture(); generateStructureTexture(); } } if (wasEDown) { if (!Keyboard.GetState().IsKeyDown(Keys.E)) { wasEDown = false; } } else { if (sideMenuEtMouseFollowUp && Keyboard.GetState().IsKeyDown(Keys.E)) { wasEDown = true; arrowDirection -= 1; if (arrowDirection < 0) { arrowDirection = 3; } generateArrowTexture(); generateStructureTexture(); } } if (wasWDown) { if (!Keyboard.GetState().IsKeyDown(Keys.W)) { wasWDown = false; } } else { if (Keyboard.GetState().IsKeyDown(Keys.W)) { wasWDown = true; if (indexSelectedStructure == null) { indexSelectedStructure = 0; } else { indexSelectedStructure -= 1; if (indexSelectedStructure < 0) { indexSelectedStructure = structureMgr.StructureTemplates.Count - 1; } } selectedStructure = structureMgr.StructureTemplates[(int)indexSelectedStructure]; generateStructureTexture(); generateMenuTexture(); } } if (wasSDown) { if (!Keyboard.GetState().IsKeyDown(Keys.S)) { wasSDown = false; } } else { if (Keyboard.GetState().IsKeyDown(Keys.S)) { wasSDown = true; if (indexSelectedStructure == null) { indexSelectedStructure = 0; } else { indexSelectedStructure += 1; if (indexSelectedStructure >= structureMgr.StructureTemplates.Count) { indexSelectedStructure = 0; } } selectedStructure = structureMgr.StructureTemplates[(int)indexSelectedStructure]; generateStructureTexture(); generateMenuTexture(); } } if (wasMDown) { if (!Keyboard.GetState().IsKeyDown(Keys.M)) { wasMDown = false; } } else { if (Keyboard.GetState().IsKeyDown(Keys.M)) { wasMDown = true; mouseFollowUp = !mouseFollowUp; } } if (wasRDown) { if (!Keyboard.GetState().IsKeyDown(Keys.R)) { wasRDown = false; } } else { if (Keyboard.GetState().IsKeyDown(Keys.R)) { wasRDown = true; structureFlipped = !structureFlipped; generateStructureTexture(); } } if (wasCDown) { if (!Keyboard.GetState().IsKeyDown(Keys.C)) { wasCDown = false; } } else { if (Keyboard.GetState().IsKeyDown(Keys.C)) { wasCDown = true; JeuDeLaVieTable.AffichageChangement = !JeuDeLaVieTable.AffichageChangement; } } if (GamePad.GetState(PlayerIndex.One).Buttons.Back == ButtonState.Pressed || Keyboard.GetState().IsKeyDown(Keys.Escape)) { Exit(); } }
protected TargetTemplate(StructureTemplate ignored) { }
protected TargetTemplate (StructureTemplate ignored) {}
public RegexMatcher(StructureTemplate stmpl) { this.stmpl = stmpl; }