Skip to content

Commit

Permalink
Merge branch 'master' into newpatcher
Browse files Browse the repository at this point in the history
  • Loading branch information
Chicken-Bones committed Mar 31, 2019
2 parents 9777b27 + d476f1b commit 38afdbb
Show file tree
Hide file tree
Showing 668 changed files with 26,236 additions and 21,309 deletions.
78 changes: 76 additions & 2 deletions .editorconfig
Original file line number Diff line number Diff line change
@@ -1,9 +1,83 @@
root = true

[*.cs]

#Core editorconfig formatting - indentation

#use hard tabs for indentation
indent_style = tab
indent_size = 4
csharp_new_line_before_open_brace = all

#Formatting - new line options

#place else statements on a new line
csharp_new_line_before_else = true
#place catch statements on a new line
csharp_new_line_before_catch = true
csharp_new_line_before_finally = true
#place finally statements on a new line
csharp_new_line_before_finally = true

#require braces to be on a new line for types (Allman)
#everything else uses K&R
csharp_new_line_before_open_brace = types

#Formatting - spacing options

#require NO space between a cast and the value
csharp_space_after_cast = false
#require a space before the colon for bases or interfaces in a type declaration
csharp_space_after_colon_in_inheritance_clause = true
#require a space after a keyword in a control flow statement such as a for loop
csharp_space_after_keywords_in_control_flow_statements = true
#require a space before the colon for bases or interfaces in a type declaration
csharp_space_before_colon_in_inheritance_clause = true
#remove space within empty argument list parentheses
csharp_space_between_method_call_empty_parameter_list_parentheses = false
#remove space between method call name and opening parenthesis
csharp_space_between_method_call_name_and_opening_parenthesis = false
#do not place space characters after the opening parenthesis and before the closing parenthesis of a method call
csharp_space_between_method_call_parameter_list_parentheses = false
#remove space within empty parameter list parentheses for a method declaration
csharp_space_between_method_declaration_empty_parameter_list_parentheses = false
#place a space character after the opening parenthesis and before the closing parenthesis of a method declaration parameter list.
csharp_space_between_method_declaration_parameter_list_parentheses = false

#Formatting - wrapping options

#leave code block on single line
csharp_preserve_single_line_blocks = true
#leave statements and member declarations on the same line
csharp_preserve_single_line_statements = true

#Style - expression bodied member options

#prefer block bodies for constructors
csharp_style_expression_bodied_constructors = false:suggestion
#prefer expression-bodied members for methods when they will be a single line
csharp_style_expression_bodied_methods = when_on_single_line:suggestion
#prefer expression-bodied members for properties when they will be a single line
csharp_style_expression_bodied_properties = when_on_single_line:suggestion
#prefer expression-bodied members for indexers when they will be a single line
csharp_style_expression_bodied_indexers = when_on_single_line:suggestion
#prefer expression-bodied members for accessors when they will be a single line
csharp_style_expression_bodied_accessors = when_on_single_line:suggestion

#Style - expression level options

#prefer out variables to be declared inline in the argument list of a method call when possible
csharp_style_inlined_variable_declaration = true:suggestion
#prefer the language keyword for member access expressions, instead of the type name, for types that have a keyword to represent them
dotnet_style_predefined_type_for_member_access = true:suggestion

#Style - implicit and explicit types

#prefer explicit type over var to declare variables with built-in system types such as int
csharp_style_var_for_built_in_types = false:suggestion
#prefer explicit type over var when the type is already mentioned on the right-hand side of a declaration
csharp_style_var_when_type_is_apparent = true:none

[*.json]
indent_style = tab
# unfortuantely anything other than tab_width and indent_size 1 causes VS to become whimsical about indenting
indent_size = 1
tab_width = 1
14 changes: 11 additions & 3 deletions .gitignore
Original file line number Diff line number Diff line change
Expand Up @@ -12,6 +12,14 @@ installer2/*.class
installer2/*.jar
solutions/documentation/html
solutions/documentation/*.tmp
solutions/*.zip
solutions/.vs/**/*
solutions/.idea/**/*
solutions/**/*.zip
**/packages/
**/.vs/
**/.idea/
/test/Test Local/Players
/test/Test Local/Worlds
/test/Test Local/Logs
/test/Test Local/*.json
/test/Test Local/Mods
/test/Test Local/Mod Configs
/ExampleMod/Fonts/ExampleFont.xnb
24 changes: 17 additions & 7 deletions CONTRIBUTING.md
Original file line number Diff line number Diff line change
@@ -1,8 +1,14 @@
# Please review te following:
<!-- Maintainers, please do not edit this file without notifying the entire team. Thank you. -->

# Contribution guidelines
Before you create a pull request, please review the following guidelines for your contribution. Thank you in advance

## Your files use tab indendation (keep tabs) of size 4
In our project, we use tab indentation with a size of 4. Please have you settings abide this rule.

**Note**: Most editors support our provided [.editorconfig](https://github.com/blushiemagic/tModLoader/blob/master/.editorconfig) file, but certain functionalities (for example ones provided by plugins or addons) sometimes do not abide it. Please be careful and considerate with your actions!

`Visual Studio`
For Visual Studio:

Tools -> Options
Text Editor -> C# -> Tabs
Expand All @@ -14,7 +20,7 @@

![Example Visual Studio](https://i.imgur.com/1m8PLjn.png "Example Visual Studio")

`Notepad++`
For Notepad++:

Tools -> Preferences
Language -> C#
Expand All @@ -25,13 +31,17 @@
![Example notepad++](https://i.imgur.com/kbF0CMu.png "Example Notepad++")

## You edit in the tModLoader solution, the chance is very slim you need another one!
If you use another editor, please find these settings yourself and adjust them accordingly.

## You edit in the tModLoader solution
The chance is very slim that you need either of the other workspaces. If you did use them, **please be absolutely sure that you had to work in them**. If you are unsure, feel free to ask us before proposing your contribution.

To open this workspace, navigate to solutions/ and open tModLoader.sln

![Example solution](https://i.imgur.com/fLHUHgj.png "Example solution")

## You use our code patcher, so you only commit patches
In this project we work with our own code patcher. This is so that we do not publish the entire Terraria codebase (which isn't allowed), but we can still open-source our code.

To open our code patcher, run setup.bat from the main directory.
If you've worked in the tModLoader workspace, you press 'Diff tModLoader'
Expand All @@ -40,9 +50,9 @@ This will create new patches containing your changes in the patches/ folder
![Example patcher](https://i.imgur.com/Ltol24M.png "Example Patcher")

## You inspect your diffs (patches)

Before you commit or create a pull request, inspect your patches. Make sure nothing weird happened.
Do not auto format vanilla files when possible, it can break things.
Before you propose your contribution, inspect your patches. Please make sure that file formatting didn't mess up (this can happen with certain plugins and addons!)

![Diff example](https://i.imgur.com/jwu2GOG.png "Diff example")

## Helpful tips for contributions
Because tModLoader is a big project, we want to make sure contributions don't introduce unecessary code or code that is fundamentally flawed by design. But please don't be discouraged! If you are unsure about your contribution, still feel free to propose it and in your proposal ask us for feedback. If you do, please add "WIP:" in the title of your proposal. It is also helpful if you are specific about what you want feedback on. We will always try to provide you feedback in a passive and helpful manner.
45 changes: 16 additions & 29 deletions ExampleMod/Angle.cs
Original file line number Diff line number Diff line change
Expand Up @@ -2,54 +2,41 @@

namespace ExampleMod
{
//imported from my tAPI mod because it's useful
public struct Angle
{
public float Value;

public Angle(float angle)
{
public Angle(float angle) {
Value = angle;
float remainder = Value % (2f * (float)Math.PI);
float rotations = Value - remainder;
Value -= rotations;
if (Value < 0f)
{
if (Value < 0f) {
Value += 2f * (float)Math.PI;
}
}

public static Angle operator +(Angle a1, Angle a2)
{
return new Angle(a1.Value + a2.Value);
}
public static Angle operator +(Angle a1, Angle a2)
=> new Angle(a1.Value + a2.Value);

public static Angle operator -(Angle a1, Angle a2)
{
return new Angle(a1.Value - a2.Value);
}
public static Angle operator -(Angle a1, Angle a2)
=> new Angle(a1.Value - a2.Value);

public Angle Opposite()
{
return new Angle(Value + (float)Math.PI);
}
public Angle Opposite()
=> new Angle(Value + (float)Math.PI);

public bool ClockwiseFrom(Angle other)
{
if (other.Value >= (float)Math.PI)
{
return this.Value < other.Value && this.Value >= other.Opposite().Value;
public bool ClockwiseFrom(Angle other) {
if (other.Value >= (float)Math.PI) {
return Value < other.Value && Value >= other.Opposite().Value;
}
return this.Value < other.Value || this.Value >= other.Opposite().Value;
return Value < other.Value || Value >= other.Opposite().Value;
}

public bool Between(Angle cLimit, Angle ccLimit)
{
if (cLimit.Value < ccLimit.Value)
{
return this.Value >= cLimit.Value && this.Value <= ccLimit.Value;
public bool Between(Angle cLimit, Angle ccLimit) {
if (cLimit.Value < ccLimit.Value) {
return Value >= cLimit.Value && Value <= ccLimit.Value;
}
return this.Value >= cLimit.Value || this.Value <= ccLimit.Value;
return Value >= cLimit.Value || Value <= ccLimit.Value;
}
}
}
62 changes: 25 additions & 37 deletions ExampleMod/Backgrounds/ExampleSurfaceBgStyle.cs
Original file line number Diff line number Diff line change
Expand Up @@ -5,66 +5,54 @@ namespace ExampleMod.Backgrounds
{
public class ExampleSurfaceBgStyle : ModSurfaceBgStyle
{
public override bool ChooseBgStyle()
{
return !Main.gameMenu && Main.LocalPlayer.GetModPlayer<ExamplePlayer>(mod).ZoneExample;
public override bool ChooseBgStyle() {
return !Main.gameMenu && Main.LocalPlayer.GetModPlayer<ExamplePlayer>().ZoneExample;
}

// Use this to keep far Backgrounds like the mountains.
public override void ModifyFarFades(float[] fades, float transitionSpeed)
{
for (int i = 0; i < fades.Length; i++)
{
if (i == Slot)
{
public override void ModifyFarFades(float[] fades, float transitionSpeed) {
for (int i = 0; i < fades.Length; i++) {
if (i == Slot) {
fades[i] += transitionSpeed;
if (fades[i] > 1f)
{
if (fades[i] > 1f) {
fades[i] = 1f;
}
}
else
{
else {
fades[i] -= transitionSpeed;
if (fades[i] < 0f)
{
if (fades[i] < 0f) {
fades[i] = 0f;
}
}
}
}

public override int ChooseFarTexture()
{
public override int ChooseFarTexture() {
return mod.GetBackgroundSlot("Backgrounds/ExampleBiomeSurfaceFar");
}

static int SurfaceFrameCounter = 0;
static int SurfaceFrame = 0;
public override int ChooseMiddleTexture()
{
if (++SurfaceFrameCounter > 12)
{
private static int SurfaceFrameCounter;
private static int SurfaceFrame;
public override int ChooseMiddleTexture() {
if (++SurfaceFrameCounter > 12) {
SurfaceFrame = (SurfaceFrame + 1) % 4;
SurfaceFrameCounter = 0;
}
switch (SurfaceFrame)
{
case 0:
return mod.GetBackgroundSlot("Backgrounds/ExampleBiomeSurfaceMid0");
case 1:
return mod.GetBackgroundSlot("Backgrounds/ExampleBiomeSurfaceMid1");
case 2:
return mod.GetBackgroundSlot("Backgrounds/ExampleBiomeSurfaceMid2");
case 3:
return mod.GetBackgroundSlot("Backgrounds/ExampleBiomeSurfaceMid3");
default:
return -1;
switch (SurfaceFrame) {
case 0:
return mod.GetBackgroundSlot("Backgrounds/ExampleBiomeSurfaceMid0");
case 1:
return mod.GetBackgroundSlot("Backgrounds/ExampleBiomeSurfaceMid1");
case 2:
return mod.GetBackgroundSlot("Backgrounds/ExampleBiomeSurfaceMid2");
case 3:
return mod.GetBackgroundSlot("Backgrounds/ExampleBiomeSurfaceMid3");
default:
return -1;
}
}

public override int ChooseCloseTexture(ref float scale, ref double parallax, ref float a, ref float b)
{
public override int ChooseCloseTexture(ref float scale, ref double parallax, ref float a, ref float b) {
return mod.GetBackgroundSlot("Backgrounds/ExampleBiomeSurfaceClose");
}
}
Expand Down
8 changes: 3 additions & 5 deletions ExampleMod/Backgrounds/ExampleUgBgStyle.cs
Original file line number Diff line number Diff line change
Expand Up @@ -5,13 +5,11 @@ namespace ExampleMod.Backgrounds
{
public class ExampleUgBgStyle : ModUgBgStyle
{
public override bool ChooseBgStyle()
{
return Main.LocalPlayer.GetModPlayer<ExamplePlayer>(mod).ZoneExample;
public override bool ChooseBgStyle() {
return Main.LocalPlayer.GetModPlayer<ExamplePlayer>().ZoneExample;
}

public override void FillTextureArray(int[] textureSlots)
{
public override void FillTextureArray(int[] textureSlots) {
textureSlots[0] = mod.GetBackgroundSlot("Backgrounds/ExampleBiomeUG0");
textureSlots[1] = mod.GetBackgroundSlot("Backgrounds/ExampleBiomeUG1");
textureSlots[2] = mod.GetBackgroundSlot("Backgrounds/ExampleBiomeUG2");
Expand Down
15 changes: 5 additions & 10 deletions ExampleMod/Buffs/Blocky.cs
Original file line number Diff line number Diff line change
Expand Up @@ -5,8 +5,7 @@ namespace ExampleMod.Buffs
{
public class Blocky : ModBuff
{
public override void SetDefaults()
{
public override void SetDefaults() {
DisplayName.SetDefault("Blocky");
Description.SetDefault("Jumping power is increased");
Main.debuff[Type] = true;
Expand All @@ -15,16 +14,13 @@ public override void SetDefaults()
canBeCleared = false;
}

public override void Update(Player player, ref int buffIndex)
{
public override void Update(Player player, ref int buffIndex) {
ExamplePlayer p = player.GetModPlayer<ExamplePlayer>();

// We use blockyAccessoryPrevious here instead of blockyAccessory because UpdateBuffs happens before UpdateEquips but after ResetEffects.
if (player.townNPCs >= 1 && p.blockyAccessoryPrevious)
{
if (player.townNPCs >= 1 && p.blockyAccessoryPrevious) {
p.blockyPower = true;
if(Main.myPlayer == player.whoAmI && Main.time % 1000 == 0)
{
if (Main.myPlayer == player.whoAmI && Main.time % 1000 == 0) {
player.QuickSpawnItem(mod.ItemType<Items.Placeable.ExampleBlock>());
}
player.jumpSpeedBoost += 4.8f;
Expand All @@ -37,8 +33,7 @@ public override void Update(Player player, ref int buffIndex)
//player.statDefense += 3;
//player.moveSpeed += 0.05f;
}
else
{
else {
player.DelBuff(buffIndex);
buffIndex--;
}
Expand Down
Loading

0 comments on commit 38afdbb

Please sign in to comment.