public static PackedScene LoadAgentScene() { return(GD.Load <PackedScene>("res://src/microbe_stage/AgentProjectile.tscn")); }
/// <summary> /// Loads save /// </summary> /// <param name="name">The name of the save to load</param> public static void LoadSave(string name) { GD.Print("Starting load of save: ", name); new InProgressLoad(name).Start(); }
public Error OpenInExternalEditor(Script script, int line, int col) { var editor = (ExternalEditorId)editorSettings.GetSetting("mono/editor/external_editor"); switch (editor) { case ExternalEditorId.None: // Tells the caller to fallback to the global external editor settings or the built-in editor return(Error.Unavailable); case ExternalEditorId.VisualStudio: throw new NotSupportedException(); case ExternalEditorId.VisualStudioForMac: goto case ExternalEditorId.MonoDevelop; case ExternalEditorId.Rider: { string scriptPath = ProjectSettings.GlobalizePath(script.ResourcePath); RiderPathManager.OpenFile(GodotSharpDirs.ProjectSlnPath, scriptPath, line); return(Error.Ok); } case ExternalEditorId.MonoDevelop: { string scriptPath = ProjectSettings.GlobalizePath(script.ResourcePath); if (line >= 0) { GodotIdeManager.SendOpenFile(scriptPath, line + 1, col); } else { GodotIdeManager.SendOpenFile(scriptPath); } break; } case ExternalEditorId.VsCode: { if (_vsCodePath.Empty() || !File.Exists(_vsCodePath)) { // Try to search it again if it wasn't found last time or if it was removed from its location _vsCodePath = VsCodeNames.SelectFirstNotNull(OS.PathWhich, orElse: string.Empty); } var args = new List <string>(); bool osxAppBundleInstalled = false; if (OS.IsOSX) { // The package path is '/Applications/Visual Studio Code.app' const string vscodeBundleId = "com.microsoft.VSCode"; osxAppBundleInstalled = Internal.IsOsxAppBundleInstalled(vscodeBundleId); if (osxAppBundleInstalled) { args.Add("-b"); args.Add(vscodeBundleId); // The reusing of existing windows made by the 'open' command might not choose a wubdiw that is // editing our folder. It's better to ask for a new window and let VSCode do the window management. args.Add("-n"); // The open process must wait until the application finishes (which is instant in VSCode's case) args.Add("--wait-apps"); args.Add("--args"); } } var resourcePath = ProjectSettings.GlobalizePath("res://"); args.Add(resourcePath); string scriptPath = ProjectSettings.GlobalizePath(script.ResourcePath); if (line >= 0) { args.Add("-g"); args.Add($"{scriptPath}:{line + 1}:{col}"); } else { args.Add(scriptPath); } string command; if (OS.IsOSX) { if (!osxAppBundleInstalled && _vsCodePath.Empty()) { GD.PushError("Cannot find code editor: VSCode"); return(Error.FileNotFound); } command = osxAppBundleInstalled ? "/usr/bin/open" : _vsCodePath; } else { if (_vsCodePath.Empty()) { GD.PushError("Cannot find code editor: VSCode"); return(Error.FileNotFound); } command = _vsCodePath; } try { OS.RunProcess(command, args); } catch (Exception e) { GD.PushError($"Error when trying to run code editor: VSCode. Exception message: '{e.Message}'"); } break; } default: throw new ArgumentOutOfRangeException(); } return(Error.Ok); }
/// <summary> /// Makes summary text /// </summary> /// <param name="previousPopulations">If provided comparisons to previous populations is included</param> /// <param name="playerReadable">if true ids are removed from the output</param> /// <param name="effects">if not null these effects are applied to the population numbers</param> /// <returns>The generated summary text</returns> public LocalizedStringBuilder MakeSummary(PatchMap previousPopulations = null, bool playerReadable = false, List <ExternalEffect> effects = null) { const bool resolveMigrations = true; const bool resolveSplits = true; var builder = new LocalizedStringBuilder(500); LocalizedStringBuilder PatchString(Patch patch) { var builder2 = new LocalizedStringBuilder(80); if (!playerReadable) { builder2.Append(patch.ID); } builder2.Append(' '); builder2.Append(new LocalizedString(patch.Name)); return(builder2); } void OutputPopulationForPatch(Species species, Patch patch, long population) { builder.Append(" "); var patchName = PatchString(patch); if (population > 0) { builder.Append(patchName); builder.Append(' '); builder.Append(new LocalizedString("POPULATION")); builder.Append(' '); builder.Append(population); } else { // For some reason this line had one more space padding than the case that the population // wasn't extinct in this patch builder.Append(new LocalizedString("WENT_EXTINCT_IN", patchName)); } if (previousPopulations != null) { builder.Append(' '); builder.Append(new LocalizedString("PREVIOUS")); builder.Append(' '); builder.Append(previousPopulations.GetPatch(patch.ID).GetSpeciesPopulation(species)); } builder.Append('\n'); } foreach (var entry in results.Values.OrderByDescending(s => s.Species.PlayerSpecies) .ThenBy(s => s.Species.FormattedName)) { builder.Append(playerReadable ? entry.Species.FormattedName : entry.Species.FormattedIdentifier); builder.Append(":\n"); if (entry.SplitFrom != null) { builder.Append(' '); builder.Append(new LocalizedString("RUN_RESULT_SPLIT_FROM", playerReadable ? entry.SplitFrom.FormattedName : entry.SplitFrom.FormattedIdentifier)); builder.Append('\n'); } if (entry.NewlyCreated != null) { builder.Append(' '); switch (entry.NewlyCreated.Value) { case NewSpeciesType.FillNiche: builder.Append(new LocalizedString("RUN_RESULT_NICHE_FILL")); break; case NewSpeciesType.SplitDueToMutation: builder.Append(new LocalizedString("RUN_RESULT_SELECTION_PRESSURE_SPLIT")); break; default: GD.PrintErr("Unhandled newly created species type: ", entry.NewlyCreated.Value); builder.Append(entry.NewlyCreated.Value); break; } builder.Append('\n'); } if (entry.SplitOff != null) { if (entry.SplitOffPatches == null) { throw new InvalidOperationException("List of split off patches is null"); } builder.Append(' '); builder.Append(new LocalizedString("RUN_RESULT_SPLIT_OFF_TO", playerReadable ? entry.SplitOff.FormattedName : entry.SplitOff.FormattedIdentifier)); builder.Append('\n'); foreach (var patch in entry.SplitOffPatches) { builder.Append(" "); builder.Append(new LocalizedString(patch.Name)); builder.Append('\n'); } } if (entry.MutatedProperties != null) { builder.Append(' '); builder.Append(new LocalizedString("RUN_RESULT_HAS_A_MUTATION")); if (!playerReadable) { builder.Append(", "); builder.Append(new LocalizedString("RUN_RESULT_GENE_CODE")); builder.Append(' '); builder.Append(entry.MutatedProperties.StringCode); } builder.Append('\n'); } if (entry.SpreadToPatches.Count > 0) { builder.Append(' '); builder.Append(new LocalizedString("RUN_RESULT_SPREAD_TO_PATCHES")); builder.Append('\n'); foreach (var spreadEntry in entry.SpreadToPatches) { if (playerReadable) { builder.Append(" "); builder.Append(new LocalizedString("RUN_RESULT_BY_SENDING_POPULATION", new LocalizedString(spreadEntry.To.Name), spreadEntry.Population, new LocalizedString(spreadEntry.From.Name))); } else { builder.Append(" "); builder.Append(new LocalizedString(spreadEntry.To.Name)); builder.Append(" pop: "); builder.Append(spreadEntry.Population); builder.Append(" from: "); builder.Append(new LocalizedString(spreadEntry.From.Name)); } builder.Append('\n'); } } builder.Append(' '); builder.Append(new LocalizedString("RUN_RESULT_POP_IN_PATCHES")); builder.Append('\n'); foreach (var patchPopulation in entry.NewPopulationInPatches) { long adjustedPopulation = patchPopulation.Value; if (resolveMigrations) { adjustedPopulation += CountSpeciesSpreadPopulation(entry.Species, patchPopulation.Key); } if (resolveSplits) { if (entry.SplitOffPatches?.Contains(patchPopulation.Key) == true) { // All population splits off adjustedPopulation = 0; } } // Apply external effects if (effects != null && previousPopulations != null && previousPopulations.CurrentPatch.ID == patchPopulation.Key.ID) { foreach (var effect in effects) { if (effect.Species == entry.Species) { adjustedPopulation += effect.Constant + (long)(effect.Species.Population * effect.Coefficient) - effect.Species.Population; } } } // As the populations are added to all patches, even when the species is not there, we remove those // from output if there is currently no population in a patch and there isn't one in // previousPopulations var include = false; if (adjustedPopulation > 0) { include = true; } else { if (previousPopulations?.GetPatch(patchPopulation.Key.ID).GetSpeciesPopulation(entry.Species) > 0) { include = true; } } if (include) { OutputPopulationForPatch(entry.Species, patchPopulation.Key, adjustedPopulation); } } // Also print new patches the species moved to (as the moves don't get // included in newPopulationInPatches if (resolveMigrations) { foreach (var spreadEntry in entry.SpreadToPatches) { var found = false; var to = spreadEntry.To; foreach (var populationEntry in entry.NewPopulationInPatches) { if (populationEntry.Key == to) { found = true; break; } } if (!found) { OutputPopulationForPatch(entry.Species, to, CountSpeciesSpreadPopulation(entry.Species, to)); } } } // Print populations from splits // Warning suppressed on resolveSplits to allow keeping the variable // ReSharper disable once RedundantLogicalConditionalExpressionOperand if (resolveSplits && entry.SplitFrom != null) { var splitFrom = results[entry.SplitFrom]; // Skip if the SplitFrom variable was used just to indicate this didn't pop out of thin air if (splitFrom.SplitOff == entry.Species) { foreach (var patchPopulation in splitFrom.SplitOffPatches) { OutputPopulationForPatch(entry.Species, patchPopulation, splitFrom.NewPopulationInPatches[patchPopulation]); } } } if (GetGlobalPopulation(entry.Species, resolveMigrations, resolveSplits) <= 0) { builder.Append(' '); builder.Append(new LocalizedString("WENT_EXTINCT_FROM_PLANET")); builder.Append('\n'); } if (playerReadable) { builder.Append('\n'); } } return(builder); }
public void HandleAIDifficulty() { GD.Print("NoughtsxCross Ai Changed"); }
public override void _Ready() { organelleSelectionElements = GetTree().GetNodesInGroup("OrganelleSelectionElement"); membraneSelectionElements = GetTree().GetNodesInGroup("MembraneSelectionElement"); itemTooltipElements = GetTree().GetNodesInGroup("ItemTooltip"); menu = GetNode <Control>(MenuPath); sizeLabel = GetNode <Label>(SizeLabelPath); speedLabel = GetNode <Label>(SpeedLabelPath); generationLabel = GetNode <Label>(GenerationLabelPath); mutationPointsLabel = GetNode <Label>(MutationPointsLabelPath); mutationPointsBar = GetNode <TextureProgress>(MutationPointsBarPath); mutationPointsSubtractBar = GetNode <TextureProgress>(MutationPointsSubtractBarPath); speciesNameEdit = GetNode <LineEdit>(SpeciesNameEditPath); membraneColorPicker = GetNode <ColorPicker>(MembraneColorPickerPath); newCellButton = GetNode <TextureButton>(NewCellButtonPath); undoButton = GetNode <TextureButton>(UndoButtonPath); redoButton = GetNode <TextureButton>(RedoButtonPath); symmetryButton = GetNode <TextureButton>(SymmetryButtonPath); finishButton = GetNode <Button>(FinishButtonPath); atpBalanceLabel = GetNode <Label>(ATPBalanceLabelPath); atpProductionBar = GetNode <SegmentedBar>(ATPProductionBarPath); atpConsumptionBar = GetNode <SegmentedBar>(ATPConsumptionBarPath); glucoseReductionLabel = GetNode <Label>(GlucoseReductionLabelPath); autoEvoLabel = GetNode <Label>(AutoEvoLabelPath); externalEffectsLabel = GetNode <Label>(ExternalEffectsLabelPath); mapDrawer = GetNode <PatchMapDrawer>(MapDrawerPath); patchNothingSelected = GetNode <Control>(PatchNothingSelectedPath); patchDetails = GetNode <Control>(PatchDetailsPath); patchName = GetNode <Label>(PatchNamePath); patchPlayerHere = GetNode <Control>(PatchPlayerHerePath); patchBiome = GetNode <Label>(PatchBiomePath); patchDepth = GetNode <Label>(PatchDepthPath); patchTemperature = GetNode <Label>(PatchTemperaturePath); patchPressure = GetNode <Label>(PatchPressurePath); patchLight = GetNode <Label>(PatchLightPath); patchOxygen = GetNode <Label>(PatchOxygenPath); patchNitrogen = GetNode <Label>(PatchNitrogenPath); patchCO2 = GetNode <Label>(PatchCO2Path); patchHydrogenSulfide = GetNode <Label>(PatchHydrogenSulfidePath); patchAmmonia = GetNode <Label>(PatchAmmoniaPath); patchGlucose = GetNode <Label>(PatchGlucosePath); patchPhosphate = GetNode <Label>(PatchPhosphatePath); patchIron = GetNode <Label>(PatchIronPath); speciesList = GetNode <VBoxContainer>(SpeciesListPath); physicalConditionsBox = GetNode <Control>(PhysicalConditionsBoxPath); atmosphericConditionsBox = GetNode <Control>(AtmosphericConditionsBoxPath); compoundsBox = GetNode <Control>(CompoundsBoxPath); moveToPatchButton = GetNode <Button>(MoveToPatchButtonPath); physicalConditionsButton = GetNode <Control>(PhysicalConditionsButtonPath); atmosphericConditionsButton = GetNode <Control>(AtmosphericConditionsButtonPath); compoundsButton = GetNode <Control>(CompoundsBoxButtonPath); speciesListButton = GetNode <Control>(SpeciesListButtonPath); symmetryIcon = GetNode <TextureRect>(SymmetryIconPath); patchTemperatureSituation = GetNode <TextureRect>(PatchTemperatureSituationPath); patchLightSituation = GetNode <TextureRect>(PatchLightSituationPath); patchHydrogenSulfideSituation = GetNode <TextureRect>(PatchHydrogenSulfideSituationPath); patchGlucoseSituation = GetNode <TextureRect>(PatchGlucoseSituationPath); patchIronSituation = GetNode <TextureRect>(PatchIronSituationPath); patchAmmoniaSituation = GetNode <TextureRect>(PatchAmmoniaSituationPath); patchPhosphateSituation = GetNode <TextureRect>(PatchPhosphateSituationPath); rigiditySlider = GetNode <Slider>(RigiditySliderPath); invalidBarTexture = GD.Load <Texture>("res://assets/textures/gui/bevel/MpBarInvalid.png"); subractBarTexture = GD.Load <Texture>("res://assets/textures/gui/bevel/MpBarSubtract.png"); mapDrawer.OnSelectedPatchChanged = drawer => { UpdateShownPatchDetails(); }; atpProductionBar.SelectedType = SegmentedBar.Type.ATP; atpProductionBar.IsProduction = true; atpConsumptionBar.SelectedType = SegmentedBar.Type.ATP; // Fade out for that smooth satisfying transition TransitionManager.Instance.AddScreenFade(Fade.FadeType.FadeOut, 0.5f); TransitionManager.Instance.StartTransitions(null, string.Empty); }
public void ApplyData(object data) { SaveData casted = (SaveData)data; GD.Print("deserialized gun: ", casted.testInt); }
public virtual void EnterState(Player player) { GD.Print("EnterState"); }
public virtual void ExitState(Player player) { GD.Print("ExitState"); }
private void Stop() { vel = Vector3.Zero; timerMove.WaitTime = (float)GD.RandRange(1.5, 4); timerMove.Start(); }
public virtual void Update(Player player, float delta) { GD.Print("Update"); }
public override void _Ready() { jellyAtomPacked = GD.Load <PackedScene>("res://tests/thibault/jelly_home_made/JellyAtom.tscn"); UpdateRect(); //Engine.TimeScale = 0.5f; }
public void Print(Score @struct) => GD.Print("Score: {0}, Streak: {1}", @struct.Points, @struct.Streak);
public void Print() { GD.Print($"points: {this.Points}, streak: {this.Streak}"); }
// Declare member variables here. Examples: // private int a = 2; // private string b = "text"; // Called when the node enters the scene tree for the first time. public override void _Ready() { var parent = GetParent(); if (parent == null) { return; } Texture texture = null; switch (parent.Name) { case SolarSystemNames.AlphaCentauri: texture = GD.Load("res://Sandbox/Sprites/SpaceObjects/CreamVioletPlanet.png") as Texture; break; case SolarSystemNames.Aquarii: texture = GD.Load("res://Sandbox/Sprites/SpaceObjects/Planet103.png") as Texture; break; case SolarSystemNames.BarnardsStar: texture = GD.Load("res://Sandbox/Sprites/SpaceObjects/Sun.png") as Texture; break; case SolarSystemNames.Cygni: texture = GD.Load("res://Sandbox/Sprites/SpaceObjects/Planet104.png") as Texture; break; case SolarSystemNames.Groombridge: texture = GD.Load("res://Sandbox/Sprites/SpaceObjects/OrangePlanet.png") as Texture; break; case SolarSystemNames.Indi: texture = GD.Load("res://Sandbox/Sprites/SpaceObjects/IcePlanet.png") as Texture; break; case SolarSystemNames.Kepler438: texture = GD.Load("res://Sandbox/Sprites/SpaceObjects/FrostPlanet.png") as Texture; break; case SolarSystemNames.Kruger: texture = GD.Load("res://Sandbox/Sprites/SpaceObjects/StormPlanet.png") as Texture; break; case SolarSystemNames.Luyten: texture = GD.Load("res://Sandbox/Sprites/SpaceObjects/CyanPlanet.png") as Texture; break; case SolarSystemNames.Quaid: texture = GD.Load("res://Sandbox/Sprites/SpaceObjects/RedLinesPlanet.png") as Texture; break; case SolarSystemNames.Sirius: texture = GD.Load("res://Sandbox/Sprites/SpaceObjects/PurplePlanet.png") as Texture; break; case SolarSystemNames.Sol: texture = GD.Load("res://Sandbox/Sprites/SpaceObjects/EarthLikePlanet.png") as Texture; break; case SolarSystemNames.Wolf359: texture = GD.Load("res://Sandbox/Sprites/SpaceObjects/CyanPlanet1.png") as Texture; break; case SolarSystemNames.Yennefer: texture = GD.Load("res://Sandbox/Sprites/SpaceObjects/Planet082.png") as Texture; break; default: GD.PrintErr("Unrecognized parent name"); break; } if (texture != null) { //GD.Print("Updating GalaxyMapNode sprite for parent: " + parent.Name); this.Texture = texture; } }
public Projectile() { GD.Print($"Projectile {Name} crated"); }
private void WriteOrganelleProcessList(List <ProcessSpeedInformation> processList, VBoxContainer targetElement) { // Remove previous process list if (targetElement.GetChildCount() > 0) { foreach (Node children in targetElement.GetChildren()) { children.QueueFree(); } } if (processList == null) { var noProcesslabel = new Label(); noProcesslabel.Text = "No processes"; targetElement.AddChild(noProcesslabel); return; } foreach (var process in processList) { var processContainer = new VBoxContainer(); targetElement.AddChild(processContainer); var processTitle = new Label(); processTitle.AddColorOverride("font_color", new Color(1.0f, 0.84f, 0.0f)); processTitle.Text = process.Process.Name; processContainer.AddChild(processTitle); var processBody = new HBoxContainer(); bool usePlus; if (process.OtherInputs.Count == 0) { // Just environmental stuff usePlus = true; } else { // Something turns into something else, uses the arrow notation usePlus = false; // Show the inputs // TODO: add commas or maybe pluses for multiple inputs foreach (var key in process.OtherInputs.Keys) { var inputCompound = process.OtherInputs[key]; var amountLabel = new Label(); amountLabel.Text = Math.Round(inputCompound.Amount, 3) + " "; processBody.AddChild(amountLabel); processBody.AddChild(GUICommon.Instance.CreateCompoundIcon(inputCompound.Compound.Name)); } // And the arrow var arrow = new TextureRect(); arrow.Expand = true; arrow.RectMinSize = new Vector2(20, 20); arrow.Texture = GD.Load <Texture>("res://assets/textures/gui/bevel/WhiteArrow.png"); processBody.AddChild(arrow); } // Outputs of the process. It's assumed that every process has outputs foreach (var key in process.Outputs.Keys) { var outputCompound = process.Outputs[key]; var amountLabel = new Label(); var stringBuilder = new StringBuilder(string.Empty, 150); // Changes process title and process# to red if process has 0 output if (outputCompound.Amount == 0) { processTitle.AddColorOverride("font_color", new Color(1.0f, 0.1f, 0.1f)); amountLabel.AddColorOverride("font_color", new Color(1.0f, 0.1f, 0.1f)); } if (usePlus) { stringBuilder.Append(outputCompound.Amount >= 0 ? "+" : string.Empty); } stringBuilder.Append(Math.Round(outputCompound.Amount, 3) + " "); amountLabel.Text = stringBuilder.ToString(); processBody.AddChild(amountLabel); processBody.AddChild(GUICommon.Instance.CreateCompoundIcon(outputCompound.Compound.Name)); } var perSecondLabel = new Label(); perSecondLabel.Text = "/second"; processBody.AddChild(perSecondLabel); // Environment conditions if (process.EnvironmentInputs.Count > 0) { var atSymbol = new Label(); atSymbol.Text = "@"; atSymbol.RectMinSize = new Vector2(30, 20); atSymbol.Align = Label.AlignEnum.Center; processBody.AddChild(atSymbol); var first = true; foreach (var key in process.EnvironmentInputs.Keys) { if (!first) { var commaLabel = new Label(); commaLabel.Text = ", "; processBody.AddChild(commaLabel); } first = false; var environmentCompound = process.EnvironmentInputs[key]; // To percentage var percentageLabel = new Label(); // TODO: sunlight needs some special handling (it used to say the lux amount) percentageLabel.Text = Math.Round(environmentCompound.AvailableAmount * 100, 1) + "%"; processBody.AddChild(percentageLabel); processBody.AddChild(GUICommon.Instance.CreateCompoundIcon(environmentCompound.Compound.Name)); } } processContainer.AddChild(processBody); } }
//This is used as a delegate that executes every sample frame. void ClockEvent(int channel) { //FIXME: restore the original early exit when not on a tick. if (channel == channels.Length - 1) { // if (frameCounter >= FramesPerEventCheck) // { // frameCounter = 0; //Reset the amount of frames needed to check for events again. var events = Clock.CheckForEvents(sequence) ?? System.Linq.Enumerable.Empty <MidiSharp.Events.MidiEvent>(); // Handle events here foreach (MidiSharp.Events.MidiEvent midiEvent in events) { //Determine event type and handle accordingly switch (midiEvent) { //Meta events. TODO case TempoMetaMidiEvent ev: Clock.SetTempo(ev.Value, sequence.TicksPerBeatOrFrame); GD.Print("BPM: ", 60000000.0 / (ev.Value)); break; //Voice channel events. TODO case ControllerVoiceMidiEvent ev: //Continuous controller value. Switch again. switch ((Controller)ev.Number) { case Controller.VolumeCoarse: channels[ev.Channel].volume = (float)ev.Value / 127.0f; break; case Controller.PanPositionCoarse: channels[ev.Channel].Pan = (float)ev.Value / 63.5f - 1; break; } break; case ProgramChangeVoiceMidiEvent ev: channels[ev.Channel].midi_program = ev.Number; channels[ev.Channel].patch = patchBank[ev.Number]; break; //Note events case OnNoteVoiceMidiEvent ev: //note: Can be more specific with "when ev" keyword if (ev.Velocity == 0) //Oh no! This is an Off event in disguise! { channels[ev.Channel].TurnOffNote(ev.Note); break; } //FIXME: When changing the buffer fill algorithm to a parallized one requesting sample batches, this won't work anymore // Because Channel will be requesting an entire buffer from Patch at once and clock events won't be able to execute in the middle. // Precalculate for each channel the frame that notes should be activated, as well as all other audio state changes...... // This probably includes CCs...... AddNote(ev.Channel, ev.Note, ev.Velocity); break; case OffNoteVoiceMidiEvent ev: channels[ev.Channel].TurnOffNote(ev.Note); break; default: break; } //End switch } // End foreach } //End frame counter event check //Don't iterate the frame counter unless we're sure all the channels have had a chance to process. if (channel == channels.Length - 1) { Clock.Iterate(); frameCounter++; } }
public void Draw() { bool[] processed = new bool[8]; foreach (CubeNode nd in Vertices()) { if (debug) { GD.Print(nd.x, " ", nd.y, " ", nd.z, " ", nd.IsIn()); } if (processed[nd.Index()]) { continue; } HashSet <CubeNode> connected = nd.AllConnected(); if (debug) { GD.Print(connected.Count); } if (connected.Count == 1) { if (debug) { GD.Print("Single"); } meshBuilder.AddTriangle(cubeIndex, nd, 0, nd, 1, nd, 2); processed[nd.Index()] = true; continue; } if (connected.Count == 2) { IEnumerator <CubeNode> e = connected.GetEnumerator(); e.MoveNext(); CubeNode n1 = e.Current; e.MoveNext(); CubeNode n2 = e.Current; int nbAxis = n1.WhichAxis(n2); meshBuilder.AddTriangle(cubeIndex, n1, (nbAxis + 1) % 3, n2, (nbAxis + 1) % 3, n2, (nbAxis + 2) % 3); meshBuilder.AddTriangle(cubeIndex, n2, (nbAxis + 2) % 3, n1, (nbAxis + 2) % 3, n1, (nbAxis + 1) % 3); if (debug) { GD.Print("Double"); } processed[n1.Index()] = true; processed[n2.Index()] = true; continue; } if (connected.Count == 3) { // find middle elem CubeNode md = nd; foreach (CubeNode n in connected) { if (n.CountNbs() == 2) { md = n; } } int axis = 0; for (int i = 0; i < 3; i++) { if (md.Nb(i).IsIn() != md.IsIn()) { axis = i; } } CubeNode nb1 = md.Nb((axis + 1) % 3); CubeNode nb2 = md.Nb((axis + 2) % 3); Vector3 intermediate1 = nb1.Intermediate(axis); Vector3 intermediate2 = nb2.Intermediate(axis); // parallel meshBuilder.AddTriangle(cubeIndex, md, axis, nb1, axis, nb2, axis); // part 1 meshBuilder.AddTriangle(cubeIndex, nb1, axis, nb2, axis, nb1, (axis + 2) % 3); // part 2 meshBuilder.AddTriangle(cubeIndex, nb1, (axis + 2) % 3, nb2, (axis + 1) % 3, nb2, axis); if (debug) { GD.Print("Trio"); } processed[md.Index()] = true; processed[nb1.Index()] = true; processed[nb2.Index()] = true; continue; } if (connected.Count > 4) { foreach (CubeNode c in connected) { processed[c.Index()] = true; } continue; } if (!nd.IsIn()) { foreach (CubeNode c in connected) { processed[c.Index()] = true; } continue; } // connected.Count is 4 // square, tetra or line CubeNode mid = nd; bool tetra = false; foreach (CubeNode c in connected) { if (c.CountNbs() == 3) { // tetra mid = c; tetra = true; } } if (tetra) { CubeNode n0 = mid.Nb(0); CubeNode n1 = mid.Nb(1); CubeNode n2 = mid.Nb(2); meshBuilder.AddTriangle(cubeIndex, n0, 1, n1, 0, n1, 2); meshBuilder.AddTriangle(cubeIndex, n0, 1, n1, 2, n0, 2); meshBuilder.AddTriangle(cubeIndex, n1, 2, n0, 2, n2, 1); meshBuilder.AddTriangle(cubeIndex, n0, 2, n2, 1, n2, 0); if (debug) { GD.Print("Tetra"); } processed[mid.Index()] = true; processed[n0.Index()] = true; processed[n1.Index()] = true; processed[n2.Index()] = true; continue; } bool sameX = true, sameY = true, sameZ = true; foreach (CubeNode n in connected) { if (n.x != nd.x) { sameX = false; } if (n.y != nd.y) { sameY = false; } if (n.z != nd.z) { sameZ = false; } } if (sameX || sameY || sameZ) { int axis = 0; if (sameY) { axis = 1; } if (sameZ) { axis = 2; } // plane meshBuilder.AddTriangle(cubeIndex, nd, axis, nd.Nb((axis + 1) % 3), axis, nd.Nb((axis + 2) % 3), axis); meshBuilder.AddTriangle(cubeIndex, nd.Nb((axis + 1) % 3), axis, nd.Nb((axis + 2) % 3), axis, nd.Nb((axis + 1) % 3).Nb((axis + 2) % 3), axis); if (debug) { GD.Print("Plane"); } foreach (CubeNode c in connected) { processed[c.Index()] = true; } continue; } // line CubeNode l1 = nd, l2 = nd, l3 = nd, l4 = nd; foreach (CubeNode n in connected) { if (n.CountNbs() == 1) { l1 = n; } } foreach (CubeNode n in connected) { if (l1.WhichAxis(n) != -1) { l2 = n; } } foreach (CubeNode n in connected) { if (n.Index() != l1.Index() && l2.WhichAxis(n) != -1) { l3 = n; } } foreach (CubeNode n in connected) { if (n.Index() != l2.Index() && l3.WhichAxis(n) != -1) { l4 = n; } } int axis1 = l1.WhichAxis(l2); int axis2 = l2.WhichAxis(l3); int axis3 = l3.WhichAxis(l4); meshBuilder.AddTriangle(cubeIndex, l1, axis3, l2, axis3, l1, axis2); meshBuilder.AddTriangle(cubeIndex, l1, axis2, l3, axis1, l4, axis1); meshBuilder.AddTriangle(cubeIndex, l2, axis3, l1, axis2, l4, axis1); meshBuilder.AddTriangle(cubeIndex, l2, axis3, l4, axis1, l4, axis2); if (debug) { GD.Print("Line"); } foreach (CubeNode c in connected) { processed[c.Index()] = true; } continue; } // geometry.End(); }
private void _on_IconSearch_file_selected(string path) { iconPath = path; GetNode <Sprite>("IconLabel/IconSprite").Texture = GD.Load(path) as Godot.Texture; }
public void ApplyResults(GameWorld world, bool skipMutations) { foreach (var entry in results) { if (entry.Value.NewlyCreated != null) { world.RegisterAutoEvoCreatedSpecies(entry.Key); } if (!skipMutations && entry.Value.MutatedProperties != null) { entry.Key.ApplyMutation(entry.Value.MutatedProperties); } foreach (var populationEntry in entry.Value.NewPopulationInPatches) { var patch = world.Map.GetPatch(populationEntry.Key.ID); if (patch != null) { // We ignore the return value as population results are added for all existing patches for all // species (if the species is not in the patch the population is 0 in the results) patch.UpdateSpeciesPopulation(entry.Key, populationEntry.Value); } else { GD.PrintErr("RunResults has population of a species for invalid patch"); } } if (entry.Value.NewlyCreated != null) { // If we split off from a species that didn't take a population hit, we need to register ourselves bool register = false; if (entry.Value.SplitFrom == null) { register = true; } else if (results[entry.Value.SplitFrom].SplitOff != entry.Key) { register = true; } if (register) { foreach (var populationEntry in entry.Value.NewPopulationInPatches) { var patch = world.Map.GetPatch(populationEntry.Key.ID); if (patch?.AddSpecies(entry.Key, populationEntry.Value) != true) { GD.PrintErr( "RunResults has new species with invalid patch or it was failed to be added"); } } } } foreach (var spreadEntry in entry.Value.SpreadToPatches) { var from = world.Map.GetPatch(spreadEntry.From.ID); var to = world.Map.GetPatch(spreadEntry.To.ID); if (from == null || to == null) { GD.PrintErr("RunResults has a species migration to/from an invalid patch"); continue; } long remainingPopulation = from.GetSpeciesPopulation(entry.Key) - spreadEntry.Population; long newPopulation = to.GetSpeciesPopulation(entry.Key) + spreadEntry.Population; if (!from.UpdateSpeciesPopulation(entry.Key, remainingPopulation)) { GD.PrintErr("RunResults failed to update population for a species in a patch it moved from"); } if (!to.UpdateSpeciesPopulation(entry.Key, newPopulation)) { if (!to.AddSpecies(entry.Key, newPopulation)) { GD.PrintErr("RunResults failed to update population and also add species failed on " + "migration target patch"); } } } if (entry.Value.SplitOff != null) { if (entry.Value.SplitOffPatches != null) { // Set populations to 0 for the patches that moved and replace the results for the split off // species with those foreach (var splitOffPatch in entry.Value.SplitOffPatches) { var patch = world.Map.GetPatch(splitOffPatch.ID); if (patch == null) { GD.PrintErr("RunResults has a species split in an invalid patch"); continue; } var population = patch.GetSpeciesPopulation(entry.Key); if (population <= 0) { continue; } if (!patch.UpdateSpeciesPopulation(entry.Key, 0)) { GD.PrintErr("RunResults failed to update population for a species that split"); } if (!patch.AddSpecies(entry.Value.SplitOff, population)) { GD.PrintErr("RunResults failed to add species to patch that split off"); } } } else { GD.PrintErr("List of split off patches is null, can't actually perform the split"); } } } }
public void RefreshData(int id) { Godot.Collections.Dictionary jsonDictionary = this.GetParent().GetParent().Call("ReadData", "Class") as Godot.Collections.Dictionary; Godot.Collections.Dictionary classData = jsonDictionary["class" + id] as Godot.Collections.Dictionary; Godot.Collections.Dictionary classSkillList = classData["skill_list"] as Godot.Collections.Dictionary; jsonDictionary = this.GetParent().GetParent().Call("ReadData", "System") as Godot.Collections.Dictionary; Godot.Collections.Dictionary systemStatsData = jsonDictionary["stats"] as Godot.Collections.Dictionary; jsonDictionary = this.GetParent().GetParent().Call("ReadData", "Skill") as Godot.Collections.Dictionary; GetNode <LineEdit>("NameLabel/NameText").Text = classData["name"] as string; string icon = classData["icon"] as string; if (icon != "") { GetNode <Sprite>("IconLabel/IconSprite").Texture = GD.Load(classData["icon"] as string) as Godot.Texture; } GetNode <LineEdit>("ExpLabel/ExpText").Text = classData["experience"] as string; GetNode <ItemList>("StatsLabel/StatsContainer/DataContainer/StatsListContainer/StatsList").Clear(); GetNode <ItemList>("StatsLabel/StatsContainer/DataContainer/FormulaListContainer/FormulaList").Clear(); for (int i = 0; i < systemStatsData.Count; i++) { string statName = systemStatsData[i.ToString()] as string; Godot.Collections.Dictionary classStatFormula = classData["stat_list"] as Godot.Collections.Dictionary; string statFormula = ""; if (classStatFormula.Contains(statName)) { statFormula = classStatFormula[statName].ToString(); } else { statFormula = "level * 5"; } GetNode <ItemList>("StatsLabel/StatsContainer/DataContainer/StatsListContainer/StatsList").AddItem(statName); GetNode <ItemList>("StatsLabel/StatsContainer/DataContainer/FormulaListContainer/FormulaList").AddItem(statFormula); } GetNode <ItemList>("SkillLabel/SkillContainer/HBoxContainer/SkillListContainer/SkillList").Clear(); GetNode <ItemList>("SkillLabel/SkillContainer/HBoxContainer/SkillLevelContainer/SkillLevelList").Clear(); skillListArray.Clear(); foreach (string element in classSkillList.Keys) { skillListArray.Add(element); Godot.Collections.Dictionary skillData = jsonDictionary["skill" + element] as Godot.Collections.Dictionary; string skillName = skillData["name"] as string; GetNode <ItemList>("SkillLabel/SkillContainer/HBoxContainer/SkillListContainer/SkillList").AddItem(skillName); string level = Convert.ToString(classSkillList[element as string]); GetNode <ItemList>("SkillLabel/SkillContainer/HBoxContainer/SkillLevelContainer/SkillLevelList").AddItem(level); } GetNode <OptionButton>("SkillLabel/AddSkill/SkillLabel/OptionButton").Clear(); foreach (string element in jsonDictionary.Keys) { Godot.Collections.Dictionary skillData = jsonDictionary[element] as Godot.Collections.Dictionary; string name = Convert.ToString(skillData["name"]); GetNode <OptionButton>("SkillLabel/AddSkill/SkillLabel/OptionButton").AddItem(name); GetNode <OptionButton>("SkillLabel/AddSkill/SkillLabel/OptionButton").Select(0); } if (classData.Contains("effects") == true) { this.ClearEffectList(); Godot.Collections.Array effectList = classData["effects"] as Godot.Collections.Array; foreach (Godot.Collections.Dictionary effect in effectList) { this.AddEffectList(effect["name"].ToString(), Convert.ToInt32(effect["data_id"]), effect["value1"].ToString(), effect["value2"].ToString()); } } }
// Declare member variables here. Examples: // private int a = 2; // private string b = "text"; // Called when the node enters the scene tree for the first time. public override void _Ready() { GD.Print(GetOwnerOrNull <Position3D>()); }
// Called when the node enters the scene tree for the first time. public override void _Ready() { GD.Print("PlayerTrail::_Ready()"); }
private void _on_Square_pressed() { GD.Print(55); EmitSignal("CustomSignal", this, turnCount); }
public void OnSideMouseEnteredBottom() { GetNode <TextureRect>("ColorRect/TextureRect").Texture = GD.Load("res://Assets/HUD/Side/hoverBottom.svg") as Texture; OnButtonMouseEnter(); }
private void PushPressed() { GD.Print("Push file"); }
public void OnSideMouseExited() { GetNode <TextureRect>("ColorRect/TextureRect").Texture = GD.Load("res://Assets/HUD/Side/normal.svg") as Texture; }
public void SelectItem(int index) { GD.Print("Item " + index + " selected"); itemSelected = index; UpdateItemInfo(); }
public static PackedScene LoadChunkScene() { return(GD.Load <PackedScene>("res://src/microbe_stage/FloatingChunk.tscn")); }