mirror of
https://github.com/Ellpeck/TinyLifeWeb.git
synced 2024-12-03 15:08:34 +01:00
Compare commits
3 commits
47c94a224b
...
50c9ee759b
Author | SHA1 | Date | |
---|---|---|---|
50c9ee759b | |||
09cc2dc91e | |||
1acf111a1c |
6 changed files with 120 additions and 3 deletions
|
@ -1,12 +1,13 @@
|
|||
# Creating Textures
|
||||
When creating textures, either for custom mods or to change the game's default textures, there are several things that you will have to look out for. This article provides some guidelines and explanations. Note that this article is not exhaustive, so don't hesitate to [let us know](https://link.tinylifegame.com/discordweb) if there's anything you're confused by!
|
||||
|
||||
## General Notes
|
||||
## Composition and Colors
|
||||
### General Notes
|
||||
- Items that should be able to have color schemes applied to them in games should use a grayscale texture. The individual colors will then be applied to the grayscale texture when drawing.
|
||||
- When making a mod, the layout, size or positioning of custom texture regions generally doesn't matter. There are some exceptions to this, which will be noted in this article.
|
||||
- Items that should be able to have multiple distinct color schemes applied (like a table with a stone surface but wooden legs) need to be split up into multiple layers, with each layer being colored by its corresponding color scheme. These layers need to be laid out **horizontally**, with the `n`th layer of the item being placed `n * width` pixels to the right of the base layer's position.
|
||||
|
||||
## Furniture
|
||||
### Furniture
|
||||
- Furniture items generally have four distinct directions they can be placed in if they're more complex, or just one or two if they have symmetry in one or both axes.
|
||||
- Layers (see general notes) can also be used to determine which parts of a furniture item will be occluded by Tinies and which won't. This is useful, for example, for the backrests of chairs, which should be drawn above a Tiny when looking at them from behind.
|
||||
|
||||
|
@ -14,7 +15,7 @@ When creating textures, either for custom mods or to change the game's default t
|
|||
|
||||
![](../media/counters.png)
|
||||
|
||||
## Clothes
|
||||
### Clothes
|
||||
- Clothes have multiple poses that they have to be compatible with, some of which have multiple animation frames. The ordering and positioning of these frames cannot be changed, so it's best to use the reference textures below for creating news clothes and hairstyles.
|
||||
- Clothes have four rotations, which are laid out in a Right-Down-Left-Up fashion.
|
||||
- When layers are laid out for clothes, each layer should contain the Right-Down-Left-Up ordering before the next layer is started.
|
||||
|
@ -32,3 +33,10 @@ When creating textures, either for custom mods or to change the game's default t
|
|||
- The most up-to-date version of the game's color schemes can be found in the [ColorScheme class](xref:TinyLife.Utilities.ColorScheme).
|
||||
|
||||
![](../media/color_schemes.png)
|
||||
|
||||
## Isometric Layout
|
||||
Community member [Gindew](https://linktr.ee/redgindew) has created a template that gives guidance on the isometric style that the game uses. You can download it as [an image](../media/iso_layout.png) or as [an Aseprite file](../media/iso_layout.aseprite).
|
||||
|
||||
Here is an enlarged version of the template so you can get a better look:
|
||||
|
||||
![](../media/iso_layout_large.png)
|
||||
|
|
107
docs/articles/sample_code.md
Normal file
107
docs/articles/sample_code.md
Normal file
|
@ -0,0 +1,107 @@
|
|||
# Sample Code for Modders
|
||||
This page collects various sample code snippets intended to help modders get started with more complex pieces of code like furniture that produces light, social actions, and more.
|
||||
|
||||
If you'd like for more examples of specific content pieces to be added to this list, don't hesitate to [ask on the Discord](https://link.tinylifegame.com/discordweb) or [open an issue](https://github.com/Ellpeck/TinyLifeWeb/issues) about it.
|
||||
|
||||
**Please note that, due to the game being closed source, the code displayed here is only intended as an example and not meant to be copied directly.**
|
||||
|
||||
## Furniture
|
||||
|
||||
### Furniture With Light
|
||||
The Sleek Floor Lamp item's code:
|
||||
```cs
|
||||
public static readonly FurnitureType SimpleLamp = FurnitureType.Register(new TypeSettings("SimpleLamp", new Point(1, 1), ObjectCategory.Lamp, 80, ColorScheme.Grays, ColorScheme.MutedPastels) {
|
||||
ElectricityRating = 1,
|
||||
LightSettings = {
|
||||
CreateLights = f => [
|
||||
new Light(f.Map, f.Position, f.Floor, Light.CircleTexture, new Vector2(6, 8), Color.LightYellow) {
|
||||
VisualWorldOffset = new Vector2(0.5F)
|
||||
}
|
||||
]
|
||||
}
|
||||
});
|
||||
```
|
||||
|
||||
The Paper Lantern Fairy Lights item's code, which is a bit more complex since they're attached to walls:
|
||||
```cs
|
||||
public static readonly FurnitureType BulbFairyLights = FurnitureType.Register(new TypeSettings("BulbFairyLights", new Point(1, 1), ObjectCategory.Lamp | ObjectCategory.WallHanging | ObjectCategory.NonColliding | ObjectCategory.CanCoverWindow, 25, ColorScheme.White) {
|
||||
DecorativeRating = _ => 1,
|
||||
Tab = Tab.Decoration | Tab.Lighting,
|
||||
LightSettings = {
|
||||
CreateLights = f => f.AttachedWall == null ? [] : [
|
||||
new Light(f.Map, f.Position, f.Floor, Light.CircleTexture, new Vector2(1), Color.LightGoldenrodYellow) {
|
||||
PositionOffset = WallLike.GetCenterBottomPos(f.AttachedWall.Positions[0], f.AttachedWall.Positions[1]) - f.Position,
|
||||
VisualWorldOffset = new Vector2(1.6F),
|
||||
Rotation = MathHelper.ToRadians(25 * (WallLike.IsVerticalForCamera(WallLike.IsVertical(f.AttachedWall.Positions[0], f.AttachedWall.Positions[1])) ? -1 : 1))
|
||||
}
|
||||
]
|
||||
}
|
||||
});
|
||||
```
|
||||
|
||||
## Actions
|
||||
|
||||
### Simple Social Actions (Talk Actions)
|
||||
The `TalkAction` class supplies a set of factory methods that allow easily creating social actions between Tinies which generally only involve talking and have a chance to succeed or fail, yielding friendship or romance gains or losses in return.
|
||||
|
||||
This is the most basic social action in the game, the Chat action:
|
||||
```cs
|
||||
public static readonly ActionType Talk = ActionType.Register(TalkAction.Create("Friendly/Talk", _ => 90, new TalkSettings {
|
||||
GoBadlyChance = _ => 0.01F, TalkMinutes = 10, FriendshipGain = _ => 1600,
|
||||
EmoteCategory = EmoteCategory.General, SpeakStyle = SpeakStyle.Neutral | SpeakStyle.Happy | SpeakStyle.Questioning
|
||||
}));
|
||||
```
|
||||
|
||||
Here is an example of a more complex talk action:
|
||||
```cs
|
||||
public static readonly ActionType AskAboutParenting = ActionType.Register(TalkAction.Create("Friendly/AskAboutParenting", _ => 50, new TalkSettings {
|
||||
FriendshipGain = _ => 3000, GoBadlyChance = _ => 0.02F, TalkMinutes = 15,
|
||||
EmoteCategory = EmoteCategory.General | EmoteCategory.Travel, SpeakStyle = SpeakStyle.Questioning | SpeakStyle.Confused | SpeakStyle.Scared,
|
||||
PartnerSpeakStyle = SpeakStyle.Confident | SpeakStyle.Affirmative | SpeakStyle.Happy | SpeakStyle.Neutral,
|
||||
Settings = {
|
||||
RequiredAges = AgeGroup.AdultOrOlder, RequiredPartnerAges = AgeGroup.AdultOrOlder,
|
||||
CanExecute = (i, _) => ActionType.Partner(i)?.Relationships.Any(r => r.Genealogy == GenealogyType.Parent) == true ? CanExecuteResult.Valid : CanExecuteResult.Hidden
|
||||
}
|
||||
}));
|
||||
```
|
||||
|
||||
## Life Goals (and Daily Tasks for Jobs)
|
||||
Here are some examples of how the `GoalSet` system can be used:
|
||||
```cs
|
||||
// execute the research business plans action for half an hour
|
||||
AutoGoalInfo.Timed<Action>("ResearchBusinessPlans", TimeSpan.FromMinutes(30), a => a.Type == ActionType.ResearchBusinessPlans, GoalTrigger.ActionUpdate)
|
||||
|
||||
// complete the read action 10 times
|
||||
AutoGoalInfo.Amount<ReadAction>("Read10Times", 10, triggers: GoalTrigger.ActionCompleted))
|
||||
|
||||
// talk to 10 distinct people
|
||||
AutoGoalInfo.Distinct<TalkAction>("TalkTo10People", 10, a => a.Partner.Id.ToString(), triggers: GoalTrigger.ActionCompleted)
|
||||
|
||||
// earning tb3000 in any way
|
||||
AutoGoalInfo.Amount<object>("Earn3000TinyBucks", 3000, triggers: GoalTrigger.EarnMoney)
|
||||
|
||||
// earning money through creating the painting furniture specifically
|
||||
AutoGoalInfo.Amount<Painting>("Earn1000FromPaintings", 1000, triggers: GoalTrigger.EarnMoney)
|
||||
|
||||
// earning money through a book project specifically
|
||||
AutoGoalInfo.Conditioned<Project>("EarnRoyalties10Books", p => p.Person.Projects.Count(pr => pr.Type == "Book" && pr.DailyPay > 0) >= 10, GoalTrigger.EarnMoney)
|
||||
```
|
||||
|
||||
Here is the full code for the game's Household Hero life goal as a reference:
|
||||
```cs
|
||||
public static readonly LifeGoal HouseholdHero = LifeGoal.Register(new LifeGoal("HouseholdHero", PersonalityType.HouseholdHero,
|
||||
new GoalSetInfo(
|
||||
AutoGoalInfo.Amount<Action>("Clean5Objects", 5, a => a.Type == ActionType.Clean || a.Type == ActionType.CleanDish, GoalTrigger.ActionCompleted),
|
||||
AutoGoalInfo.Conditioned<Person>("CleaningLevel3", p => p.HasSkillLevel(SkillType.Cleaning, 3), GoalTrigger.PersonUpdate)),
|
||||
new GoalSetInfo(
|
||||
AutoGoalInfo.Amount<RepairAction>("Repair3Objects", 3, triggers: GoalTrigger.ActionCompleted),
|
||||
AutoGoalInfo.Conditioned<Person>("RepairLevel5", p => p.HasSkillLevel(SkillType.Repair, 5), GoalTrigger.PersonUpdate)),
|
||||
new GoalSetInfo(
|
||||
AutoGoalInfo.Conditioned<Person>("CleaningLevel5", p => p.HasSkillLevel(SkillType.Cleaning, 5), GoalTrigger.PersonUpdate),
|
||||
AutoGoalInfo.Conditioned<Person>("RepairLevel10", p => p.HasSkillLevel(SkillType.Repair, 10), GoalTrigger.PersonUpdate))) {
|
||||
AllowedAges = AgeGroup.OlderThanChild
|
||||
});
|
||||
});
|
||||
```
|
||||
|
||||
For more info on goal sets and how they can be used for life goals and job daily tasks, see [this Discord discussion](https://discord.com/channels/181435613147430913/981562300592947220/1281723775586406411).
|
|
@ -13,6 +13,8 @@
|
|||
- name: Modding
|
||||
- name: Modding Basics
|
||||
href: mod_basics.md
|
||||
- name: Sample Code for Modders
|
||||
href: sample_code.md
|
||||
- name: Creating Textures
|
||||
href: creating_textures.md
|
||||
|
||||
|
|
BIN
docs/media/iso_layout.aseprite
Normal file
BIN
docs/media/iso_layout.aseprite
Normal file
Binary file not shown.
BIN
docs/media/iso_layout.png
Normal file
BIN
docs/media/iso_layout.png
Normal file
Binary file not shown.
After Width: | Height: | Size: 2.5 KiB |
BIN
docs/media/iso_layout_large.png
Normal file
BIN
docs/media/iso_layout_large.png
Normal file
Binary file not shown.
After Width: | Height: | Size: 3.4 KiB |
Loading…
Reference in a new issue