major refactor + concept
- refactored the main player controller script into smaller components for readability - refactored the file structure and added folder coloring - added lore and concept for future reference
This commit is contained in:
parent
9744e58966
commit
0ddbcf7744
58 changed files with 2773 additions and 433 deletions
3
concept/breadwinner/.obsidian/app.json
vendored
Normal file
3
concept/breadwinner/.obsidian/app.json
vendored
Normal file
|
|
@ -0,0 +1,3 @@
|
||||||
|
{
|
||||||
|
"alwaysUpdateLinks": true
|
||||||
|
}
|
||||||
4
concept/breadwinner/.obsidian/appearance.json
vendored
Normal file
4
concept/breadwinner/.obsidian/appearance.json
vendored
Normal file
|
|
@ -0,0 +1,4 @@
|
||||||
|
{
|
||||||
|
"cssTheme": "Obsidianite",
|
||||||
|
"theme": "obsidian"
|
||||||
|
}
|
||||||
33
concept/breadwinner/.obsidian/core-plugins.json
vendored
Normal file
33
concept/breadwinner/.obsidian/core-plugins.json
vendored
Normal file
|
|
@ -0,0 +1,33 @@
|
||||||
|
{
|
||||||
|
"file-explorer": true,
|
||||||
|
"global-search": true,
|
||||||
|
"switcher": true,
|
||||||
|
"graph": true,
|
||||||
|
"backlink": true,
|
||||||
|
"canvas": true,
|
||||||
|
"outgoing-link": true,
|
||||||
|
"tag-pane": true,
|
||||||
|
"footnotes": false,
|
||||||
|
"properties": true,
|
||||||
|
"page-preview": true,
|
||||||
|
"daily-notes": true,
|
||||||
|
"templates": true,
|
||||||
|
"note-composer": true,
|
||||||
|
"command-palette": true,
|
||||||
|
"slash-command": false,
|
||||||
|
"editor-status": true,
|
||||||
|
"bookmarks": true,
|
||||||
|
"markdown-importer": false,
|
||||||
|
"zk-prefixer": false,
|
||||||
|
"random-note": false,
|
||||||
|
"outline": true,
|
||||||
|
"word-count": true,
|
||||||
|
"slides": false,
|
||||||
|
"audio-recorder": false,
|
||||||
|
"workspaces": false,
|
||||||
|
"file-recovery": true,
|
||||||
|
"publish": false,
|
||||||
|
"sync": true,
|
||||||
|
"bases": true,
|
||||||
|
"webviewer": false
|
||||||
|
}
|
||||||
22
concept/breadwinner/.obsidian/graph.json
vendored
Normal file
22
concept/breadwinner/.obsidian/graph.json
vendored
Normal file
|
|
@ -0,0 +1,22 @@
|
||||||
|
{
|
||||||
|
"collapse-filter": true,
|
||||||
|
"search": "",
|
||||||
|
"showTags": false,
|
||||||
|
"showAttachments": false,
|
||||||
|
"hideUnresolved": false,
|
||||||
|
"showOrphans": true,
|
||||||
|
"collapse-color-groups": true,
|
||||||
|
"colorGroups": [],
|
||||||
|
"collapse-display": true,
|
||||||
|
"showArrow": false,
|
||||||
|
"textFadeMultiplier": 0,
|
||||||
|
"nodeSizeMultiplier": 1,
|
||||||
|
"lineSizeMultiplier": 1,
|
||||||
|
"collapse-forces": true,
|
||||||
|
"centerStrength": 0.518713248970312,
|
||||||
|
"repelStrength": 10,
|
||||||
|
"linkStrength": 1,
|
||||||
|
"linkDistance": 250,
|
||||||
|
"scale": 0.7132754626224407,
|
||||||
|
"close": true
|
||||||
|
}
|
||||||
7
concept/breadwinner/.obsidian/themes/Obsidianite/manifest.json
vendored
Normal file
7
concept/breadwinner/.obsidian/themes/Obsidianite/manifest.json
vendored
Normal file
|
|
@ -0,0 +1,7 @@
|
||||||
|
{
|
||||||
|
"name": "Obsidianite",
|
||||||
|
"version": "2.0.2",
|
||||||
|
"minAppVersion": "1.1.0",
|
||||||
|
"author": "@bennyxguo",
|
||||||
|
"authorUrl": "https://github.com/bennyxguo"
|
||||||
|
}
|
||||||
1481
concept/breadwinner/.obsidian/themes/Obsidianite/theme.css
vendored
Normal file
1481
concept/breadwinner/.obsidian/themes/Obsidianite/theme.css
vendored
Normal file
File diff suppressed because it is too large
Load diff
245
concept/breadwinner/.obsidian/workspace.json
vendored
Normal file
245
concept/breadwinner/.obsidian/workspace.json
vendored
Normal file
|
|
@ -0,0 +1,245 @@
|
||||||
|
{
|
||||||
|
"main": {
|
||||||
|
"id": "28323c9c9c8f824d",
|
||||||
|
"type": "split",
|
||||||
|
"children": [
|
||||||
|
{
|
||||||
|
"id": "e3c159822b57aede",
|
||||||
|
"type": "tabs",
|
||||||
|
"children": [
|
||||||
|
{
|
||||||
|
"id": "dcb7106dcf4a60dd",
|
||||||
|
"type": "leaf",
|
||||||
|
"state": {
|
||||||
|
"type": "markdown",
|
||||||
|
"state": {
|
||||||
|
"file": "thing groups/Equippable.md",
|
||||||
|
"mode": "source",
|
||||||
|
"source": false
|
||||||
|
},
|
||||||
|
"icon": "lucide-file",
|
||||||
|
"title": "Equippable"
|
||||||
|
}
|
||||||
|
},
|
||||||
|
{
|
||||||
|
"id": "cc30646b046d3148",
|
||||||
|
"type": "leaf",
|
||||||
|
"state": {
|
||||||
|
"type": "markdown",
|
||||||
|
"state": {
|
||||||
|
"file": "game mechanics/Clipboard.md",
|
||||||
|
"mode": "source",
|
||||||
|
"source": false
|
||||||
|
},
|
||||||
|
"icon": "lucide-file",
|
||||||
|
"title": "Clipboard"
|
||||||
|
}
|
||||||
|
}
|
||||||
|
],
|
||||||
|
"currentTab": 1
|
||||||
|
}
|
||||||
|
],
|
||||||
|
"direction": "vertical"
|
||||||
|
},
|
||||||
|
"left": {
|
||||||
|
"id": "c47a4dd12a181305",
|
||||||
|
"type": "split",
|
||||||
|
"children": [
|
||||||
|
{
|
||||||
|
"id": "1d732e949ecb7ff5",
|
||||||
|
"type": "tabs",
|
||||||
|
"children": [
|
||||||
|
{
|
||||||
|
"id": "787ccec16a03f34e",
|
||||||
|
"type": "leaf",
|
||||||
|
"state": {
|
||||||
|
"type": "file-explorer",
|
||||||
|
"state": {
|
||||||
|
"sortOrder": "alphabetical",
|
||||||
|
"autoReveal": false
|
||||||
|
},
|
||||||
|
"icon": "lucide-folder-closed",
|
||||||
|
"title": "Files"
|
||||||
|
}
|
||||||
|
},
|
||||||
|
{
|
||||||
|
"id": "396e6407e7d74ce7",
|
||||||
|
"type": "leaf",
|
||||||
|
"state": {
|
||||||
|
"type": "search",
|
||||||
|
"state": {
|
||||||
|
"query": "",
|
||||||
|
"matchingCase": false,
|
||||||
|
"explainSearch": false,
|
||||||
|
"collapseAll": false,
|
||||||
|
"extraContext": false,
|
||||||
|
"sortOrder": "alphabetical"
|
||||||
|
},
|
||||||
|
"icon": "lucide-search",
|
||||||
|
"title": "Keresés"
|
||||||
|
}
|
||||||
|
},
|
||||||
|
{
|
||||||
|
"id": "60eb4e500151af49",
|
||||||
|
"type": "leaf",
|
||||||
|
"state": {
|
||||||
|
"type": "bookmarks",
|
||||||
|
"state": {},
|
||||||
|
"icon": "lucide-bookmark",
|
||||||
|
"title": "Könyvjelzők"
|
||||||
|
}
|
||||||
|
}
|
||||||
|
]
|
||||||
|
}
|
||||||
|
],
|
||||||
|
"direction": "horizontal",
|
||||||
|
"width": 300
|
||||||
|
},
|
||||||
|
"right": {
|
||||||
|
"id": "6c3b63c92687c92c",
|
||||||
|
"type": "split",
|
||||||
|
"children": [
|
||||||
|
{
|
||||||
|
"id": "62c8ce916c27f5de",
|
||||||
|
"type": "tabs",
|
||||||
|
"children": [
|
||||||
|
{
|
||||||
|
"id": "03f01b1cdcd651ea",
|
||||||
|
"type": "leaf",
|
||||||
|
"state": {
|
||||||
|
"type": "backlink",
|
||||||
|
"state": {
|
||||||
|
"file": "game mechanics/Clipboard.md",
|
||||||
|
"collapseAll": false,
|
||||||
|
"extraContext": false,
|
||||||
|
"sortOrder": "alphabetical",
|
||||||
|
"showSearch": false,
|
||||||
|
"searchQuery": "",
|
||||||
|
"backlinkCollapsed": false,
|
||||||
|
"unlinkedCollapsed": true
|
||||||
|
},
|
||||||
|
"icon": "links-coming-in",
|
||||||
|
"title": "Backlinks for Clipboard"
|
||||||
|
}
|
||||||
|
},
|
||||||
|
{
|
||||||
|
"id": "300e9e61ca856913",
|
||||||
|
"type": "leaf",
|
||||||
|
"state": {
|
||||||
|
"type": "outgoing-link",
|
||||||
|
"state": {
|
||||||
|
"file": "entities/Player.md",
|
||||||
|
"linksCollapsed": false,
|
||||||
|
"unlinkedCollapsed": true
|
||||||
|
},
|
||||||
|
"icon": "links-going-out",
|
||||||
|
"title": "Kimenő kapcsolatok a(z) Player jegyzetből"
|
||||||
|
}
|
||||||
|
},
|
||||||
|
{
|
||||||
|
"id": "48329abeac44dabd",
|
||||||
|
"type": "leaf",
|
||||||
|
"state": {
|
||||||
|
"type": "tag",
|
||||||
|
"state": {
|
||||||
|
"sortOrder": "frequency",
|
||||||
|
"useHierarchy": true,
|
||||||
|
"showSearch": false,
|
||||||
|
"searchQuery": ""
|
||||||
|
},
|
||||||
|
"icon": "lucide-tags",
|
||||||
|
"title": "Címkék"
|
||||||
|
}
|
||||||
|
},
|
||||||
|
{
|
||||||
|
"id": "99cf439ab830cb0a",
|
||||||
|
"type": "leaf",
|
||||||
|
"state": {
|
||||||
|
"type": "all-properties",
|
||||||
|
"state": {
|
||||||
|
"sortOrder": "frequency",
|
||||||
|
"showSearch": false,
|
||||||
|
"searchQuery": ""
|
||||||
|
},
|
||||||
|
"icon": "lucide-archive",
|
||||||
|
"title": "Minden tulajdonság"
|
||||||
|
}
|
||||||
|
},
|
||||||
|
{
|
||||||
|
"id": "418af86fa0164a7a",
|
||||||
|
"type": "leaf",
|
||||||
|
"state": {
|
||||||
|
"type": "graph",
|
||||||
|
"state": {},
|
||||||
|
"icon": "lucide-git-fork",
|
||||||
|
"title": "Graph view"
|
||||||
|
}
|
||||||
|
},
|
||||||
|
{
|
||||||
|
"id": "6f0ac6a92e460aab",
|
||||||
|
"type": "leaf",
|
||||||
|
"state": {
|
||||||
|
"type": "outline",
|
||||||
|
"state": {
|
||||||
|
"file": "entities/Player.md",
|
||||||
|
"followCursor": false,
|
||||||
|
"showSearch": false,
|
||||||
|
"searchQuery": ""
|
||||||
|
},
|
||||||
|
"icon": "lucide-list",
|
||||||
|
"title": "Player vázlata"
|
||||||
|
}
|
||||||
|
}
|
||||||
|
],
|
||||||
|
"currentTab": 4
|
||||||
|
}
|
||||||
|
],
|
||||||
|
"direction": "horizontal",
|
||||||
|
"width": 647.5,
|
||||||
|
"collapsed": true
|
||||||
|
},
|
||||||
|
"left-ribbon": {
|
||||||
|
"hiddenItems": {
|
||||||
|
"switcher:Open quick switcher": false,
|
||||||
|
"graph:Open graph view": false,
|
||||||
|
"canvas:Create new canvas": false,
|
||||||
|
"daily-notes:Open today's daily note": false,
|
||||||
|
"templates:Insert template": false,
|
||||||
|
"command-palette:Open command palette": false,
|
||||||
|
"bases:Create new base": false
|
||||||
|
}
|
||||||
|
},
|
||||||
|
"active": "cc30646b046d3148",
|
||||||
|
"lastOpenFiles": [
|
||||||
|
"game mechanics/Day cycle.md",
|
||||||
|
"game mechanics/Smartwatch.md",
|
||||||
|
"game mechanics/THE NARRATOR.md",
|
||||||
|
"concepts and lore/Base gameplay.md",
|
||||||
|
"concepts and lore/Multiplayer.md",
|
||||||
|
"concepts and lore/Singleplayer.md",
|
||||||
|
"entities/Serbreads.md",
|
||||||
|
"entities/IT.md",
|
||||||
|
"entities/PlayerEntity.md",
|
||||||
|
"TLDR/MVP Functionality.md",
|
||||||
|
"TLDR/MVP Assets.md",
|
||||||
|
"TLDR/MVP.md",
|
||||||
|
"TLDR",
|
||||||
|
"concepts and lore/Lore.md",
|
||||||
|
"thing groups/Player.md",
|
||||||
|
"game mechanics/Clipboard.md",
|
||||||
|
"game mechanics/The pawn shop.md",
|
||||||
|
"game mechanics/The safe zone computer.md",
|
||||||
|
"game mechanics/The safe zone.md",
|
||||||
|
"game mechanics/The PSA system.md",
|
||||||
|
"thing groups/Equippable.md",
|
||||||
|
"thing groups/Grabbable.md",
|
||||||
|
"thing groups/!Group rules.md",
|
||||||
|
"thing groups/Entity.md",
|
||||||
|
"Pasted image 20260728145533.png",
|
||||||
|
"game mechanics",
|
||||||
|
"concepts and lore/Multiplayer (bredren).md",
|
||||||
|
"thing groups",
|
||||||
|
"concepts and lore",
|
||||||
|
"entities"
|
||||||
|
]
|
||||||
|
}
|
||||||
10
concept/breadwinner/TLDR/MVP Assets.md
Normal file
10
concept/breadwinner/TLDR/MVP Assets.md
Normal file
|
|
@ -0,0 +1,10 @@
|
||||||
|
The list goes from most important to least important in descending order
|
||||||
|
|
||||||
|
- [[The safe zone]]
|
||||||
|
- [[The safe zone computer]]
|
||||||
|
- layout pieces for procedural generation of levels
|
||||||
|
- procedural level generation
|
||||||
|
- Player character
|
||||||
|
- IT model
|
||||||
|
- serbreads model
|
||||||
|
- textures for everything
|
||||||
8
concept/breadwinner/TLDR/MVP Functionality.md
Normal file
8
concept/breadwinner/TLDR/MVP Functionality.md
Normal file
|
|
@ -0,0 +1,8 @@
|
||||||
|
Descending in order of importance
|
||||||
|
- Movement fluidity
|
||||||
|
- Procedural camera and ui movement fluidity
|
||||||
|
- Audio
|
||||||
|
- breathing
|
||||||
|
- jumping, landing
|
||||||
|
- ambiance
|
||||||
|
- Multiplayer base
|
||||||
2
concept/breadwinner/TLDR/MVP.md
Normal file
2
concept/breadwinner/TLDR/MVP.md
Normal file
|
|
@ -0,0 +1,2 @@
|
||||||
|
- [[MVP Assets]]
|
||||||
|
- [[MVP Functionality]]
|
||||||
11
concept/breadwinner/concepts and lore/Base gameplay.md
Normal file
11
concept/breadwinner/concepts and lore/Base gameplay.md
Normal file
|
|
@ -0,0 +1,11 @@
|
||||||
|
You start in the *"safe zone"*. There is an old *computer* with a *printer* attached. You can hear a silly, high-passed song playing from somewhere in the safe zone. There is also a *bed*, where you can sleep once you have finished for the day.
|
||||||
|
|
||||||
|
You must go out into the *"infinite bread warehouse"* to gather bread for delivery next to the *safe zone*. This warehouse is randomly generated each time you are dropped in the game from warehouse components to give it a liminal feel.
|
||||||
|
|
||||||
|
You must use small *"bread moving trays"* to be able to move a bigger number of bread.
|
||||||
|
|
||||||
|
You have a base quota that gets printed out or written on the screen at the *safe zone* every day. Once the quota is fulfilled, you can hear an approval sound emanating from the computer that can be found in the *safe zone*. Once you check, you can see that there are additional quotas you can complete for additional *cash*.
|
||||||
|
|
||||||
|
With cash you can buy *upgrades*, such as **increased inventory space**, **exosuits** for increased speed or power (can lift heavier objects aka bring more bread on the tray), **lures** for the entities, **facility upgrades** (more or better battery for longer day-times (important for later game because the quotas are so big))
|
||||||
|
|
||||||
|
The *day ends* after x minutes, when all the lights go out, and everything gets pitch black. You can still deliver more bread, but because of the dark, there are more *entities* roaming about, making it much more treacherous. BUT yielding high in rewards if you do, since you can find treasures lurking in the darkness. Treasures are [[Equippable]]s, which have a higher sell value.
|
||||||
5
concept/breadwinner/concepts and lore/Multiplayer.md
Normal file
5
concept/breadwinner/concepts and lore/Multiplayer.md
Normal file
|
|
@ -0,0 +1,5 @@
|
||||||
|
4 player CO-OP, where the difficulty scales in accordance of player count.
|
||||||
|
|
||||||
|
Name of the mode is **bredren**, coming from brethren.
|
||||||
|
|
||||||
|
https://youtu.be/frNKdfPQfxA
|
||||||
1
concept/breadwinner/concepts and lore/Singleplayer.md
Normal file
1
concept/breadwinner/concepts and lore/Singleplayer.md
Normal file
|
|
@ -0,0 +1 @@
|
||||||
|
The original experience. Check [[Base gameplay]].
|
||||||
12
concept/breadwinner/entities/IT.md
Normal file
12
concept/breadwinner/entities/IT.md
Normal file
|
|
@ -0,0 +1,12 @@
|
||||||
|
IT is the main "*monsert*" of the game.
|
||||||
|
|
||||||
|
IT looks like a gigantic centipede, which has a body made of bread????
|
||||||
|
|
||||||
|
Each day it grows **longer**. Yes. It consumes more bread, since its basically (no really) infinite.
|
||||||
|
|
||||||
|
It can crawl on the walls, and basically follows the curvature of the wall and sticks to it, because uh **IT CAN**.
|
||||||
|
|
||||||
|
In game, it should be drawn towards sounds --> making use of [[The PSA system]] and items is key for conquering this entity.
|
||||||
|
|
||||||
|
Of course, bread is not the only source of its meal -- its also you as well. It will eat you, yummy ummyy muym ym yummy
|
||||||
|
|
||||||
3
concept/breadwinner/entities/PlayerEntity.md
Normal file
3
concept/breadwinner/entities/PlayerEntity.md
Normal file
|
|
@ -0,0 +1,3 @@
|
||||||
|
This is the node, that the player will be in control of during game runtime
|
||||||
|
it is in the group [[Player]]
|
||||||
|
|
||||||
6
concept/breadwinner/entities/Serbreads.md
Normal file
6
concept/breadwinner/entities/Serbreads.md
Normal file
|
|
@ -0,0 +1,6 @@
|
||||||
|
Servants but bread.
|
||||||
|
|
||||||
|
They are **anthropomorphic bread**. They walk towards you, and are *photo-phobic* (aka afraid of light), because of reasons. Therefore they do not come out in the day, but in the **night** they do. They are easily deferred with a **flashlight**, or some other light source, if bright enough.
|
||||||
|
|
||||||
|
They are sneaky, but do give a **small sound** when approaching. Their pitter-patter is not perfect. When threatened or shot with light, they *scream* and run away from its source. Anti-moth like.
|
||||||
|
|
||||||
5
concept/breadwinner/game mechanics/Clipboard.md
Normal file
5
concept/breadwinner/game mechanics/Clipboard.md
Normal file
|
|
@ -0,0 +1,5 @@
|
||||||
|
This is your on-person **information carrier** provided to you by the **oh-so-kind managers** from high up!
|
||||||
|
|
||||||
|
**You can use it to write** up the quota of the day, also write up storage places for later reference, where you can find different kinds of loafs, or perhaps treasures.
|
||||||
|
|
||||||
|
Basically a *book and quill* from minecraft but takes up no inventory space. COOOL!
|
||||||
15
concept/breadwinner/game mechanics/Day cycle.md
Normal file
15
concept/breadwinner/game mechanics/Day cycle.md
Normal file
|
|
@ -0,0 +1,15 @@
|
||||||
|
Since this game is set inside a liminal infinite corporate warehouse, there are *no windows*. Why would there be?
|
||||||
|
|
||||||
|
# Day
|
||||||
|
When the lights are on, it is **daytime**. The lights are terrible, they do not light up much, but it would cost more to be able to light up all of the warehouse, due to it being infinite.
|
||||||
|
|
||||||
|
Due to this, it is **not** entirely pitch black, but it is *pretty dark.*
|
||||||
|
|
||||||
|
**Entities** still **roam around**, but they are more spread out, and therefore *entity* *interactions* are *minimal* to *none*.
|
||||||
|
|
||||||
|
# Night
|
||||||
|
[[The PSA system]] announces the "*daylight savings*" which literally means they turn off all lights in the warehouse.
|
||||||
|
|
||||||
|
**Entities roam around**, and the chances for interacting with them is increased. Every \<minute\> (idk if it should be minute, maybe it should be 3 or 4 minutes depending on how it will feel in testing) it gets more and more higher.
|
||||||
|
|
||||||
|
You are always safe in [[The safe zone]], no matter when you go in.
|
||||||
3
concept/breadwinner/game mechanics/Smartwatch.md
Normal file
3
concept/breadwinner/game mechanics/Smartwatch.md
Normal file
|
|
@ -0,0 +1,3 @@
|
||||||
|
you can always check the PROPER time by pulling this little thing up
|
||||||
|
|
||||||
|
You can also check some cool stats with it as well. Of course you can, its a **smart watch**!!!!!!!
|
||||||
10
concept/breadwinner/game mechanics/THE NARRATOR.md
Normal file
10
concept/breadwinner/game mechanics/THE NARRATOR.md
Normal file
|
|
@ -0,0 +1,10 @@
|
||||||
|
The narrator talks to the player when they are still in [[The safe zone]].
|
||||||
|
|
||||||
|
Once the player has left [[The safe zone]], the narrator can easily break the 4th wall, and talk through [[The PSA system]]. This disturbes breadlife. Could come in handy in a bad situation!
|
||||||
|
|
||||||
|
The narrator is self aware, and hates hearing himself on [[The PSA system]], and reacts to it accordingly. Oh yeah, he also says some cheesy one liners because its funny as hell, probably.
|
||||||
|
|
||||||
|
The narrator **mocks** the player after their mistakes, and has **memory**.
|
||||||
|
It remembers. *It always remembers*.
|
||||||
|
|
||||||
|
BIG BROTHER??
|
||||||
9
concept/breadwinner/game mechanics/The PSA system.md
Normal file
9
concept/breadwinner/game mechanics/The PSA system.md
Normal file
|
|
@ -0,0 +1,9 @@
|
||||||
|
There are **loudspeakers** littered around the warehouse, that can be used as *distractions* for different kinds of entities.
|
||||||
|
|
||||||
|
The main thing with them is, that due to corner cutting, they could not be connected to a centralized network, and operate separately. Therefore **you must get near their respective computer**, if you want to either play a sound or music through them.
|
||||||
|
|
||||||
|
It also **announces the daylight savings time**: you have 3 minutes left before the day cycle turns to night. Every speaker announces it at the same time in the beginning, but the longer you play, the bigger the difference will be between computers due to something idk like synchronization issues, due to them not being able to sync to other computers or the outside. Thank the budget cuts. You can always check the REAL TIME with your **auto-syncing satellite-technology included BreadMart [[Smartwatch]] ^tm
|
||||||
|
|
||||||
|
[[THE NARRATOR]] can speak through it once in a while. Especially at **bad** moments.
|
||||||
|
Sometimes good :3
|
||||||
|
|
||||||
73
concept/breadwinner/game mechanics/The pawn shop.md
Normal file
73
concept/breadwinner/game mechanics/The pawn shop.md
Normal file
|
|
@ -0,0 +1,73 @@
|
||||||
|
Should have the icon of a pawn from chess
|
||||||
|
It is an online marketplace, which can be found on your computer in your **safe zone**, where you can **instantly sell** and **auction** your found goods in exchange for **money**. Oh and you can buy shit as well, either at the auctions, or at the instant shop
|
||||||
|
|
||||||
|
both times when selling or buying you have to pay shipping, which increases each day up to a limit
|
||||||
|
$\text{shipping\_price} = idk$
|
||||||
|
upper limit: $idk \cdot 10$
|
||||||
|
# SELL
|
||||||
|
## Instant shop
|
||||||
|
no risk, small reward way of getting money for your treasures
|
||||||
|
|
||||||
|
basically, you can instantly sell your chosen item for
|
||||||
|
$$\text{Instant Sell price} = \text{item\_value} * (0.3 + \text{base\_sell\_upgrade\_level} \cdot 0.1)$$
|
||||||
|
- $\text{item\_value}$ is the value of the item you are trying to sell
|
||||||
|
- $\text{base\_sell\_upgrade\_level}$ is the level of the safe zone upgrade "base sell amount"
|
||||||
|
|
||||||
|
so basically you can upgrade with your money, how much you can instant sell the items for
|
||||||
|
NO RNG INCLUDED!
|
||||||
|
## Auction
|
||||||
|
high risk, high reward way of making money from your found goods
|
||||||
|
|
||||||
|
at first, you have to auction your items for a price, that you can set
|
||||||
|
this will determine, how many bids you will get
|
||||||
|
|
||||||
|
$$P(\text{first\_bid\_to\_happen}) = \frac{\text{item\_value} - \text{auction\_price}}{\text{item\_value} + \text{auction\_price}} $$
|
||||||
|
|
||||||
|
as you can see, if you start the bidding on 0, then you are guaranteed to have a bid.
|
||||||
|
|
||||||
|
<hr>
|
||||||
|
|
||||||
|
next up, the bid amount
|
||||||
|
$$\text{bid\_amount} = \text{item\_value} \cdot \text{bid\_increase} \cdot \text{random\_spread}$$
|
||||||
|
|
||||||
|
where
|
||||||
|
|
||||||
|
$\text{bid\_increase} = 0.1 + \text{bid\_amount\_upgrade\_level} \cdot 0.05$
|
||||||
|
$\text{random\_spread} = \text{randf\_range}(0.5 + \text{min\_bid\_multiplier\_upgrade}, 1.2 + \text{max\_bid\_multiplier\_upgrade})$
|
||||||
|
|
||||||
|
- $\text{bid\_amount\_upgrade\_level}$ is the level of the upgrade
|
||||||
|
- $\text{min\_bid\_multiplier\_upgrade}$ raises the minimum multiplier for the bid raise
|
||||||
|
- $\text{max\_bid\_multiplier\_upgrade}$ raises the maximum multiplier for the bid raise
|
||||||
|
|
||||||
|
<hr>
|
||||||
|
|
||||||
|
$\text{current\_bid}$ this is the current active bid
|
||||||
|
$\text{last\_bid}$ this is the one bid before the current
|
||||||
|
|
||||||
|
<hr>
|
||||||
|
|
||||||
|
next up, the bid chance
|
||||||
|
$$P(\text{bid\_happens}) = \frac{\text{last\_bid} + \frac{\text{bid\_chance\_upgrade} \cdot \text{item\_value}}{10}}{\text{current\_bid} +\text{item\_value}}$$
|
||||||
|
- $\text{bid\_chance\_upgrade}$ this practically upgrades the items value to make it more probably for a bid to occur
|
||||||
|
- $\text{current\_bid}$ the current active highest bid
|
||||||
|
|
||||||
|
since this probability can exceed 1, it should be clamped to 1
|
||||||
|
|
||||||
|
### how it looks like in game
|
||||||
|
When you want to start an auction, you open the pawn shop on [[The safe zone computer]] and you go to the auction center. You press the "*put item up for auction*" button, and you select the item from your inventory. Next, a window pops up, where you have to enter the starting bid amount. You enter the starting bid, and you start the auction, and wait for the results.
|
||||||
|
|
||||||
|
It can have a fun effect when happening, maybe even like a spinning wheel (WE LOVE GAMPLING!!!)
|
||||||
|
|
||||||
|
# BUY
|
||||||
|
|
||||||
|
## Instant buy
|
||||||
|
high price, for sure delivery
|
||||||
|
|
||||||
|
if you buy something here, it will be delivered 100%
|
||||||
|
|
||||||
|
when buying, the shipping price is counted into the shown price, so no hassle!
|
||||||
|
|
||||||
|
## Auction buy
|
||||||
|
same system for auctioning as selling, but you participate in it as well. The same upgrades apply, but in reverse, making the chance of bidding lower with upgrades, making it easier for you to purchase items from the auction.
|
||||||
|
|
||||||
|
can luck out with good items, and even do some reselling, and earn money. kinda like stocks!
|
||||||
14
concept/breadwinner/game mechanics/The safe zone computer.md
Normal file
14
concept/breadwinner/game mechanics/The safe zone computer.md
Normal file
|
|
@ -0,0 +1,14 @@
|
||||||
|
The computer is the main centre of the chilling phase of the game.
|
||||||
|
Each player has their own computer in their own container
|
||||||
|
|
||||||
|
It is an old CRT monitor placed on top of an old pc case.
|
||||||
|
|
||||||
|
# The desktop
|
||||||
|
the desktop has 2 major apps:
|
||||||
|
- [[The pawn shop]]
|
||||||
|
- The quota machine
|
||||||
|
|
||||||
|
## the quota machine
|
||||||
|
its basically a program, which shows you the quota of the day. you have to manually write this up on your [[Clipboard]], or remember it in your head.
|
||||||
|
|
||||||
|
it will get harder and harder with each passing day
|
||||||
15
concept/breadwinner/game mechanics/The safe zone.md
Normal file
15
concept/breadwinner/game mechanics/The safe zone.md
Normal file
|
|
@ -0,0 +1,15 @@
|
||||||
|
This is the first room, where the player(s) wake up when starting a new game.
|
||||||
|
It looks like a semi-rised shipping container room, which has some windows on the sides. The inside is very simple, but functional:
|
||||||
|
- 1 bed(s)
|
||||||
|
- a wardrobe
|
||||||
|
- a desk
|
||||||
|
- [[The safe zone computer]]
|
||||||
|
- a couch
|
||||||
|
- a coffee machine (of course)
|
||||||
|
- a big bread container next to the couch
|
||||||
|
|
||||||
|
At the end of every day, the player(s) must return to this place, where once they are finished with the quotas, are safe from all the entities lying within the warehouse.
|
||||||
|
|
||||||
|
Each player has their own little container, because it would be more expensive to make the container bigger for one person, and they would have to create different manufacture lines for each number of player that can play, so this cuts costs. The containers are just put next to each other side by side (longer side to longer side).
|
||||||
|
|
||||||
|
Before going to bed tho, they have the ability to sell and auction their treasures for extra dinhero at the [[The pawn shop]].
|
||||||
11
concept/breadwinner/thing groups/!Group rules.md
Normal file
11
concept/breadwinner/thing groups/!Group rules.md
Normal file
|
|
@ -0,0 +1,11 @@
|
||||||
|
Each group in code is exclusively lowercase
|
||||||
|
|
||||||
|
For example the "Entity" group can be referred to as **x.*is_in_group("entity")*** where x is the entity that is being checked.
|
||||||
|
|
||||||
|
each group
|
||||||
|
--
|
||||||
|
- [Entity](Entity)
|
||||||
|
- [Equippable](Equippable)
|
||||||
|
- [Grabbable](Grabbable)
|
||||||
|
- [Player](Player)
|
||||||
|
|
||||||
0
concept/breadwinner/thing groups/Entity.md
Normal file
0
concept/breadwinner/thing groups/Entity.md
Normal file
24
concept/breadwinner/thing groups/Equippable.md
Normal file
24
concept/breadwinner/thing groups/Equippable.md
Normal file
|
|
@ -0,0 +1,24 @@
|
||||||
|
Objects that are *equippable* can be put into the inventory
|
||||||
|
If something is equippable, it is **also** grabbable
|
||||||
|
RigidBody3D < [Grabbable](Grabbable.md) < Equippable
|
||||||
|
|
||||||
|
Components (the node tree):
|
||||||
|
- the grabbable object
|
||||||
|
- camera (only active for one frame to take the picture of the item when put inside the inventory)
|
||||||
|
- for creating the image of the object
|
||||||
|
- placed above the object at northwest up, pointing at the centre of the object
|
||||||
|
|
||||||
|
Properties:
|
||||||
|
- function
|
||||||
|
- what it can do, when equipped
|
||||||
|
- inv slot size
|
||||||
|
- how many slots of inventory does it take up
|
||||||
|
- weight
|
||||||
|
- how much the equippable weighs
|
||||||
|
- if a player is holding too much, they get encumbered
|
||||||
|
- description
|
||||||
|
- in english description of the equippable item. maybe some lore, or something fun
|
||||||
|
- the image
|
||||||
|
- created by the camera for dynamic inventory icons
|
||||||
|
- sell value
|
||||||
|
- how much dinhero you can, if you sell this item on the online marketplace
|
||||||
13
concept/breadwinner/thing groups/Grabbable.md
Normal file
13
concept/breadwinner/thing groups/Grabbable.md
Normal file
|
|
@ -0,0 +1,13 @@
|
||||||
|
Objects that are *grabbable* can be picked up and held by the player when holding \[LMB\]
|
||||||
|
These objects always rotate towards the player's camera
|
||||||
|
|
||||||
|
RigidBody3D < Grabbable < [Equippable](Equippable.md)
|
||||||
|
|
||||||
|
Components:
|
||||||
|
- the objects itself
|
||||||
|
- mesh
|
||||||
|
- collider
|
||||||
|
|
||||||
|
Properties
|
||||||
|
- weight
|
||||||
|
- how hard is it to pick up or drag
|
||||||
44
concept/breadwinner/thing groups/Player.md
Normal file
44
concept/breadwinner/thing groups/Player.md
Normal file
|
|
@ -0,0 +1,44 @@
|
||||||
|
The player (or players in [[Multiplayer]]) is the node that is controlled by the user.
|
||||||
|
Read about lore in [[PlayerEntity]]
|
||||||
|
|
||||||
|
Components (node tree):
|
||||||
|
- Camera
|
||||||
|
- this is where the player percieves the game world
|
||||||
|
- this is manipulated by the procedural animation "idle"
|
||||||
|
- has the child "flashlight"
|
||||||
|
- Camera Pivot
|
||||||
|
- this is where the camera position is being manipulated by leaning
|
||||||
|
- UI
|
||||||
|
- This handles all the shown ui things like stamina currently active item and inventory slot
|
||||||
|
- Sound emitters
|
||||||
|
- this is where the sounds will be emitted from, mainly movement, breathing and flashlight
|
||||||
|
- Legs
|
||||||
|
- left, right
|
||||||
|
- left, right FX (shuffling for now)
|
||||||
|
- Head
|
||||||
|
- flashlight
|
||||||
|
- breathing
|
||||||
|
|
||||||
|
Properties:
|
||||||
|
- Stamina
|
||||||
|
- 0 - 100 float value
|
||||||
|
- refills after 2 seconds of non-jumping or non-sprinting
|
||||||
|
- breathing heaviness and idle animation heaviness is influenced by this value
|
||||||
|
- Inventory
|
||||||
|
- this is where the player can store some items for later use
|
||||||
|
- dynamic size
|
||||||
|
- start with inv size 2, can be later upgraded to a max of 5
|
||||||
|
- needs testing to see if its balanced or fun
|
||||||
|
- upgrade can be like a bigger pouch or a bag
|
||||||
|
- one inventory slot can hold one equippable item
|
||||||
|
- Movement states
|
||||||
|
- walking, running, crouching, grabbing, leaning
|
||||||
|
- each is a boolean
|
||||||
|
- var walking: bool = false
|
||||||
|
- each has their own functions
|
||||||
|
- set_\<type\>(boolean) --> sets the state
|
||||||
|
- set_walking(yes:bool) -> void
|
||||||
|
- set_walking(true) --> sets walking to true, running to false
|
||||||
|
- influences the audio and what can and cant the player do (cannot run and walk at the same time)
|
||||||
|
- grabbing force
|
||||||
|
- if increased, you can move more bread on a tray or hold and drag heavier objects easier
|
||||||
|
|
@ -1,6 +1,6 @@
|
||||||
[gd_scene format=3 uid="uid://chykk2a3opu0d"]
|
[gd_scene format=3 uid="uid://chykk2a3opu0d"]
|
||||||
|
|
||||||
[ext_resource type="PackedScene" uid="uid://kqq30y24c6kd" path="res://player/player.tscn" id="1_s8b7j"]
|
[ext_resource type="PackedScene" uid="uid://kqq30y24c6kd" path="res://scenes/player/player.tscn" id="1_s8b7j"]
|
||||||
[ext_resource type="AudioStream" uid="uid://db0yck6trekrs" path="res://assets/sounds/ambiance/pc-fan-paulstretched.mp3" id="2_phkhq"]
|
[ext_resource type="AudioStream" uid="uid://db0yck6trekrs" path="res://assets/sounds/ambiance/pc-fan-paulstretched.mp3" id="2_phkhq"]
|
||||||
[ext_resource type="Script" uid="uid://y8x4svl5kej2" path="res://addons/spatial_audio_3d/spatial_audio_3d.gd" id="4_yb1w3"]
|
[ext_resource type="Script" uid="uid://y8x4svl5kej2" path="res://addons/spatial_audio_3d/spatial_audio_3d.gd" id="4_yb1w3"]
|
||||||
|
|
||||||
|
|
|
||||||
|
|
@ -1,419 +0,0 @@
|
||||||
extends CharacterBody3D
|
|
||||||
class_name PlayerCharacter
|
|
||||||
|
|
||||||
@export_category("Movement")
|
|
||||||
@export var SPEED = 5.0 ##base walking speed
|
|
||||||
@export var SPRINT_MULTIPLIER = 1.5 ##how much faster should you move, when sprinting
|
|
||||||
@export var SPRINT_STAMINA_COST = 10.0 ##how much stamina should be consumed each frame while sprinting (delta * SPRINT_STAMINA_COST)
|
|
||||||
@export var CROUCH_SPEED_MULTIPLIER = .5 ##how much slower you should be going while crouching
|
|
||||||
|
|
||||||
@export_category("Jump")
|
|
||||||
@export var JUMP_VELOCITY = 4.5 ##how high you can jump
|
|
||||||
@export var JUMP_STAMINA_COST = 10 ##how much stamina each jump consumes
|
|
||||||
|
|
||||||
@export_category("Camera")
|
|
||||||
@export var LOOK_SENSITIVITY = 1.0 ##camera sensitivity
|
|
||||||
@export var CAMERA_VELOCITY_MULTIPLIER = 1.5 ##how heavy should the UI movement feel
|
|
||||||
@export var CAMERA_BOB_FREQUENCY = 2.4 ##how quick the camera bobs whilst moving
|
|
||||||
@export var CAMERA_BOB_AMPLITUDE = 0.08 ##how hard the camera bobs whilst moving
|
|
||||||
@export var CAMERA_BOB_MULTIPLIER = 200.0 ##how much the ui reacts to head bobbing
|
|
||||||
@export var CAMERA_SIDEWAYS_BOB_AMPLITUDE = 0.003 ## how many degrees does the camera bob sideways
|
|
||||||
|
|
||||||
@export_category("UI")
|
|
||||||
@export var UI_SCALE: float = 1 ##rational scale of the ui
|
|
||||||
@export var UI_MOVEMENT_SENSITIVITY = 0.5 ##how much the UI moves when you move the camera
|
|
||||||
@export var UI_MOVEMENT_SPEED = 15.0 ##how fast the UI moves when you move the camera
|
|
||||||
@export var UI_MOVEMENT_VELOCITY_MULTIPLIER = 2.0 ##how much the ui leans when walking or strafing
|
|
||||||
|
|
||||||
@export_category("Inventory")
|
|
||||||
@export var INVENTORY_MAX = 3 ##max number of items that can be in the player's inventory
|
|
||||||
@export var INVENTORY_ITEMS: Array = [] ##the items in the player's inventory
|
|
||||||
|
|
||||||
@export_category("Audio")
|
|
||||||
@export var AUDIO_LOUDNESS: float = 100.0
|
|
||||||
@export var NORMAL_FOOTSTEP_SOUNDS: Array[AudioStreamWAV] ##normal footsteps -- walking
|
|
||||||
@export var HEAVY_FOOTSTEP_SOUNDS: Array[AudioStreamWAV] ##heavy footsteps -- running
|
|
||||||
@export var LIGHT_FOOTSTEP_SOUNDS: Array[AudioStreamWAV] ##light footsteps -- crouching
|
|
||||||
@export var SHUFFLE_FOOTSTEP_SOUNDS: Array[AudioStreamWAV] ##shuffling -- random chance of playing while running
|
|
||||||
@export var FLASHLIGHT_CLICK_SOUNDS: Array[AudioStreamWAV] ##flashlight click
|
|
||||||
@export var SHUFFLE_CHANCE: float = 20 ##percentage of chance for a shuffle noise to be played whilst running
|
|
||||||
|
|
||||||
@export_category("Grabbing")
|
|
||||||
@export var GRAB_POWER: float = 15.0 ##how fast the grabbed object snaps to the hold position
|
|
||||||
@export var GRAB_ROTATION_POWER: float = 15.0 ##how fast the object rotates towards the player
|
|
||||||
@export var GRAB_PANEL: PackedScene ##panel that goes over the grabbable object to show its grabbable
|
|
||||||
|
|
||||||
@export_category("Player Physics")
|
|
||||||
@export_flags_3d_physics var PLAYER_COLLISION_MASK: int = 16
|
|
||||||
|
|
||||||
@onready var camera = $CameraPivot/PlayerCamera
|
|
||||||
@onready var camera_pivot = $CameraPivot
|
|
||||||
@onready var ui = $PlayerUi
|
|
||||||
@onready var ui_base_position = ui.position
|
|
||||||
@onready var in_game_menu = $InGameMenu
|
|
||||||
@onready var left_foot_sound_player = $SoundEmitters/LeftFoot
|
|
||||||
@onready var left_foot_texture_sound_player = $SoundEmitters/LeftFoot/LeftFootTexture
|
|
||||||
@onready var right_foot_sound_player = $SoundEmitters/RightFoot
|
|
||||||
@onready var right_foot_texture_sound_player = $SoundEmitters/RightFoot/RightFootTexture
|
|
||||||
@onready var flashlight_sound_player = $SoundEmitters/FlashlightSound
|
|
||||||
@onready var cursor_raycast = $CameraPivot/PlayerCamera/CursorRaycast
|
|
||||||
@onready var hold_position = $CameraPivot/PlayerCamera/HoldPosition
|
|
||||||
@onready var popup_panels = $PopupPanels
|
|
||||||
|
|
||||||
var walking: bool = false
|
|
||||||
var running: bool = false
|
|
||||||
var crouching: bool = false
|
|
||||||
var in_menu: bool = false
|
|
||||||
var stamina: float = 100.0
|
|
||||||
var stamina_recharge_on: bool = false
|
|
||||||
var selected_item: int = 0
|
|
||||||
var t_bob: float = 0
|
|
||||||
var last_bob_y: float = 0.0
|
|
||||||
var held_object: RigidBody3D = null
|
|
||||||
|
|
||||||
var _mouse_motion: Vector2 = Vector2.ZERO
|
|
||||||
var _mouse_motion_delta: Vector2 = Vector2.ZERO
|
|
||||||
var _last_camera_global_position: Vector3 = Vector3.ZERO
|
|
||||||
var _current_leg_is_right: bool = false ##if true: current leg is the right leg
|
|
||||||
var _current_footstep_sound: AudioStreamWAV = null
|
|
||||||
var _current_flashlight_sound: AudioStreamWAV = null
|
|
||||||
var _camera_original_position: Vector3 = Vector3(0,.75,0)
|
|
||||||
|
|
||||||
func play_footstep_sound():
|
|
||||||
var sound_to_play
|
|
||||||
if walking:
|
|
||||||
sound_to_play = NORMAL_FOOTSTEP_SOUNDS.pick_random()
|
|
||||||
while sound_to_play == _current_footstep_sound:
|
|
||||||
sound_to_play = NORMAL_FOOTSTEP_SOUNDS.pick_random()
|
|
||||||
elif running:
|
|
||||||
sound_to_play = HEAVY_FOOTSTEP_SOUNDS.pick_random()
|
|
||||||
while sound_to_play == _current_footstep_sound:
|
|
||||||
sound_to_play = HEAVY_FOOTSTEP_SOUNDS.pick_random()
|
|
||||||
if randf_range(1, 100) > 100 - SHUFFLE_CHANCE:
|
|
||||||
match _current_leg_is_right:
|
|
||||||
true:
|
|
||||||
right_foot_texture_sound_player.do_set_stream(SHUFFLE_FOOTSTEP_SOUNDS.pick_random())
|
|
||||||
right_foot_texture_sound_player.do_play()
|
|
||||||
false:
|
|
||||||
left_foot_texture_sound_player.do_set_stream(SHUFFLE_FOOTSTEP_SOUNDS.pick_random())
|
|
||||||
left_foot_texture_sound_player.do_play()
|
|
||||||
|
|
||||||
elif crouching:
|
|
||||||
sound_to_play = LIGHT_FOOTSTEP_SOUNDS.pick_random()
|
|
||||||
while sound_to_play == _current_footstep_sound:
|
|
||||||
sound_to_play = LIGHT_FOOTSTEP_SOUNDS.pick_random()
|
|
||||||
|
|
||||||
_current_footstep_sound = sound_to_play
|
|
||||||
|
|
||||||
if _current_leg_is_right:
|
|
||||||
right_foot_sound_player.do_set_stream(sound_to_play)
|
|
||||||
right_foot_sound_player.pitch_scale = randf_range(0.8, 1.2)
|
|
||||||
right_foot_sound_player.do_play()
|
|
||||||
_current_leg_is_right = false
|
|
||||||
else:
|
|
||||||
left_foot_sound_player.do_set_stream(sound_to_play)
|
|
||||||
left_foot_sound_player.pitch_scale = randf_range(0.8, 1.2)
|
|
||||||
left_foot_sound_player.do_play()
|
|
||||||
_current_leg_is_right = true
|
|
||||||
|
|
||||||
func ui_handling(delta):
|
|
||||||
ui.offset_transform_scale *= UI_SCALE
|
|
||||||
ui_movement_handling(delta)
|
|
||||||
ui.set_stamina_bar(stamina)
|
|
||||||
var horizontal_speed = Vector3(velocity.x, velocity.y, velocity.z).length()
|
|
||||||
|
|
||||||
if is_on_floor() and horizontal_speed > 0.05:
|
|
||||||
t_bob += delta * (velocity.length() * float(is_on_floor()) + (int(Input.is_action_pressed("crouch"))) * 3)
|
|
||||||
|
|
||||||
var current_sin_pos = sin(t_bob * CAMERA_BOB_FREQUENCY)
|
|
||||||
|
|
||||||
#footstep handling
|
|
||||||
if last_bob_y >= -.95 and current_sin_pos < -.95:
|
|
||||||
play_footstep_sound()
|
|
||||||
|
|
||||||
last_bob_y = current_sin_pos
|
|
||||||
|
|
||||||
camera_bobbing(t_bob)
|
|
||||||
|
|
||||||
#idle breathing
|
|
||||||
elif is_on_floor() and horizontal_speed < 0.05:
|
|
||||||
t_bob += delta * 1
|
|
||||||
camera_breathing(t_bob)
|
|
||||||
else:
|
|
||||||
camera.rotation.z = lerpf(camera.rotation.z,0, delta * 0.004)
|
|
||||||
camera.transform.origin.y = lerpf(camera.transform.origin.y, _camera_original_position.y, delta * 5.0)
|
|
||||||
if camera.transform.origin.length() < 0.01:
|
|
||||||
t_bob = 0
|
|
||||||
last_bob_y = 0.0
|
|
||||||
|
|
||||||
func ui_movement_handling(delta: float):
|
|
||||||
var mouse_offset = -_mouse_motion_delta * UI_MOVEMENT_SENSITIVITY
|
|
||||||
|
|
||||||
var current_camera_global_position = camera.global_position
|
|
||||||
var camera_global_velocity = (current_camera_global_position - _last_camera_global_position) / delta
|
|
||||||
|
|
||||||
var cam_local_vel = camera.global_transform.basis.inverse() * camera_global_velocity
|
|
||||||
|
|
||||||
var inertia_offset = Vector2(
|
|
||||||
-cam_local_vel.x,
|
|
||||||
cam_local_vel.y - (cam_local_vel.z * 0.25)
|
|
||||||
) * CAMERA_VELOCITY_MULTIPLIER
|
|
||||||
|
|
||||||
var target_offset = mouse_offset + inertia_offset
|
|
||||||
ui.position = ui.position.lerp(ui_base_position + target_offset, delta * UI_MOVEMENT_SPEED)
|
|
||||||
|
|
||||||
_last_camera_global_position = current_camera_global_position
|
|
||||||
|
|
||||||
var ui_scaling_target = Vector2(-cam_local_vel.z * UI_MOVEMENT_SENSITIVITY * .002 + 1, -cam_local_vel.z * UI_MOVEMENT_SENSITIVITY * .002 + 1)
|
|
||||||
ui.offset_transform_scale = ui.offset_transform_scale.lerp(ui_scaling_target, delta * UI_MOVEMENT_SPEED)
|
|
||||||
|
|
||||||
var ui_rotation_target = -inertia_offset.x - mouse_offset.x * 0.25
|
|
||||||
ui.offset_transform_rotation = lerpf(ui.offset_transform_rotation, ui_rotation_target * UI_MOVEMENT_SENSITIVITY * 0.003, delta * UI_MOVEMENT_SPEED)
|
|
||||||
|
|
||||||
func toggle_menu():
|
|
||||||
if !in_game_menu.visible:
|
|
||||||
ui.visible = false
|
|
||||||
popup_panels.visible = false
|
|
||||||
in_game_menu.visible = true
|
|
||||||
$Cursor.visible = false
|
|
||||||
Input.mouse_mode = Input.MOUSE_MODE_VISIBLE
|
|
||||||
in_menu = true
|
|
||||||
else:
|
|
||||||
ui.visible = true
|
|
||||||
popup_panels.visible = true
|
|
||||||
in_game_menu.visible = false
|
|
||||||
$Cursor.visible = true
|
|
||||||
Input.mouse_mode = Input.MOUSE_MODE_CAPTURED
|
|
||||||
in_menu = false
|
|
||||||
|
|
||||||
func toggle_flashlight():
|
|
||||||
$CameraPivot/PlayerCamera/Flashlight.visible = not $CameraPivot/PlayerCamera/Flashlight.visible
|
|
||||||
var play_sound = FLASHLIGHT_CLICK_SOUNDS.pick_random()
|
|
||||||
|
|
||||||
while play_sound == _current_flashlight_sound:
|
|
||||||
play_sound = FLASHLIGHT_CLICK_SOUNDS.pick_random()
|
|
||||||
|
|
||||||
flashlight_sound_player.do_set_stream(play_sound)
|
|
||||||
flashlight_sound_player.pitch_scale = randf_range(.8, 1.2)
|
|
||||||
flashlight_sound_player.do_play()
|
|
||||||
_current_flashlight_sound = play_sound
|
|
||||||
|
|
||||||
func camera_bobbing(time: float):
|
|
||||||
camera.transform.origin.y = sin(time * CAMERA_BOB_FREQUENCY) * CAMERA_BOB_AMPLITUDE + .75
|
|
||||||
camera.rotation.z += sin(time * CAMERA_BOB_FREQUENCY * .5) * CAMERA_SIDEWAYS_BOB_AMPLITUDE
|
|
||||||
|
|
||||||
func camera_breathing(time: float):
|
|
||||||
camera.transform.origin.y = sin(time * CAMERA_BOB_FREQUENCY) * CAMERA_BOB_AMPLITUDE + .75
|
|
||||||
camera.rotation.x += sin(time * CAMERA_BOB_FREQUENCY) * CAMERA_SIDEWAYS_BOB_AMPLITUDE
|
|
||||||
|
|
||||||
func _process(delta: float) -> void:
|
|
||||||
if Input.is_action_just_pressed("next_item"):
|
|
||||||
next_item()
|
|
||||||
|
|
||||||
if Input.is_action_just_pressed("prev_item"):
|
|
||||||
prev_item()
|
|
||||||
|
|
||||||
if Input.is_action_just_pressed("select_item_1"):
|
|
||||||
select_item(0)
|
|
||||||
|
|
||||||
if Input.is_action_just_pressed("select_item_2"):
|
|
||||||
select_item(1)
|
|
||||||
|
|
||||||
if Input.is_action_just_pressed("select_item_3"):
|
|
||||||
select_item(2)
|
|
||||||
|
|
||||||
if stamina_recharge_on:
|
|
||||||
stamina = move_toward(stamina, 100, .5)
|
|
||||||
|
|
||||||
_mouse_motion.y = clamp(_mouse_motion.y, -1560, 1560)
|
|
||||||
transform.basis = Basis.from_euler(Vector3(0, _mouse_motion.x * -0.001 * LOOK_SENSITIVITY, 0))
|
|
||||||
camera.transform.basis = lerp(camera.transform.basis, Basis.from_euler(Vector3(_mouse_motion.y * -0.001 * LOOK_SENSITIVITY, 0, 0)), delta * 10)
|
|
||||||
|
|
||||||
#handle grabbable panel
|
|
||||||
if grabbable_panel != null:
|
|
||||||
var target_position = $Cursor.position - camera.unproject_position(grabbable_panel_body.global_position)
|
|
||||||
grabbable_panel.position = grabbable_panel.position.lerp(-target_position / 2, delta * 50)
|
|
||||||
|
|
||||||
func _init() -> void:
|
|
||||||
Input.mouse_mode = Input.MOUSE_MODE_CAPTURED
|
|
||||||
|
|
||||||
func _ready() -> void:
|
|
||||||
ui.select_item(0)
|
|
||||||
_last_camera_global_position = camera.global_position
|
|
||||||
|
|
||||||
func next_item():
|
|
||||||
if selected_item + 1 > INVENTORY_MAX - 1:
|
|
||||||
selected_item = 0
|
|
||||||
else:
|
|
||||||
selected_item += 1
|
|
||||||
ui.select_item(selected_item)
|
|
||||||
|
|
||||||
func prev_item():
|
|
||||||
if selected_item - 1 < 0:
|
|
||||||
selected_item = INVENTORY_MAX - 1
|
|
||||||
else:
|
|
||||||
selected_item -= 1
|
|
||||||
ui.select_item(selected_item)
|
|
||||||
|
|
||||||
func select_item(index: int):
|
|
||||||
selected_item = index
|
|
||||||
ui.select_item(index)
|
|
||||||
|
|
||||||
func _input(event):
|
|
||||||
if Input.is_action_just_pressed("open_menu"):
|
|
||||||
toggle_menu()
|
|
||||||
|
|
||||||
if not in_menu:
|
|
||||||
if event is InputEventMouseMotion:
|
|
||||||
if Input.get_mouse_mode() == Input.MOUSE_MODE_CAPTURED:
|
|
||||||
_mouse_motion += event.relative
|
|
||||||
_mouse_motion_delta = event.relative
|
|
||||||
|
|
||||||
if Input.is_action_just_pressed("flashlight"):
|
|
||||||
toggle_flashlight()
|
|
||||||
|
|
||||||
if Input.is_action_just_released("jump") or Input.is_action_just_released("sprint"):
|
|
||||||
$StaminaReset.start()
|
|
||||||
|
|
||||||
if Input.is_action_just_pressed("grab"):
|
|
||||||
if cursor_raycast.is_colliding():
|
|
||||||
var hit_object = cursor_raycast.get_collider()
|
|
||||||
|
|
||||||
if hit_object is RigidBody3D and hit_object.is_in_group("grabbable"):
|
|
||||||
held_object = hit_object
|
|
||||||
held_object.gravity_scale = 0.0
|
|
||||||
held_object.angular_damp = 5.0
|
|
||||||
popup_panels.visible = false
|
|
||||||
|
|
||||||
if Input.is_action_just_released("grab") and held_object != null:
|
|
||||||
held_object.gravity_scale = 1.0
|
|
||||||
held_object.angular_damp = 0.0
|
|
||||||
held_object = null
|
|
||||||
popup_panels.visible = true
|
|
||||||
|
|
||||||
func is_crouched(yes:bool):
|
|
||||||
if yes:
|
|
||||||
crouching = true
|
|
||||||
walking = false
|
|
||||||
running = false
|
|
||||||
else:
|
|
||||||
crouching = false
|
|
||||||
|
|
||||||
func is_walking(yes:bool):
|
|
||||||
if yes:
|
|
||||||
crouching = false
|
|
||||||
walking = true
|
|
||||||
running = false
|
|
||||||
else:
|
|
||||||
walking = false
|
|
||||||
|
|
||||||
func is_running(yes:bool):
|
|
||||||
if yes:
|
|
||||||
crouching = false
|
|
||||||
walking = false
|
|
||||||
running = true
|
|
||||||
else:
|
|
||||||
running = false
|
|
||||||
|
|
||||||
|
|
||||||
func _physics_process(delta: float) -> void:
|
|
||||||
if not is_on_floor():
|
|
||||||
velocity += get_gravity() * delta
|
|
||||||
|
|
||||||
if not in_menu:
|
|
||||||
if Input.is_action_just_pressed("jump") and is_on_floor() and stamina > JUMP_STAMINA_COST:
|
|
||||||
velocity.y = JUMP_VELOCITY
|
|
||||||
stamina -= JUMP_STAMINA_COST
|
|
||||||
stamina_recharge_on = false
|
|
||||||
|
|
||||||
var input_dir = Input.get_vector("left", "right", "forward", "backward")
|
|
||||||
#var direction = (transform.basis * Vector3(input_dir.x, 0, input_dir.y)).normalized()
|
|
||||||
var lean_dir = -Input.get_axis("lean_left", "lean_right") * .1
|
|
||||||
|
|
||||||
if lean_dir:
|
|
||||||
camera_pivot.rotation.z = lerpf(camera_pivot.rotation.z, lean_dir, delta*10)
|
|
||||||
camera_pivot.position.x = lerpf(camera_pivot.position.x, -lean_dir * 5, delta * 7)
|
|
||||||
else:
|
|
||||||
camera_pivot.rotation.z = lerpf(camera_pivot.rotation.z, 0, delta*10)
|
|
||||||
camera_pivot.position.x = lerpf(camera_pivot.position.x, 0, delta * 7)
|
|
||||||
|
|
||||||
var target_speed = SPEED
|
|
||||||
var is_moving = input_dir != Vector2.ZERO
|
|
||||||
|
|
||||||
if Input.is_action_pressed("crouch"):
|
|
||||||
$PlayerHitBox.shape.height = lerpf($PlayerHitBox.shape.height, .5, delta * 5)
|
|
||||||
target_speed *= CROUCH_SPEED_MULTIPLIER
|
|
||||||
is_crouched(true)
|
|
||||||
else:
|
|
||||||
$PlayerHitBox.shape.height = lerpf($PlayerHitBox.shape.height, 2, delta * 10)
|
|
||||||
is_crouched(false)
|
|
||||||
|
|
||||||
if Input.is_action_pressed("sprint") and stamina > 0:
|
|
||||||
target_speed *= SPRINT_MULTIPLIER
|
|
||||||
is_running(true)
|
|
||||||
stamina -= delta * SPRINT_STAMINA_COST
|
|
||||||
stamina_recharge_on = false
|
|
||||||
else:
|
|
||||||
is_running(false)
|
|
||||||
|
|
||||||
|
|
||||||
#apply motion
|
|
||||||
var local_vel = transform.basis.inverse() * velocity
|
|
||||||
var target_local_vel = Vector3(input_dir.x, 0, input_dir.y) * target_speed
|
|
||||||
var accel_rate = 6.0 if is_moving else 9.0
|
|
||||||
local_vel.x = lerpf(local_vel.x, target_local_vel.x, delta * accel_rate)
|
|
||||||
local_vel.z = lerpf(local_vel.z, target_local_vel.z, delta * accel_rate)
|
|
||||||
|
|
||||||
var global_horizontal = transform.basis * local_vel
|
|
||||||
velocity.x = global_horizontal.x
|
|
||||||
velocity.z = global_horizontal.z
|
|
||||||
|
|
||||||
if is_moving and not running and not crouching:
|
|
||||||
is_walking(true)
|
|
||||||
else:
|
|
||||||
is_walking(false)
|
|
||||||
|
|
||||||
ui_handling(delta)
|
|
||||||
|
|
||||||
#handle grabbed object
|
|
||||||
if held_object != null:
|
|
||||||
var target_pos = hold_position.global_position
|
|
||||||
var current_pos = held_object.global_position
|
|
||||||
var direction = target_pos - current_pos
|
|
||||||
|
|
||||||
held_object.linear_velocity = direction * GRAB_POWER
|
|
||||||
|
|
||||||
var current_quat = held_object.global_transform.basis.get_rotation_quaternion()
|
|
||||||
var target_quat = hold_position.global_transform.basis.get_rotation_quaternion()
|
|
||||||
|
|
||||||
var delta_quat = target_quat * current_quat.inverse()
|
|
||||||
var angle = delta_quat.get_angle()
|
|
||||||
var axis = delta_quat.get_axis()
|
|
||||||
|
|
||||||
if angle > PI:
|
|
||||||
angle -= TAU
|
|
||||||
|
|
||||||
held_object.angular_velocity = axis * angle * GRAB_ROTATION_POWER
|
|
||||||
else:
|
|
||||||
velocity.x = lerpf(velocity.x, 0, delta * 10)
|
|
||||||
velocity.z = lerpf(velocity.z, 0, delta * 10)
|
|
||||||
|
|
||||||
move_and_slide()
|
|
||||||
|
|
||||||
func _on_stamina_reset_timeout() -> void:
|
|
||||||
stamina_recharge_on = true
|
|
||||||
|
|
||||||
var grabbable_panel = null
|
|
||||||
var grabbable_panel_body = null
|
|
||||||
|
|
||||||
func _on_grabbable_finder_body_entered(body: Node3D) -> void:
|
|
||||||
if body.is_in_group("grabbable"):
|
|
||||||
grabbable_panel = GRAB_PANEL.instantiate()
|
|
||||||
popup_panels.add_child(grabbable_panel)
|
|
||||||
grabbable_panel_body = body
|
|
||||||
|
|
||||||
func _on_grabbable_finder_body_exited(body: Node3D) -> void:
|
|
||||||
if body == grabbable_panel_body:
|
|
||||||
popup_panels.remove_child(grabbable_panel)
|
|
||||||
grabbable_panel = null
|
|
||||||
grabbable_panel_body = null
|
|
||||||
|
|
@ -31,6 +31,18 @@ window/stretch/aspect="expand"
|
||||||
version_control/plugin_name="GitPlugin"
|
version_control/plugin_name="GitPlugin"
|
||||||
version_control/autoload_on_startup=true
|
version_control/autoload_on_startup=true
|
||||||
|
|
||||||
|
[file_customization]
|
||||||
|
|
||||||
|
folder_colors={
|
||||||
|
"res://addons/": "yellow",
|
||||||
|
"res://assets/": "red",
|
||||||
|
"res://concept/": "purple",
|
||||||
|
"res://maps/": "orange",
|
||||||
|
"res://scenes/": "blue",
|
||||||
|
"res://scripts/": "gray",
|
||||||
|
"res://shaders/": "pink"
|
||||||
|
}
|
||||||
|
|
||||||
[global_group]
|
[global_group]
|
||||||
|
|
||||||
grabbable="this object can be grabbed"
|
grabbable="this object can be grabbed"
|
||||||
|
|
|
||||||
|
|
@ -1,6 +1,6 @@
|
||||||
[gd_scene format=3 uid="uid://c02fkimxlbrje"]
|
[gd_scene format=3 uid="uid://c02fkimxlbrje"]
|
||||||
|
|
||||||
[ext_resource type="Shader" uid="uid://desjwy54cjos8" path="res://player/blur_shader.gdshader" id="1_sseo3"]
|
[ext_resource type="Shader" uid="uid://desjwy54cjos8" path="res://shaders/blur_shader.gdshader" id="1_sseo3"]
|
||||||
|
|
||||||
[sub_resource type="ShaderMaterial" id="ShaderMaterial_aghy0"]
|
[sub_resource type="ShaderMaterial" id="ShaderMaterial_aghy0"]
|
||||||
shader = ExtResource("1_sseo3")
|
shader = ExtResource("1_sseo3")
|
||||||
|
|
@ -1,7 +1,7 @@
|
||||||
[gd_scene format=3 uid="uid://y5f3db7clptv"]
|
[gd_scene format=3 uid="uid://y5f3db7clptv"]
|
||||||
|
|
||||||
[ext_resource type="Script" uid="uid://d0g3mdq54p7oh" path="res://player/in_game_menu_manager.gd" id="1_j5o6r"]
|
[ext_resource type="Script" uid="uid://d0g3mdq54p7oh" path="res://scenes/player/in_game_menu_manager.gd" id="1_s4bu6"]
|
||||||
[ext_resource type="Shader" uid="uid://desjwy54cjos8" path="res://player/blur_shader.gdshader" id="1_x6hgt"]
|
[ext_resource type="Shader" uid="uid://desjwy54cjos8" path="res://shaders/blur_shader.gdshader" id="1_x6hgt"]
|
||||||
|
|
||||||
[sub_resource type="ShaderMaterial" id="ShaderMaterial_yf5fn"]
|
[sub_resource type="ShaderMaterial" id="ShaderMaterial_yf5fn"]
|
||||||
shader = ExtResource("1_x6hgt")
|
shader = ExtResource("1_x6hgt")
|
||||||
|
|
@ -14,7 +14,7 @@ anchor_right = 1.0
|
||||||
anchor_bottom = 1.0
|
anchor_bottom = 1.0
|
||||||
grow_horizontal = 2
|
grow_horizontal = 2
|
||||||
grow_vertical = 2
|
grow_vertical = 2
|
||||||
script = ExtResource("1_j5o6r")
|
script = ExtResource("1_s4bu6")
|
||||||
|
|
||||||
[node name="Panel" type="Panel" parent="." unique_id=501811587]
|
[node name="Panel" type="Panel" parent="." unique_id=501811587]
|
||||||
material = SubResource("ShaderMaterial_yf5fn")
|
material = SubResource("ShaderMaterial_yf5fn")
|
||||||
95
scenes/player/input_controller_component.gd
Normal file
95
scenes/player/input_controller_component.gd
Normal file
|
|
@ -0,0 +1,95 @@
|
||||||
|
extends Node
|
||||||
|
|
||||||
|
@export_category("Grabbing")
|
||||||
|
@export var GRAB_POWER: float = 15.0 ##how fast the grabbed object snaps to the hold position
|
||||||
|
@export var GRAB_ROTATION_POWER: float = 15.0 ##how fast the object rotates towards the player
|
||||||
|
@export var GRAB_PANEL: PackedScene ##panel that goes over the grabbable object to show its grabbable
|
||||||
|
|
||||||
|
@onready var ui_handler: Node = %UiHandler
|
||||||
|
@onready var player_state: Node = %PlayerState
|
||||||
|
@onready var flashlight: SpotLight3D = %Flashlight
|
||||||
|
@onready var sound_controller: Node = %SoundController
|
||||||
|
@onready var cursor_raycast: RayCast3D = %CursorRaycast
|
||||||
|
@onready var popup_panels: Control = %PopupPanels
|
||||||
|
@onready var stamina_reset: Timer = %StaminaReset
|
||||||
|
@onready var player: PlayerCharacter = $"../.."
|
||||||
|
@onready var procedural_camera_mover: Node = %ProceduralCameraMover
|
||||||
|
@onready var camera: Camera3D = %PlayerCamera
|
||||||
|
@onready var hold_position: Marker3D = %HoldPosition
|
||||||
|
|
||||||
|
|
||||||
|
var sensitivity: float = 0.002
|
||||||
|
|
||||||
|
var _mouse_motion: Vector2 = Vector2.ZERO
|
||||||
|
var _mouse_motion_delta: Vector2 = Vector2.ZERO
|
||||||
|
|
||||||
|
var held_object: RigidBody3D = null
|
||||||
|
|
||||||
|
func toggle_flashlight():
|
||||||
|
flashlight.visible = !flashlight.visible
|
||||||
|
sound_controller.play_flashlight_sound()
|
||||||
|
|
||||||
|
func _input(event):
|
||||||
|
if Input.is_action_just_pressed("open_menu"):
|
||||||
|
ui_handler.toggle_menu()
|
||||||
|
|
||||||
|
if not player_state.in_menu:
|
||||||
|
if event is InputEventMouseMotion:
|
||||||
|
if Input.get_mouse_mode() == Input.MOUSE_MODE_CAPTURED:
|
||||||
|
_mouse_motion += event.relative
|
||||||
|
_mouse_motion_delta = event.relative
|
||||||
|
|
||||||
|
if Input.is_action_just_pressed("flashlight"):
|
||||||
|
toggle_flashlight()
|
||||||
|
|
||||||
|
if Input.is_action_just_released("jump") or Input.is_action_just_released("sprint"):
|
||||||
|
stamina_reset.start()
|
||||||
|
|
||||||
|
if Input.is_action_just_pressed("grab"):
|
||||||
|
if cursor_raycast.is_colliding():
|
||||||
|
var hit_object = cursor_raycast.get_collider()
|
||||||
|
|
||||||
|
if hit_object is RigidBody3D and hit_object.is_in_group("grabbable"):
|
||||||
|
held_object = hit_object
|
||||||
|
held_object.gravity_scale = 0.0
|
||||||
|
held_object.angular_damp = 5.0
|
||||||
|
popup_panels.visible = false
|
||||||
|
|
||||||
|
if Input.is_action_just_released("grab") and held_object != null:
|
||||||
|
held_object.gravity_scale = 1.0
|
||||||
|
held_object.angular_damp = 0.0
|
||||||
|
held_object = null
|
||||||
|
popup_panels.visible = true
|
||||||
|
|
||||||
|
func _physics_process(delta: float) -> void:
|
||||||
|
#handle grabbed object
|
||||||
|
if held_object != null:
|
||||||
|
var target_pos = hold_position.global_position
|
||||||
|
var current_pos = held_object.global_position
|
||||||
|
var direction = target_pos - current_pos
|
||||||
|
|
||||||
|
held_object.linear_velocity = direction * GRAB_POWER
|
||||||
|
|
||||||
|
var current_quat = held_object.global_transform.basis.get_rotation_quaternion()
|
||||||
|
var target_quat = hold_position.global_transform.basis.get_rotation_quaternion()
|
||||||
|
|
||||||
|
var delta_quat = target_quat * current_quat.inverse()
|
||||||
|
var angle = delta_quat.get_angle()
|
||||||
|
var axis = delta_quat.get_axis()
|
||||||
|
|
||||||
|
if angle > PI:
|
||||||
|
angle -= TAU
|
||||||
|
|
||||||
|
held_object.angular_velocity = axis * angle * GRAB_ROTATION_POWER
|
||||||
|
|
||||||
|
func _process(delta: float) -> void:
|
||||||
|
_mouse_motion.y = clamp(_mouse_motion.y, -1560, 1560)
|
||||||
|
player.transform.basis = Basis.from_euler(Vector3(0, _mouse_motion.x * -0.001 * procedural_camera_mover.LOOK_SENSITIVITY, 0))
|
||||||
|
camera.transform.basis = lerp(camera.transform.basis, Basis.from_euler(Vector3(_mouse_motion.y * -0.001 * procedural_camera_mover.LOOK_SENSITIVITY, 0, 0)), delta * 10)
|
||||||
|
|
||||||
|
#func _unhandled_input(event: InputEvent) -> void:
|
||||||
|
#if event is InputEventMouseMotion:
|
||||||
|
#player_camera.rotate_y(-event.relative.x * sensitivity)
|
||||||
|
#player_camera.rotate_x(-event.relative.y * sensitivity)
|
||||||
|
#player_camera.rotation.x = clamp(player_camera.rotation.x, deg_to_rad(-90), deg_to_rad(90))
|
||||||
|
#player_camera.rotation.z = 0
|
||||||
1
scenes/player/input_controller_component.gd.uid
Normal file
1
scenes/player/input_controller_component.gd.uid
Normal file
|
|
@ -0,0 +1 @@
|
||||||
|
uid://bvvwwkswavy5x
|
||||||
100
scenes/player/movement_component.gd
Normal file
100
scenes/player/movement_component.gd
Normal file
|
|
@ -0,0 +1,100 @@
|
||||||
|
extends Node
|
||||||
|
|
||||||
|
@export_category("Movement")
|
||||||
|
@export var SPEED = 5.0 ##base walking speed
|
||||||
|
@export var SPRINT_MULTIPLIER = 1.5 ##how much faster should you move, when sprinting
|
||||||
|
@export var SPRINT_STAMINA_COST = 10.0 ##how much stamina should be consumed each frame while sprinting (delta * SPRINT_STAMINA_COST)
|
||||||
|
@export var CROUCH_SPEED_MULTIPLIER = .5 ##how much slower you should be going while crouching
|
||||||
|
|
||||||
|
@export_category("Jump")
|
||||||
|
@export var JUMP_VELOCITY = 4.5 ##how high you can jump
|
||||||
|
@export var JUMP_STAMINA_COST = 10 ##how much stamina each jump consumes
|
||||||
|
|
||||||
|
@export_category("Camera")
|
||||||
|
@export var LOOK_SENSITIVITY = 1.0 ##camera sensitivity
|
||||||
|
@export var CAMERA_VELOCITY_MULTIPLIER = 1.5 ##how heavy should the UI movement feel
|
||||||
|
|
||||||
|
|
||||||
|
var _mouse_motion: Vector2 = Vector2.ZERO
|
||||||
|
|
||||||
|
@onready var camera_pivot: Node3D = %CameraPivot
|
||||||
|
@onready var player_camera: Camera3D = %PlayerCamera
|
||||||
|
@onready var player: PlayerCharacter = $"../.."
|
||||||
|
@onready var player_state: Node = %PlayerState
|
||||||
|
@onready var player_properties: Node = %PlayerProperties
|
||||||
|
@onready var procedural_camera_mover: Node = %ProceduralCameraMover
|
||||||
|
@onready var player_hit_box: CollisionShape3D = $"../../PlayerHitBox"
|
||||||
|
|
||||||
|
# Called when the node enters the scene tree for the first time.
|
||||||
|
func _ready() -> void:
|
||||||
|
Input.mouse_mode = Input.MOUSE_MODE_CAPTURED
|
||||||
|
|
||||||
|
func _physics_process(delta: float) -> void:
|
||||||
|
if not player.is_on_floor():
|
||||||
|
player.velocity += player.get_gravity() * delta
|
||||||
|
|
||||||
|
if not player_state.in_menu:
|
||||||
|
if Input.is_action_just_pressed("jump") and player.is_on_floor() and player_properties.stamina > JUMP_STAMINA_COST:
|
||||||
|
player.velocity.y = JUMP_VELOCITY
|
||||||
|
player_properties.stamina -= JUMP_STAMINA_COST
|
||||||
|
player_properties.stamina_recharge_off()
|
||||||
|
|
||||||
|
var input_dir = Input.get_vector("left", "right", "forward", "backward")
|
||||||
|
#var direction = (transform.basis * Vector3(input_dir.x, 0, input_dir.y)).normalized()
|
||||||
|
var lean_dir = -Input.get_axis("lean_left", "lean_right") * .1
|
||||||
|
|
||||||
|
if lean_dir:
|
||||||
|
camera_pivot.rotation.z = lerpf(camera_pivot.rotation.z, lean_dir, delta*10)
|
||||||
|
camera_pivot.position.x = lerpf(camera_pivot.position.x, -lean_dir * 5, delta * 7)
|
||||||
|
else:
|
||||||
|
camera_pivot.rotation.z = lerpf(camera_pivot.rotation.z, 0, delta*10)
|
||||||
|
camera_pivot.position.x = lerpf(camera_pivot.position.x, 0, delta * 7)
|
||||||
|
|
||||||
|
var target_speed = SPEED
|
||||||
|
var is_moving = input_dir != Vector2.ZERO
|
||||||
|
|
||||||
|
if Input.is_action_pressed("crouch"):
|
||||||
|
player_hit_box.shape.height = lerpf(player_hit_box.shape.height, .5, delta * 5)
|
||||||
|
target_speed *= CROUCH_SPEED_MULTIPLIER
|
||||||
|
player_state.is_crouched(true)
|
||||||
|
else:
|
||||||
|
player_hit_box.shape.height = lerpf(player_hit_box.shape.height, 2, delta * 10)
|
||||||
|
player_state.is_crouched(false)
|
||||||
|
|
||||||
|
if Input.is_action_pressed("sprint") and player_properties.stamina > 0:
|
||||||
|
target_speed *= SPRINT_MULTIPLIER
|
||||||
|
player_state.is_running(true)
|
||||||
|
player_properties.stamina -= delta * SPRINT_STAMINA_COST
|
||||||
|
player_properties.stamina_recharge_off()
|
||||||
|
else:
|
||||||
|
player_state.is_running(false)
|
||||||
|
|
||||||
|
#apply motion
|
||||||
|
var local_vel = player.transform.basis.inverse() * player.velocity
|
||||||
|
var target_local_vel = Vector3(player_camera.transform.basis * Vector3(input_dir.x, 0, input_dir.y)) * target_speed
|
||||||
|
var accel_rate = 6.0 if is_moving else 9.0
|
||||||
|
local_vel.x = lerpf(local_vel.x, target_local_vel.x, delta * accel_rate)
|
||||||
|
local_vel.z = lerpf(local_vel.z, target_local_vel.z, delta * accel_rate)
|
||||||
|
|
||||||
|
var global_horizontal = player.transform.basis * local_vel
|
||||||
|
player.velocity.x = global_horizontal.x
|
||||||
|
player.velocity.z = global_horizontal.z
|
||||||
|
|
||||||
|
if is_moving and not player_state.running and not player_state.crouching:
|
||||||
|
player_state.is_walking(true)
|
||||||
|
else:
|
||||||
|
player_state.is_walking(false)
|
||||||
|
|
||||||
|
procedural_camera_mover.do(delta)
|
||||||
|
else:
|
||||||
|
player.velocity.x = lerpf(player.velocity.x, 0, delta * 10)
|
||||||
|
player.velocity.z = lerpf(player.velocity.z, 0, delta * 10)
|
||||||
|
|
||||||
|
player.move_and_slide()
|
||||||
|
|
||||||
|
# Called every frame. 'delta' is the elapsed time since the previous frame.
|
||||||
|
#func _process(delta: float) -> void:
|
||||||
|
#_mouse_motion.y = clamp(_mouse_motion.y, -1560, 1560)
|
||||||
|
#player.transform.basis = Basis.from_euler(Vector3(0, _mouse_motion.x * -0.001 * LOOK_SENSITIVITY, 0))
|
||||||
|
#player.transform.basis = lerp(player_camera.transform.basis, Basis.from_euler(Vector3(_mouse_motion.y * -0.001 * LOOK_SENSITIVITY, 0, 0)), delta * 10)
|
||||||
|
#
|
||||||
1
scenes/player/movement_component.gd.uid
Normal file
1
scenes/player/movement_component.gd.uid
Normal file
|
|
@ -0,0 +1 @@
|
||||||
|
uid://dr2lwciaohf6f
|
||||||
|
|
@ -1,9 +1,9 @@
|
||||||
[gd_scene format=3 uid="uid://kqq30y24c6kd"]
|
[gd_scene format=3 uid="uid://kqq30y24c6kd"]
|
||||||
|
|
||||||
[ext_resource type="Script" uid="uid://l2rc674shj03" path="res://player/player_manager.gd" id="1_eqqp1"]
|
[ext_resource type="Script" uid="uid://l2rc674shj03" path="res://scenes/player/player_manager.gd" id="1_eqqp1"]
|
||||||
[ext_resource type="AudioStream" uid="uid://he4huk3fb0vm" path="res://assets/sounds/walking/normal/normal walk-001.wav" id="2_32hag"]
|
[ext_resource type="AudioStream" uid="uid://he4huk3fb0vm" path="res://assets/sounds/walking/normal/normal walk-001.wav" id="2_32hag"]
|
||||||
[ext_resource type="PackedScene" uid="uid://bsccbqq04umeg" path="res://player/player_ui.tscn" id="2_rkbax"]
|
[ext_resource type="PackedScene" uid="uid://bsccbqq04umeg" path="res://scenes/player/player_ui.tscn" id="2_rkbax"]
|
||||||
[ext_resource type="PackedScene" uid="uid://y5f3db7clptv" path="res://player/in_game_menu.tscn" id="3_g1dw6"]
|
[ext_resource type="PackedScene" uid="uid://y5f3db7clptv" path="res://scenes/player/in_game_menu.tscn" id="3_g1dw6"]
|
||||||
[ext_resource type="AudioStream" uid="uid://db5upx7hn27qe" path="res://assets/sounds/walking/normal/normal walk-002.wav" id="3_tqiix"]
|
[ext_resource type="AudioStream" uid="uid://db5upx7hn27qe" path="res://assets/sounds/walking/normal/normal walk-002.wav" id="3_tqiix"]
|
||||||
[ext_resource type="AudioStream" uid="uid://b00bi5iffp5lf" path="res://assets/sounds/walking/normal/normal walk-003.wav" id="4_e7oew"]
|
[ext_resource type="AudioStream" uid="uid://b00bi5iffp5lf" path="res://assets/sounds/walking/normal/normal walk-003.wav" id="4_e7oew"]
|
||||||
[ext_resource type="AudioStream" uid="uid://6slw3x6cnmim" path="res://assets/sounds/walking/normal/normal walk-004.wav" id="5_c35mf"]
|
[ext_resource type="AudioStream" uid="uid://6slw3x6cnmim" path="res://assets/sounds/walking/normal/normal walk-004.wav" id="5_c35mf"]
|
||||||
|
|
@ -58,10 +58,17 @@
|
||||||
[ext_resource type="AudioStream" uid="uid://bxebqhgkkeqhp" path="res://assets/sounds/flashlight/flashlight-click-005.wav" id="55_7l6ig"]
|
[ext_resource type="AudioStream" uid="uid://bxebqhgkkeqhp" path="res://assets/sounds/flashlight/flashlight-click-005.wav" id="55_7l6ig"]
|
||||||
[ext_resource type="AudioStream" uid="uid://ctmut3x6w0sj1" path="res://assets/sounds/flashlight/flashlight-click-006.wav" id="56_j3r50"]
|
[ext_resource type="AudioStream" uid="uid://ctmut3x6w0sj1" path="res://assets/sounds/flashlight/flashlight-click-006.wav" id="56_j3r50"]
|
||||||
[ext_resource type="AudioStream" uid="uid://dsgr417h5gcn0" path="res://assets/sounds/flashlight/flashlight-click-009.wav" id="59_do7qw"]
|
[ext_resource type="AudioStream" uid="uid://dsgr417h5gcn0" path="res://assets/sounds/flashlight/flashlight-click-009.wav" id="59_do7qw"]
|
||||||
[ext_resource type="PackedScene" uid="uid://c02fkimxlbrje" path="res://player/grab_prompt.tscn" id="59_p5tca"]
|
[ext_resource type="PackedScene" uid="uid://c02fkimxlbrje" path="res://scenes/player/grab_prompt.tscn" id="59_p5tca"]
|
||||||
|
[ext_resource type="Script" uid="uid://dr2lwciaohf6f" path="res://scenes/player/movement_component.gd" id="60_s3g0c"]
|
||||||
[ext_resource type="AudioStream" uid="uid://b8ppwr5vwhej0" path="res://assets/sounds/flashlight/flashlight-click-011.wav" id="61_8rogd"]
|
[ext_resource type="AudioStream" uid="uid://b8ppwr5vwhej0" path="res://assets/sounds/flashlight/flashlight-click-011.wav" id="61_8rogd"]
|
||||||
|
[ext_resource type="Script" uid="uid://cjk6a0da11ge6" path="res://scenes/player/procedural_camera_mover_component.gd" id="61_hggc2"]
|
||||||
[ext_resource type="AudioStream" uid="uid://dlyhi0c2bw5b2" path="res://assets/sounds/flashlight/flashlight-click-012.wav" id="62_48p26"]
|
[ext_resource type="AudioStream" uid="uid://dlyhi0c2bw5b2" path="res://assets/sounds/flashlight/flashlight-click-012.wav" id="62_48p26"]
|
||||||
|
[ext_resource type="Script" uid="uid://v8er7yn0hdh8" path="res://scenes/player/sound_controller_component.gd" id="62_b2j0d"]
|
||||||
[ext_resource type="Script" uid="uid://y8x4svl5kej2" path="res://addons/spatial_audio_3d/spatial_audio_3d.gd" id="62_jbx34"]
|
[ext_resource type="Script" uid="uid://y8x4svl5kej2" path="res://addons/spatial_audio_3d/spatial_audio_3d.gd" id="62_jbx34"]
|
||||||
|
[ext_resource type="Script" uid="uid://7aa26wi66kqq" path="res://scenes/player/ui_handler_component.gd" id="63_7l6ig"]
|
||||||
|
[ext_resource type="Script" uid="uid://bvvwwkswavy5x" path="res://scenes/player/input_controller_component.gd" id="64_j3r50"]
|
||||||
|
[ext_resource type="Script" uid="uid://7hmwhf7acwpj" path="res://scenes/player/state_handler_component.gd" id="65_kssj8"]
|
||||||
|
[ext_resource type="Script" uid="uid://cbdvyelf7nb1u" path="res://scenes/player/player_properties.gd" id="66_8lfxt"]
|
||||||
|
|
||||||
[sub_resource type="CapsuleShape3D" id="CapsuleShape3D_g4v7s"]
|
[sub_resource type="CapsuleShape3D" id="CapsuleShape3D_g4v7s"]
|
||||||
|
|
||||||
|
|
@ -96,16 +103,55 @@ SHUFFLE_FOOTSTEP_SOUNDS = Array[AudioStreamWAV]([ExtResource("44_qavcc"), ExtRes
|
||||||
FLASHLIGHT_CLICK_SOUNDS = Array[AudioStreamWAV]([ExtResource("51_pjwc4"), ExtResource("52_or4qq"), ExtResource("53_hggc2"), ExtResource("55_7l6ig"), ExtResource("56_j3r50"), ExtResource("59_do7qw"), ExtResource("61_8rogd"), ExtResource("62_48p26")])
|
FLASHLIGHT_CLICK_SOUNDS = Array[AudioStreamWAV]([ExtResource("51_pjwc4"), ExtResource("52_or4qq"), ExtResource("53_hggc2"), ExtResource("55_7l6ig"), ExtResource("56_j3r50"), ExtResource("59_do7qw"), ExtResource("61_8rogd"), ExtResource("62_48p26")])
|
||||||
GRAB_PANEL = ExtResource("59_p5tca")
|
GRAB_PANEL = ExtResource("59_p5tca")
|
||||||
|
|
||||||
|
[node name="Components" type="Node" parent="." unique_id=1652812621]
|
||||||
|
|
||||||
|
[node name="Movement" type="Node" parent="Components" unique_id=1821617467]
|
||||||
|
unique_name_in_owner = true
|
||||||
|
script = ExtResource("60_s3g0c")
|
||||||
|
|
||||||
|
[node name="ProceduralCameraMover" type="Node" parent="Components" unique_id=899836528]
|
||||||
|
unique_name_in_owner = true
|
||||||
|
script = ExtResource("61_hggc2")
|
||||||
|
|
||||||
|
[node name="SoundController" type="Node" parent="Components" unique_id=1286506274]
|
||||||
|
unique_name_in_owner = true
|
||||||
|
script = ExtResource("62_b2j0d")
|
||||||
|
NORMAL_FOOTSTEP_SOUNDS = Array[AudioStreamWAV]([ExtResource("2_32hag"), ExtResource("3_tqiix"), ExtResource("4_e7oew"), ExtResource("5_c35mf"), ExtResource("6_65viv"), ExtResource("7_x7c3f"), ExtResource("8_bjvpn"), ExtResource("9_s7qer"), ExtResource("10_g4c7l"), ExtResource("11_knn7v"), ExtResource("12_7pqkx"), ExtResource("13_uw77l"), ExtResource("14_rptt4")])
|
||||||
|
HEAVY_FOOTSTEP_SOUNDS = Array[AudioStreamWAV]([ExtResource("15_n0b8q"), ExtResource("16_jfgyi"), ExtResource("17_237xx"), ExtResource("18_wpyo2"), ExtResource("19_7crtr"), ExtResource("20_vgvch"), ExtResource("21_a1u5o"), ExtResource("22_3dxkp"), ExtResource("23_6wior"), ExtResource("24_p5tca"), ExtResource("25_jbx34"), ExtResource("26_s3g0c"), ExtResource("27_35wys"), ExtResource("28_pjwc4"), ExtResource("29_or4qq"), ExtResource("30_hggc2")])
|
||||||
|
LIGHT_FOOTSTEP_SOUNDS = Array[AudioStreamWAV]([ExtResource("31_b2j0d"), ExtResource("32_7l6ig"), ExtResource("33_j3r50"), ExtResource("34_utr5e"), ExtResource("35_kewli"), ExtResource("36_do7qw"), ExtResource("37_2h6tc"), ExtResource("38_8rogd"), ExtResource("39_48p26"), ExtResource("40_anp34"), ExtResource("41_jdjat"), ExtResource("42_j420s"), ExtResource("43_kcq4v")])
|
||||||
|
SHUFFLE_FOOTSTEP_SOUNDS = Array[AudioStreamWAV]([ExtResource("44_qavcc"), ExtResource("45_bd26m"), ExtResource("46_lufic"), ExtResource("47_nxclr"), ExtResource("48_onxu2"), ExtResource("49_gci7n"), ExtResource("50_tcwf7")])
|
||||||
|
FLASHLIGHT_CLICK_SOUNDS = Array[AudioStreamWAV]([ExtResource("51_pjwc4"), ExtResource("52_or4qq"), ExtResource("53_hggc2"), ExtResource("55_7l6ig"), ExtResource("56_j3r50"), ExtResource("59_do7qw"), ExtResource("61_8rogd"), ExtResource("62_48p26")])
|
||||||
|
|
||||||
|
[node name="UiHandler" type="Node" parent="Components" unique_id=1264775993]
|
||||||
|
unique_name_in_owner = true
|
||||||
|
script = ExtResource("63_7l6ig")
|
||||||
|
GRAB_PANEL = ExtResource("59_p5tca")
|
||||||
|
|
||||||
|
[node name="InputController" type="Node" parent="Components" unique_id=1680856401]
|
||||||
|
unique_name_in_owner = true
|
||||||
|
script = ExtResource("64_j3r50")
|
||||||
|
|
||||||
|
[node name="PlayerState" type="Node" parent="Components" unique_id=1564123661]
|
||||||
|
unique_name_in_owner = true
|
||||||
|
script = ExtResource("65_kssj8")
|
||||||
|
|
||||||
|
[node name="PlayerProperties" type="Node" parent="Components" unique_id=1984191860]
|
||||||
|
unique_name_in_owner = true
|
||||||
|
script = ExtResource("66_8lfxt")
|
||||||
|
|
||||||
[node name="PlayerHitBox" type="CollisionShape3D" parent="." unique_id=1513955228]
|
[node name="PlayerHitBox" type="CollisionShape3D" parent="." unique_id=1513955228]
|
||||||
shape = SubResource("CapsuleShape3D_g4v7s")
|
shape = SubResource("CapsuleShape3D_g4v7s")
|
||||||
|
|
||||||
[node name="CameraPivot" type="Node3D" parent="." unique_id=963377832]
|
[node name="CameraPivot" type="Node3D" parent="." unique_id=963377832]
|
||||||
|
unique_name_in_owner = true
|
||||||
|
|
||||||
[node name="PlayerCamera" type="Camera3D" parent="CameraPivot" unique_id=303347613]
|
[node name="PlayerCamera" type="Camera3D" parent="CameraPivot" unique_id=303347613]
|
||||||
|
unique_name_in_owner = true
|
||||||
transform = Transform3D(1, 0, 0, 0, 1, 0, 0, 0, 1, 0, 0.75045073, 0)
|
transform = Transform3D(1, 0, 0, 0, 1, 0, 0, 0, 1, 0, 0.75045073, 0)
|
||||||
current = true
|
current = true
|
||||||
|
|
||||||
[node name="Flashlight" type="SpotLight3D" parent="CameraPivot/PlayerCamera" unique_id=1036641941]
|
[node name="Flashlight" type="SpotLight3D" parent="CameraPivot/PlayerCamera" unique_id=1036641941]
|
||||||
|
unique_name_in_owner = true
|
||||||
transform = Transform3D(1, 0, 0, 0, 1, 0, 0, 0, 1, -0.025482714, 0.16212702, -0.019012451)
|
transform = Transform3D(1, 0, 0, 0, 1, 0, 0, 0, 1, -0.025482714, 0.16212702, -0.019012451)
|
||||||
light_color = Color(0.97844106, 0.88945234, 0, 1)
|
light_color = Color(0.97844106, 0.88945234, 0, 1)
|
||||||
light_indirect_energy = 3.519
|
light_indirect_energy = 3.519
|
||||||
|
|
@ -116,10 +162,12 @@ spot_angle = 18.581459
|
||||||
spot_angle_attenuation = 1.9318668
|
spot_angle_attenuation = 1.9318668
|
||||||
|
|
||||||
[node name="CursorRaycast" type="RayCast3D" parent="CameraPivot/PlayerCamera" unique_id=1978798208]
|
[node name="CursorRaycast" type="RayCast3D" parent="CameraPivot/PlayerCamera" unique_id=1978798208]
|
||||||
|
unique_name_in_owner = true
|
||||||
transform = Transform3D(1, 0, 0, 0, -4.371139e-08, -1, 0, 1, -4.371139e-08, 0, 0, 0)
|
transform = Transform3D(1, 0, 0, 0, -4.371139e-08, -1, 0, 1, -4.371139e-08, 0, 0, 0)
|
||||||
target_position = Vector3(0, -2, 0)
|
target_position = Vector3(0, -2, 0)
|
||||||
|
|
||||||
[node name="HoldPosition" type="Marker3D" parent="CameraPivot/PlayerCamera" unique_id=425231379]
|
[node name="HoldPosition" type="Marker3D" parent="CameraPivot/PlayerCamera" unique_id=425231379]
|
||||||
|
unique_name_in_owner = true
|
||||||
transform = Transform3D(1, 0, 0, 0, 1, 0, 0, 0, 1, 0, 0, -1.5698267)
|
transform = Transform3D(1, 0, 0, 0, 1, 0, 0, 0, 1, 0, 0, -1.5698267)
|
||||||
|
|
||||||
[node name="GrabbableFinder" type="Area3D" parent="CameraPivot/PlayerCamera" unique_id=988433915]
|
[node name="GrabbableFinder" type="Area3D" parent="CameraPivot/PlayerCamera" unique_id=988433915]
|
||||||
|
|
@ -133,11 +181,14 @@ transform = Transform3D(1, 0, 0, 0, 1, 0, 0, 0, 1, 0, 0.7621309, 0)
|
||||||
doppler_tracking = 2
|
doppler_tracking = 2
|
||||||
|
|
||||||
[node name="PlayerUi" parent="." unique_id=454848358 instance=ExtResource("2_rkbax")]
|
[node name="PlayerUi" parent="." unique_id=454848358 instance=ExtResource("2_rkbax")]
|
||||||
|
unique_name_in_owner = true
|
||||||
|
|
||||||
[node name="InGameMenu" parent="." unique_id=1952418949 instance=ExtResource("3_g1dw6")]
|
[node name="InGameMenu" parent="." unique_id=1952418949 instance=ExtResource("3_g1dw6")]
|
||||||
|
unique_name_in_owner = true
|
||||||
visible = false
|
visible = false
|
||||||
|
|
||||||
[node name="PopupPanels" type="Control" parent="." unique_id=305048227]
|
[node name="PopupPanels" type="Control" parent="." unique_id=305048227]
|
||||||
|
unique_name_in_owner = true
|
||||||
layout_mode = 3
|
layout_mode = 3
|
||||||
anchors_preset = 15
|
anchors_preset = 15
|
||||||
anchor_right = 1.0
|
anchor_right = 1.0
|
||||||
|
|
@ -147,6 +198,7 @@ grow_vertical = 2
|
||||||
mouse_filter = 2
|
mouse_filter = 2
|
||||||
|
|
||||||
[node name="Cursor" type="TextureRect" parent="." unique_id=785138925]
|
[node name="Cursor" type="TextureRect" parent="." unique_id=785138925]
|
||||||
|
unique_name_in_owner = true
|
||||||
anchors_preset = 8
|
anchors_preset = 8
|
||||||
anchor_left = 0.5
|
anchor_left = 0.5
|
||||||
anchor_top = 0.5
|
anchor_top = 0.5
|
||||||
|
|
@ -164,12 +216,14 @@ texture = SubResource("CurveXYZTexture_d0u6y")
|
||||||
expand_mode = 1
|
expand_mode = 1
|
||||||
|
|
||||||
[node name="StaminaReset" type="Timer" parent="." unique_id=1815815085]
|
[node name="StaminaReset" type="Timer" parent="." unique_id=1815815085]
|
||||||
|
unique_name_in_owner = true
|
||||||
wait_time = 2.0
|
wait_time = 2.0
|
||||||
one_shot = true
|
one_shot = true
|
||||||
|
|
||||||
[node name="SoundEmitters" type="Node3D" parent="." unique_id=661429541]
|
[node name="SoundEmitters" type="Node3D" parent="." unique_id=661429541]
|
||||||
|
|
||||||
[node name="LeftFoot" type="AudioStreamPlayer3D" parent="SoundEmitters" unique_id=49863314]
|
[node name="LeftFoot" type="AudioStreamPlayer3D" parent="SoundEmitters" unique_id=49863314]
|
||||||
|
unique_name_in_owner = true
|
||||||
transform = Transform3D(1, 0, 0, 0, 1, 0, 0, 0, 1, -0.43042383, -0.90646136, 0)
|
transform = Transform3D(1, 0, 0, 0, 1, 0, 0, 0, 1, -0.43042383, -0.90646136, 0)
|
||||||
area_mask = 17
|
area_mask = 17
|
||||||
doppler_tracking = 2
|
doppler_tracking = 2
|
||||||
|
|
@ -183,6 +237,7 @@ roomsize_multiplicator = 20.0
|
||||||
metadata/_custom_type_script = "uid://y8x4svl5kej2"
|
metadata/_custom_type_script = "uid://y8x4svl5kej2"
|
||||||
|
|
||||||
[node name="LeftFootTexture" type="AudioStreamPlayer3D" parent="SoundEmitters/LeftFoot" unique_id=368492]
|
[node name="LeftFootTexture" type="AudioStreamPlayer3D" parent="SoundEmitters/LeftFoot" unique_id=368492]
|
||||||
|
unique_name_in_owner = true
|
||||||
transform = Transform3D(1, 0, 0, 0, 1, 0, 0, 0, 1, 0.032262772, 0.019309282, 0)
|
transform = Transform3D(1, 0, 0, 0, 1, 0, 0, 0, 1, 0.032262772, 0.019309282, 0)
|
||||||
area_mask = 17
|
area_mask = 17
|
||||||
script = ExtResource("62_jbx34")
|
script = ExtResource("62_jbx34")
|
||||||
|
|
@ -195,6 +250,7 @@ roomsize_multiplicator = 20.0
|
||||||
metadata/_custom_type_script = "uid://y8x4svl5kej2"
|
metadata/_custom_type_script = "uid://y8x4svl5kej2"
|
||||||
|
|
||||||
[node name="RightFoot" type="AudioStreamPlayer3D" parent="SoundEmitters" unique_id=622217520]
|
[node name="RightFoot" type="AudioStreamPlayer3D" parent="SoundEmitters" unique_id=622217520]
|
||||||
|
unique_name_in_owner = true
|
||||||
transform = Transform3D(1, 0, 0, 0, 1, 0, 0, 0, 1, 0.3428033, -0.8860581, 0)
|
transform = Transform3D(1, 0, 0, 0, 1, 0, 0, 0, 1, 0.3428033, -0.8860581, 0)
|
||||||
area_mask = 17
|
area_mask = 17
|
||||||
script = ExtResource("62_jbx34")
|
script = ExtResource("62_jbx34")
|
||||||
|
|
@ -207,6 +263,7 @@ roomsize_multiplicator = 20.0
|
||||||
metadata/_custom_type_script = "uid://y8x4svl5kej2"
|
metadata/_custom_type_script = "uid://y8x4svl5kej2"
|
||||||
|
|
||||||
[node name="RightFootTexture" type="AudioStreamPlayer3D" parent="SoundEmitters/RightFoot" unique_id=721446442]
|
[node name="RightFootTexture" type="AudioStreamPlayer3D" parent="SoundEmitters/RightFoot" unique_id=721446442]
|
||||||
|
unique_name_in_owner = true
|
||||||
area_mask = 17
|
area_mask = 17
|
||||||
script = ExtResource("62_jbx34")
|
script = ExtResource("62_jbx34")
|
||||||
reverb_volume_db = -12.0
|
reverb_volume_db = -12.0
|
||||||
|
|
@ -218,6 +275,7 @@ roomsize_multiplicator = 20.0
|
||||||
metadata/_custom_type_script = "uid://y8x4svl5kej2"
|
metadata/_custom_type_script = "uid://y8x4svl5kej2"
|
||||||
|
|
||||||
[node name="FlashlightSound" type="AudioStreamPlayer3D" parent="SoundEmitters" unique_id=1011459854]
|
[node name="FlashlightSound" type="AudioStreamPlayer3D" parent="SoundEmitters" unique_id=1011459854]
|
||||||
|
unique_name_in_owner = true
|
||||||
transform = Transform3D(1, 0, 0, 0, 1, 0, 0, 0, 1, 0, 0.53598464, 0)
|
transform = Transform3D(1, 0, 0, 0, 1, 0, 0, 0, 1, 0, 0.53598464, 0)
|
||||||
max_polyphony = 3
|
max_polyphony = 3
|
||||||
area_mask = 17
|
area_mask = 17
|
||||||
|
|
@ -230,6 +288,6 @@ max_raycast_distance = 200
|
||||||
roomsize_multiplicator = 20.0
|
roomsize_multiplicator = 20.0
|
||||||
metadata/_custom_type_script = "uid://y8x4svl5kej2"
|
metadata/_custom_type_script = "uid://y8x4svl5kej2"
|
||||||
|
|
||||||
[connection signal="body_entered" from="CameraPivot/PlayerCamera/GrabbableFinder" to="." method="_on_grabbable_finder_body_entered"]
|
[connection signal="body_entered" from="CameraPivot/PlayerCamera/GrabbableFinder" to="Components/UiHandler" method="_on_grabbable_finder_body_entered"]
|
||||||
[connection signal="body_exited" from="CameraPivot/PlayerCamera/GrabbableFinder" to="." method="_on_grabbable_finder_body_exited"]
|
[connection signal="body_exited" from="CameraPivot/PlayerCamera/GrabbableFinder" to="Components/UiHandler" method="_on_grabbable_finder_body_exited"]
|
||||||
[connection signal="timeout" from="StaminaReset" to="." method="_on_stamina_reset_timeout"]
|
[connection signal="timeout" from="StaminaReset" to="Components/PlayerProperties" method="_on_stamina_reset_timeout"]
|
||||||
109
scenes/player/player_manager.gd
Normal file
109
scenes/player/player_manager.gd
Normal file
|
|
@ -0,0 +1,109 @@
|
||||||
|
extends CharacterBody3D
|
||||||
|
class_name PlayerCharacter
|
||||||
|
|
||||||
|
##TODO make it so that you can easily tweak settings from here, cascading to the components
|
||||||
|
|
||||||
|
@export_category("Movement")
|
||||||
|
@export var SPEED = 5.0 ##base walking speed
|
||||||
|
@export var SPRINT_MULTIPLIER = 1.5 ##how much faster should you move, when sprinting
|
||||||
|
@export var SPRINT_STAMINA_COST = 10.0 ##how much stamina should be consumed each frame while sprinting (delta * SPRINT_STAMINA_COST)
|
||||||
|
@export var CROUCH_SPEED_MULTIPLIER = .5 ##how much slower you should be going while crouching
|
||||||
|
|
||||||
|
@export_category("Jump")
|
||||||
|
@export var JUMP_VELOCITY = 4.5 ##how high you can jump
|
||||||
|
@export var JUMP_STAMINA_COST = 10 ##how much stamina each jump consumes
|
||||||
|
|
||||||
|
@export_category("Camera")
|
||||||
|
@export var LOOK_SENSITIVITY = 1.0 ##camera sensitivity
|
||||||
|
@export var CAMERA_VELOCITY_MULTIPLIER = 1.5 ##how heavy should the UI movement feel
|
||||||
|
@export var CAMERA_BOB_FREQUENCY = 2.4 ##how quick the camera bobs whilst moving
|
||||||
|
@export var CAMERA_BOB_AMPLITUDE = 0.08 ##how hard the camera bobs whilst moving
|
||||||
|
@export var CAMERA_BOB_MULTIPLIER = 200.0 ##how much the ui reacts to head bobbing
|
||||||
|
@export var CAMERA_SIDEWAYS_BOB_AMPLITUDE = 0.003 ## how many degrees does the camera bob sideways
|
||||||
|
|
||||||
|
@export_category("UI")
|
||||||
|
@export var UI_SCALE: float = 1 ##rational scale of the ui
|
||||||
|
@export var UI_MOVEMENT_SENSITIVITY = 0.5 ##how much the UI moves when you move the camera
|
||||||
|
@export var UI_MOVEMENT_SPEED = 15.0 ##how fast the UI moves when you move the camera
|
||||||
|
@export var UI_MOVEMENT_VELOCITY_MULTIPLIER = 2.0 ##how much the ui leans when walking or strafing
|
||||||
|
|
||||||
|
@export_category("Inventory")
|
||||||
|
@export var INVENTORY_MAX = 3 ##max number of items that can be in the player's inventory
|
||||||
|
@export var INVENTORY_ITEMS: Array = [] ##the items in the player's inventory
|
||||||
|
|
||||||
|
@export_category("Audio")
|
||||||
|
@export var AUDIO_LOUDNESS: float = 100.0
|
||||||
|
@export var NORMAL_FOOTSTEP_SOUNDS: Array[AudioStreamWAV] ##normal footsteps -- walking
|
||||||
|
@export var HEAVY_FOOTSTEP_SOUNDS: Array[AudioStreamWAV] ##heavy footsteps -- running
|
||||||
|
@export var LIGHT_FOOTSTEP_SOUNDS: Array[AudioStreamWAV] ##light footsteps -- crouching
|
||||||
|
@export var SHUFFLE_FOOTSTEP_SOUNDS: Array[AudioStreamWAV] ##shuffling -- random chance of playing while running
|
||||||
|
@export var FLASHLIGHT_CLICK_SOUNDS: Array[AudioStreamWAV] ##flashlight click
|
||||||
|
@export var SHUFFLE_CHANCE: float = 20 ##percentage of chance for a shuffle noise to be played whilst running
|
||||||
|
|
||||||
|
@export_category("Grabbing")
|
||||||
|
@export var GRAB_POWER: float = 15.0 ##how fast the grabbed object snaps to the hold position
|
||||||
|
@export var GRAB_ROTATION_POWER: float = 15.0 ##how fast the object rotates towards the player
|
||||||
|
@export var GRAB_PANEL: PackedScene ##panel that goes over the grabbable object to show its grabbable
|
||||||
|
|
||||||
|
@export_category("Player Physics")
|
||||||
|
@export_flags_3d_physics var PLAYER_COLLISION_MASK: int = 16
|
||||||
|
|
||||||
|
@onready var camera = $CameraPivot/PlayerCamera
|
||||||
|
@onready var camera_pivot = $CameraPivot
|
||||||
|
@onready var ui = $PlayerUi
|
||||||
|
@onready var ui_base_position = ui.position
|
||||||
|
@onready var in_game_menu = $InGameMenu
|
||||||
|
@onready var left_foot_sound_player = $SoundEmitters/LeftFoot
|
||||||
|
@onready var left_foot_texture_sound_player = $SoundEmitters/LeftFoot/LeftFootTexture
|
||||||
|
@onready var right_foot_sound_player = $SoundEmitters/RightFoot
|
||||||
|
@onready var right_foot_texture_sound_player = $SoundEmitters/RightFoot/RightFootTexture
|
||||||
|
@onready var flashlight_sound_player = $SoundEmitters/FlashlightSound
|
||||||
|
@onready var cursor_raycast = $CameraPivot/PlayerCamera/CursorRaycast
|
||||||
|
@onready var hold_position = $CameraPivot/PlayerCamera/HoldPosition
|
||||||
|
@onready var popup_panels = $PopupPanels
|
||||||
|
|
||||||
|
var walking: bool = false
|
||||||
|
var running: bool = false
|
||||||
|
var crouching: bool = false
|
||||||
|
var in_menu: bool = false
|
||||||
|
var stamina: float = 100.0
|
||||||
|
var stamina_recharge_on: bool = false
|
||||||
|
var selected_item: int = 0
|
||||||
|
var t_bob: float = 0
|
||||||
|
var last_bob_y: float = 0.0
|
||||||
|
var held_object: RigidBody3D = null
|
||||||
|
|
||||||
|
var _mouse_motion: Vector2 = Vector2.ZERO
|
||||||
|
var _mouse_motion_delta: Vector2 = Vector2.ZERO
|
||||||
|
var _last_camera_global_position: Vector3 = Vector3.ZERO
|
||||||
|
var _current_leg_is_right: bool = false ##if true: current leg is the right leg
|
||||||
|
var _current_footstep_sound: AudioStreamWAV = null
|
||||||
|
var _current_flashlight_sound: AudioStreamWAV = null
|
||||||
|
var _camera_original_position: Vector3 = Vector3(0,.75,0)
|
||||||
|
|
||||||
|
# components
|
||||||
|
@onready var procedural_camera_mover: Node = %ProceduralCameraMover
|
||||||
|
@onready var sound_controller: Node = %SoundController
|
||||||
|
@onready var ui_handler: Node = %UiHandler
|
||||||
|
@onready var input_controller: Node = %InputController
|
||||||
|
@onready var player_state: Node = %PlayerState
|
||||||
|
@onready var player_properties: Node = %PlayerProperties
|
||||||
|
|
||||||
|
func _process(delta: float) -> void:
|
||||||
|
if Input.is_action_just_pressed("next_item"):
|
||||||
|
ui_handler.next_item()
|
||||||
|
|
||||||
|
if Input.is_action_just_pressed("prev_item"):
|
||||||
|
ui_handler.prev_item()
|
||||||
|
|
||||||
|
if Input.is_action_just_pressed("select_item_1"):
|
||||||
|
ui_handler.select_item(0)
|
||||||
|
|
||||||
|
if Input.is_action_just_pressed("select_item_2"):
|
||||||
|
ui_handler.select_item(1)
|
||||||
|
|
||||||
|
if Input.is_action_just_pressed("select_item_3"):
|
||||||
|
ui_handler.select_item(2)
|
||||||
|
|
||||||
|
func _ready() -> void:
|
||||||
|
ui_handler.select_item(0)
|
||||||
22
scenes/player/player_properties.gd
Normal file
22
scenes/player/player_properties.gd
Normal file
|
|
@ -0,0 +1,22 @@
|
||||||
|
extends Node
|
||||||
|
|
||||||
|
@export_category("Inventory")
|
||||||
|
@export var INVENTORY_MAX = 3 ##max number of items that can be in the player's inventory
|
||||||
|
@export var INVENTORY_ITEMS: Array = [] ##the items in the player's inventory
|
||||||
|
|
||||||
|
var stamina: float = 100.0
|
||||||
|
var selected_item: int = 0
|
||||||
|
var stamina_recharge: bool = true
|
||||||
|
|
||||||
|
func stamina_recharge_off():
|
||||||
|
stamina_recharge = false
|
||||||
|
|
||||||
|
func select_item(index:int):
|
||||||
|
selected_item = index
|
||||||
|
|
||||||
|
func _process(delta: float) -> void:
|
||||||
|
if stamina_recharge:
|
||||||
|
stamina = move_toward(stamina, 100, .5)
|
||||||
|
|
||||||
|
func _on_stamina_reset_timeout() -> void:
|
||||||
|
stamina_recharge = true
|
||||||
1
scenes/player/player_properties.gd.uid
Normal file
1
scenes/player/player_properties.gd.uid
Normal file
|
|
@ -0,0 +1 @@
|
||||||
|
uid://cbdvyelf7nb1u
|
||||||
|
|
@ -1,6 +1,6 @@
|
||||||
[gd_scene format=3 uid="uid://bsccbqq04umeg"]
|
[gd_scene format=3 uid="uid://bsccbqq04umeg"]
|
||||||
|
|
||||||
[ext_resource type="Script" uid="uid://lkb0o8too0mj" path="res://player/player_ui_manager.gd" id="1_n215f"]
|
[ext_resource type="Script" uid="uid://lkb0o8too0mj" path="res://scenes/player/player_ui_manager.gd" id="1_32d7b"]
|
||||||
|
|
||||||
[node name="PlayerUi" type="Control" unique_id=454848358]
|
[node name="PlayerUi" type="Control" unique_id=454848358]
|
||||||
layout_mode = 3
|
layout_mode = 3
|
||||||
|
|
@ -10,7 +10,7 @@ anchor_bottom = 1.0
|
||||||
grow_horizontal = 2
|
grow_horizontal = 2
|
||||||
grow_vertical = 2
|
grow_vertical = 2
|
||||||
offset_transform_enabled = true
|
offset_transform_enabled = true
|
||||||
script = ExtResource("1_n215f")
|
script = ExtResource("1_32d7b")
|
||||||
|
|
||||||
[node name="StaminaBar" type="ProgressBar" parent="." unique_id=1844702202]
|
[node name="StaminaBar" type="ProgressBar" parent="." unique_id=1844702202]
|
||||||
layout_mode = 1
|
layout_mode = 1
|
||||||
96
scenes/player/procedural_camera_mover_component.gd
Normal file
96
scenes/player/procedural_camera_mover_component.gd
Normal file
|
|
@ -0,0 +1,96 @@
|
||||||
|
extends Node
|
||||||
|
|
||||||
|
@export_category("Camera")
|
||||||
|
@export var LOOK_SENSITIVITY = 1.0 ##camera sensitivity
|
||||||
|
@export var CAMERA_VELOCITY_MULTIPLIER = 1.5 ##how heavy should the UI movement feel
|
||||||
|
@export var CAMERA_BOB_FREQUENCY = 2.4 ##how quick the camera bobs whilst moving
|
||||||
|
@export var CAMERA_BOB_AMPLITUDE = 0.08 ##how hard the camera bobs whilst moving
|
||||||
|
@export var CAMERA_BOB_MULTIPLIER = 200.0 ##how much the ui reacts to head bobbing
|
||||||
|
@export var CAMERA_SIDEWAYS_BOB_AMPLITUDE = 0.003 ## how many degrees does the camera bob sideways
|
||||||
|
|
||||||
|
@export_category("UI")
|
||||||
|
@export var UI_SCALE: float = 1 ##rational scale of the ui
|
||||||
|
@export var UI_MOVEMENT_SENSITIVITY = 0.5 ##how much the UI moves when you move the camera
|
||||||
|
@export var UI_MOVEMENT_SPEED = 15.0 ##how fast the UI moves when you move the camera
|
||||||
|
@export var UI_MOVEMENT_VELOCITY_MULTIPLIER = 2.0 ##how much the ui leans when walking or strafing
|
||||||
|
|
||||||
|
@onready var player: PlayerCharacter = $"../.."
|
||||||
|
@onready var sound_controller: Node = %SoundController
|
||||||
|
@onready var camera: Camera3D = %PlayerCamera
|
||||||
|
@onready var ui: Control = %PlayerUi
|
||||||
|
@onready var player_properties: Node = %PlayerProperties
|
||||||
|
@onready var ui_base_position = ui.position
|
||||||
|
|
||||||
|
var t_bob: float = 0.0
|
||||||
|
var last_bob_y: float = 0.0
|
||||||
|
|
||||||
|
var _camera_original_position: Vector3 = Vector3(0,.75,0)
|
||||||
|
var _mouse_motion: Vector2 = Vector2.ZERO
|
||||||
|
var _mouse_motion_delta: Vector2 = Vector2.ZERO
|
||||||
|
var _last_camera_global_position: Vector3 = Vector3.ZERO
|
||||||
|
|
||||||
|
func _ready() -> void:
|
||||||
|
_last_camera_global_position = camera.global_position
|
||||||
|
|
||||||
|
func do(delta):
|
||||||
|
ui.offset_transform_scale *= UI_SCALE
|
||||||
|
ui_movement_handling(delta)
|
||||||
|
ui.set_stamina_bar(player_properties.stamina)
|
||||||
|
var horizontal_speed = Vector3(player.velocity.x, player.velocity.y, player.velocity.z).length()
|
||||||
|
|
||||||
|
if player.is_on_floor() and horizontal_speed > 0.05:
|
||||||
|
t_bob += delta * (player.velocity.length() * float(player.is_on_floor()) + (int(Input.is_action_pressed("crouch"))) * 3)
|
||||||
|
|
||||||
|
var current_sin_pos = sin(t_bob * CAMERA_BOB_FREQUENCY)
|
||||||
|
|
||||||
|
#footstep handling
|
||||||
|
if last_bob_y >= -.95 and current_sin_pos < -.95:
|
||||||
|
sound_controller.play_footstep_sound()
|
||||||
|
|
||||||
|
last_bob_y = current_sin_pos
|
||||||
|
|
||||||
|
camera_bobbing(t_bob)
|
||||||
|
|
||||||
|
#idle breathing
|
||||||
|
elif player.is_on_floor() and horizontal_speed < 0.05:
|
||||||
|
t_bob += delta * 1
|
||||||
|
camera_breathing(t_bob)
|
||||||
|
else:
|
||||||
|
camera.rotation.z = lerpf(camera.rotation.z,0, delta * 0.004)
|
||||||
|
camera.transform.origin.y = lerpf(camera.transform.origin.y, _camera_original_position.y, delta * 5.0)
|
||||||
|
if camera.transform.origin.length() < 0.01:
|
||||||
|
t_bob = 0
|
||||||
|
last_bob_y = 0.0
|
||||||
|
|
||||||
|
func ui_movement_handling(delta: float):
|
||||||
|
var mouse_offset = -_mouse_motion_delta * UI_MOVEMENT_SENSITIVITY
|
||||||
|
|
||||||
|
var current_camera_global_position = camera.global_position
|
||||||
|
var camera_global_velocity = (current_camera_global_position - _last_camera_global_position) / delta
|
||||||
|
|
||||||
|
var cam_local_vel = camera.global_transform.basis.inverse() * camera_global_velocity
|
||||||
|
|
||||||
|
var inertia_offset = Vector2(
|
||||||
|
-cam_local_vel.x,
|
||||||
|
cam_local_vel.y - (cam_local_vel.z * 0.25)
|
||||||
|
) * CAMERA_VELOCITY_MULTIPLIER
|
||||||
|
|
||||||
|
var target_offset = mouse_offset + inertia_offset
|
||||||
|
ui.position = ui.position.lerp(ui_base_position + target_offset, delta * UI_MOVEMENT_SPEED)
|
||||||
|
|
||||||
|
_last_camera_global_position = current_camera_global_position
|
||||||
|
|
||||||
|
var ui_scaling_target = Vector2(-cam_local_vel.z * UI_MOVEMENT_SENSITIVITY * .002 + 1, -cam_local_vel.z * UI_MOVEMENT_SENSITIVITY * .002 + 1)
|
||||||
|
ui.offset_transform_scale = ui.offset_transform_scale.lerp(ui_scaling_target, delta * UI_MOVEMENT_SPEED)
|
||||||
|
|
||||||
|
var ui_rotation_target = -inertia_offset.x - mouse_offset.x * 0.25
|
||||||
|
ui.offset_transform_rotation = lerpf(ui.offset_transform_rotation, ui_rotation_target * UI_MOVEMENT_SENSITIVITY * 0.003, delta * UI_MOVEMENT_SPEED)
|
||||||
|
|
||||||
|
|
||||||
|
func camera_bobbing(time: float):
|
||||||
|
camera.transform.origin.y = sin(time * CAMERA_BOB_FREQUENCY) * CAMERA_BOB_AMPLITUDE + .75
|
||||||
|
camera.rotation.z += sin(time * CAMERA_BOB_FREQUENCY * .5) * CAMERA_SIDEWAYS_BOB_AMPLITUDE
|
||||||
|
|
||||||
|
func camera_breathing(time: float):
|
||||||
|
camera.transform.origin.y = sin(time * CAMERA_BOB_FREQUENCY) * CAMERA_BOB_AMPLITUDE + .75
|
||||||
|
camera.rotation.x += sin(time * CAMERA_BOB_FREQUENCY) * CAMERA_SIDEWAYS_BOB_AMPLITUDE
|
||||||
1
scenes/player/procedural_camera_mover_component.gd.uid
Normal file
1
scenes/player/procedural_camera_mover_component.gd.uid
Normal file
|
|
@ -0,0 +1 @@
|
||||||
|
uid://cjk6a0da11ge6
|
||||||
69
scenes/player/sound_controller_component.gd
Normal file
69
scenes/player/sound_controller_component.gd
Normal file
|
|
@ -0,0 +1,69 @@
|
||||||
|
extends Node
|
||||||
|
|
||||||
|
@export_category("Audio")
|
||||||
|
@export var AUDIO_LOUDNESS: float = 100.0
|
||||||
|
@export var NORMAL_FOOTSTEP_SOUNDS: Array[AudioStreamWAV] ##normal footsteps -- walking
|
||||||
|
@export var HEAVY_FOOTSTEP_SOUNDS: Array[AudioStreamWAV] ##heavy footsteps -- running
|
||||||
|
@export var LIGHT_FOOTSTEP_SOUNDS: Array[AudioStreamWAV] ##light footsteps -- crouching
|
||||||
|
@export var SHUFFLE_FOOTSTEP_SOUNDS: Array[AudioStreamWAV] ##shuffling -- random chance of playing while running
|
||||||
|
@export var FLASHLIGHT_CLICK_SOUNDS: Array[AudioStreamWAV] ##flashlight click
|
||||||
|
@export var SHUFFLE_CHANCE: float = 20 ##percentage of chance for a shuffle noise to be played whilst running
|
||||||
|
|
||||||
|
var _current_flashlight_sound = null
|
||||||
|
var _current_footstep_sound = null
|
||||||
|
var _current_leg_is_right = false
|
||||||
|
|
||||||
|
@onready var flashlight_sound_player: SpatialAudio3D = %FlashlightSound
|
||||||
|
@onready var player_state: Node = %PlayerState
|
||||||
|
@onready var left_foot_texture: SpatialAudio3D = %LeftFootTexture
|
||||||
|
@onready var right_foot: SpatialAudio3D = %RightFoot
|
||||||
|
@onready var right_foot_texture: SpatialAudio3D = %RightFootTexture
|
||||||
|
@onready var left_foot: SpatialAudio3D = %LeftFoot
|
||||||
|
|
||||||
|
func play_flashlight_sound():
|
||||||
|
var play_sound = FLASHLIGHT_CLICK_SOUNDS.pick_random()
|
||||||
|
|
||||||
|
while play_sound == _current_flashlight_sound:
|
||||||
|
play_sound = FLASHLIGHT_CLICK_SOUNDS.pick_random()
|
||||||
|
|
||||||
|
flashlight_sound_player.do_set_stream(play_sound)
|
||||||
|
flashlight_sound_player.pitch_scale = randf_range(.8, 1.2)
|
||||||
|
flashlight_sound_player.do_play()
|
||||||
|
_current_flashlight_sound = play_sound
|
||||||
|
|
||||||
|
func play_footstep_sound():
|
||||||
|
var sound_to_play
|
||||||
|
if player_state.walking:
|
||||||
|
sound_to_play = NORMAL_FOOTSTEP_SOUNDS.pick_random()
|
||||||
|
while sound_to_play == _current_footstep_sound:
|
||||||
|
sound_to_play = NORMAL_FOOTSTEP_SOUNDS.pick_random()
|
||||||
|
elif player_state.running:
|
||||||
|
sound_to_play = HEAVY_FOOTSTEP_SOUNDS.pick_random()
|
||||||
|
while sound_to_play == _current_footstep_sound:
|
||||||
|
sound_to_play = HEAVY_FOOTSTEP_SOUNDS.pick_random()
|
||||||
|
if randf_range(1, 100) > 100 - SHUFFLE_CHANCE:
|
||||||
|
match _current_leg_is_right:
|
||||||
|
true:
|
||||||
|
right_foot_texture.do_set_stream(SHUFFLE_FOOTSTEP_SOUNDS.pick_random())
|
||||||
|
right_foot_texture.do_play()
|
||||||
|
false:
|
||||||
|
left_foot_texture.do_set_stream(SHUFFLE_FOOTSTEP_SOUNDS.pick_random())
|
||||||
|
left_foot_texture.do_play()
|
||||||
|
|
||||||
|
elif player_state.crouching:
|
||||||
|
sound_to_play = LIGHT_FOOTSTEP_SOUNDS.pick_random()
|
||||||
|
while sound_to_play == _current_footstep_sound:
|
||||||
|
sound_to_play = LIGHT_FOOTSTEP_SOUNDS.pick_random()
|
||||||
|
|
||||||
|
_current_footstep_sound = sound_to_play
|
||||||
|
|
||||||
|
if _current_leg_is_right:
|
||||||
|
right_foot.do_set_stream(sound_to_play)
|
||||||
|
right_foot.pitch_scale = randf_range(0.8, 1.2)
|
||||||
|
right_foot.do_play()
|
||||||
|
_current_leg_is_right = false
|
||||||
|
else:
|
||||||
|
left_foot.do_set_stream(sound_to_play)
|
||||||
|
left_foot.pitch_scale = randf_range(0.8, 1.2)
|
||||||
|
left_foot.do_play()
|
||||||
|
_current_leg_is_right = true
|
||||||
1
scenes/player/sound_controller_component.gd.uid
Normal file
1
scenes/player/sound_controller_component.gd.uid
Normal file
|
|
@ -0,0 +1 @@
|
||||||
|
uid://v8er7yn0hdh8
|
||||||
30
scenes/player/state_handler_component.gd
Normal file
30
scenes/player/state_handler_component.gd
Normal file
|
|
@ -0,0 +1,30 @@
|
||||||
|
extends Node
|
||||||
|
|
||||||
|
var walking: bool = false
|
||||||
|
var running: bool = false
|
||||||
|
var crouching: bool = false
|
||||||
|
var in_menu: bool = false
|
||||||
|
|
||||||
|
func is_crouched(yes:bool):
|
||||||
|
if yes:
|
||||||
|
crouching = true
|
||||||
|
walking = false
|
||||||
|
running = false
|
||||||
|
else:
|
||||||
|
crouching = false
|
||||||
|
|
||||||
|
func is_walking(yes:bool):
|
||||||
|
if yes:
|
||||||
|
crouching = false
|
||||||
|
walking = true
|
||||||
|
running = false
|
||||||
|
else:
|
||||||
|
walking = false
|
||||||
|
|
||||||
|
func is_running(yes:bool):
|
||||||
|
if yes:
|
||||||
|
crouching = false
|
||||||
|
walking = false
|
||||||
|
running = true
|
||||||
|
else:
|
||||||
|
running = false
|
||||||
1
scenes/player/state_handler_component.gd.uid
Normal file
1
scenes/player/state_handler_component.gd.uid
Normal file
|
|
@ -0,0 +1 @@
|
||||||
|
uid://7hmwhf7acwpj
|
||||||
72
scenes/player/ui_handler_component.gd
Normal file
72
scenes/player/ui_handler_component.gd
Normal file
|
|
@ -0,0 +1,72 @@
|
||||||
|
extends Node
|
||||||
|
|
||||||
|
@export_category("UI")
|
||||||
|
@export var UI_SCALE: float = 1 ##rational scale of the ui
|
||||||
|
@export var UI_MOVEMENT_SENSITIVITY = 0.5 ##how much the UI moves when you move the camera
|
||||||
|
@export var UI_MOVEMENT_SPEED = 15.0 ##how fast the UI moves when you move the camera
|
||||||
|
@export var UI_MOVEMENT_VELOCITY_MULTIPLIER = 2.0 ##how much the ui leans when walking or strafing
|
||||||
|
|
||||||
|
@export var GRAB_PANEL: PackedScene
|
||||||
|
|
||||||
|
@onready var in_game_menu: Control = %InGameMenu
|
||||||
|
@onready var ui: Control = %PlayerUi
|
||||||
|
@onready var popup_panels: Control = %PopupPanels
|
||||||
|
@onready var player_state: Node = %PlayerState
|
||||||
|
@onready var player_properties: Node = %PlayerProperties
|
||||||
|
@onready var player: PlayerCharacter = $"../.."
|
||||||
|
@onready var cursor: TextureRect = %Cursor
|
||||||
|
@onready var player_camera: Camera3D = %PlayerCamera
|
||||||
|
|
||||||
|
var grabbable_panel = null
|
||||||
|
var grabbable_panel_body = null
|
||||||
|
|
||||||
|
func _on_grabbable_finder_body_entered(body: Node3D) -> void:
|
||||||
|
if body.is_in_group("grabbable"):
|
||||||
|
grabbable_panel = GRAB_PANEL.instantiate()
|
||||||
|
popup_panels.add_child(grabbable_panel)
|
||||||
|
grabbable_panel_body = body
|
||||||
|
|
||||||
|
func _on_grabbable_finder_body_exited(body: Node3D) -> void:
|
||||||
|
if body == grabbable_panel_body:
|
||||||
|
popup_panels.remove_child(grabbable_panel)
|
||||||
|
grabbable_panel = null
|
||||||
|
grabbable_panel_body = null
|
||||||
|
|
||||||
|
func _process(delta: float) -> void:
|
||||||
|
if grabbable_panel != null:
|
||||||
|
var target_position = cursor.position - player_camera.unproject_position(grabbable_panel_body.global_position)
|
||||||
|
grabbable_panel.position = grabbable_panel.position.lerp(-target_position / 2, delta * 50)
|
||||||
|
|
||||||
|
func toggle_menu():
|
||||||
|
if !in_game_menu.visible:
|
||||||
|
ui.visible = false
|
||||||
|
popup_panels.visible = false
|
||||||
|
in_game_menu.visible = true
|
||||||
|
cursor.visible = false
|
||||||
|
Input.mouse_mode = Input.MOUSE_MODE_VISIBLE
|
||||||
|
player_state.in_menu = true
|
||||||
|
else:
|
||||||
|
ui.visible = true
|
||||||
|
popup_panels.visible = true
|
||||||
|
in_game_menu.visible = false
|
||||||
|
cursor.visible = true
|
||||||
|
Input.mouse_mode = Input.MOUSE_MODE_CAPTURED
|
||||||
|
player_state.in_menu = false
|
||||||
|
|
||||||
|
func next_item():
|
||||||
|
if player_properties.selected_item + 1 > player_properties.INVENTORY_MAX - 1:
|
||||||
|
player_properties.selected_item = 0
|
||||||
|
else:
|
||||||
|
player_properties.selected_item += 1
|
||||||
|
ui.select_item(player_properties.selected_item)
|
||||||
|
|
||||||
|
func prev_item():
|
||||||
|
if player_properties.selected_item - 1 < 0:
|
||||||
|
player_properties.selected_item = player_properties.INVENTORY_MAX - 1
|
||||||
|
else:
|
||||||
|
player_properties.selected_item -= 1
|
||||||
|
ui.select_item(player_properties.selected_item)
|
||||||
|
|
||||||
|
func select_item(index: int):
|
||||||
|
player_properties.select_item(index)
|
||||||
|
ui.select_item(index)
|
||||||
1
scenes/player/ui_handler_component.gd.uid
Normal file
1
scenes/player/ui_handler_component.gd.uid
Normal file
|
|
@ -0,0 +1 @@
|
||||||
|
uid://7aa26wi66kqq
|
||||||
Loading…
Reference in a new issue