Skip to content

Commit

Permalink
Merge pull request #3018 from KBVE/beta
Browse files Browse the repository at this point in the history
Preparing Release Branch
  • Loading branch information
h0lybyte authored Oct 13, 2024
2 parents 50f1187 + eb7cfec commit 91855be
Show file tree
Hide file tree
Showing 31 changed files with 1,010 additions and 143 deletions.
47 changes: 47 additions & 0 deletions apps/kbve.com/src/content/journal/10-11.mdx
Original file line number Diff line number Diff line change
@@ -0,0 +1,47 @@
---
title: 'October: 11th'
category: Daily
date: 2024-10-11 12:00:00
client: Self
unsplash: 1693298661836-1206649639ef
img: https://images.unsplash.com/photo-1693298661836-1206649639ef?crop=entropy&cs=srgb&fm=jpg&ixid=MnwzNjM5Nzd8MHwxfHJhbmRvbXx8fHx8fHx8fDE2ODE3NDg2ODY&ixlib=rb-4.0.3&q=85
description: October 11th.
tags:
- daily
---

import { Adsense, Tasks } from '@kbve/astropad';

## 2024

**Animations**

Spending some time learning how animations work within Unity is always a fun time.
The first animation will be with a 2D sprite and that will have multiple different references.

**JEDI**

Under the `kilonet` package, the first major script that we want to add is the `JEDI.cs` and it will handle our JSON serialization.
However I believe in the future, this can be our first step in doing the Rust FFI and specfically replacing the json methods with a rust binding.

**Packages**

We got our first package for unity loaded into the `rareicon` game on the Azure side!
For now we will continue to migrate some of the legacy code into this package, but the end goal will shift a bit?
Part of the problem that I can see is that version control will be a bit rough because we are using branch names.
The solution to this will be to have our package get either loaded into the unity asset store or we go through nuget?
These are concerns for a future problem, since the goal should be inching closer to getting a steam game published.

**Kilonet**

The next update for the `kilonet` will be focused on resolving some of the vuplux and supabase integrations.
One of the areas that we need to double check are the save states for the json, which are currently hardcoded in, also the supabase anon key and the api is also hardcoded in.
Both of these need to be adjusted, but I am still considering how I would want to handle that.

**Register**

It seems that our register function within Supabase was broken but I was able to figure it out.
During the table creation for the usercard, we were referencing the username table twice, which is not optimal because we already have the username saved in the user profile.
The solution was to drop that column for username on the user card, then adjust the table creation by having the default fields be null and then finally adjusting the materialized view to use a join between the two tables.

<Adsense />
62 changes: 62 additions & 0 deletions apps/kbve.com/src/content/journal/10-12.mdx
Original file line number Diff line number Diff line change
@@ -0,0 +1,62 @@
---
title: 'October: 12th'
category: Daily
date: 2024-10-12 12:00:00
client: Self
unsplash: 1693298661836-1206649639ef
img: https://images.unsplash.com/photo-1693298661836-1206649639ef?crop=entropy&cs=srgb&fm=jpg&ixid=MnwzNjM5Nzd8MHwxfHJhbmRvbXx8fHx8fHx8fDE2ODE3NDg2ODY&ixlib=rb-4.0.3&q=85
description: October 12th.
tags:
- daily
---

import { Adsense, Tasks } from '@kbve/astropad';

## 2024

**Login**

Now we can go back around and adjust the login script within unity to use the kilonet.
We would want to keep the supabase instance and client connected but only if in the `kbve` mode because in `offline` and `steam`, we would not need the supabase client.
For the steam version, we would just handover auth and utility to the Steam SDK, this way the player can still get the achievements and in-game items.
However what we do need to be careful about is to prevent cheating and maybe lockdown parts of our code, hmm, we can get a bit creative with how we want to handle that part too.

**Title**

For the rare icon game, we will focus on three core gameplay options, `Single-Player`, `Steam` and `KBVE`.
The single player will be an offline and casual instance, while the steam mode will be focused on a co-op style of gameplay and finally the kbve version will be for the hardcore players.
We will want to keep the players focused on the single-player first, maybe even lock out the `kbve` until they complete at least one mission on the single-player?
The goal would be to keep players happy regardless of their play style and maybe find some creative ways to make each instance popular?
Like special abilities from the single player could grant you special benefits in the pvp areas?

**State Machine**

In our current state machine codebase, the save file name is just hardcoded to be:

```c#

private const string SaveFileName = "RareIconGameSave.json"; // JSON file name for saving state
```

We want to make this a bit more dynamic, maybe depending on the application's name or just some form of a variable, rather than what it is right now.
For that, we need to update the `StateMachine.cs`, such that when the constructor is being created, we do this:

```c#
SaveFileName = !string.IsNullOrEmpty(Application.productName) ? Application.productName + "_GameSave.json" : "RareIconGameSave.json";
```

This will let us create the save state based upon the `productName` and `_GameSave.json`!
Let us go ahead and push that out!

**Data**

There is an older folder we created called `_Data`, which holds a bunch of assets under a sub-folder of `BG` and `PixelArt`.
I am going to go ahead and remove those because we will no longer use them in our current game.
It would make more sense to keep the simple ui for now and focus on making it more stylish after we get the core gameplay out.

**SubScene**

After getting the base of the game state resolved, we can move forward with the initial game loading and level picking.
I am going to build off of the MM system and basically reverse engineer how they handle level loading, we see that there are two scripts attached to the button.
The scripts are `Selection Base` and `LevelSelector`, we will peak inside both of those cs files and see what they are doing.
6 changes: 1 addition & 5 deletions apps/kbve.com/src/pages/arcade/fishchip/itch.astro
Original file line number Diff line number Diff line change
Expand Up @@ -28,15 +28,11 @@ const pageDescription: string = `Fish and Chip Demo | KBVE.com`;
},
inLanguage: 'en-US',
}}>
<div class="relative min-h-screen">

<!-- Form component positioned relative to the loader -->
<div class="relative z-10">
<section
class={`flex-auto w-full md:w-6/12 p-5 bg-[#c0987d] border border-cyan-200 rounded-lg shadow bg-default bg-cover bg-blend-overlay`}
class={`flex-auto w-full bg-[#c0987d] border border-cyan-200 rounded-lg shadow bg-default bg-cover bg-blend-overlay`}
style={`background-image: url('https://utfs.io/f/ae961975-ad95-4247-91cc-2c573d6fbe3e-1t0m0l.webp')`}>
<AstroPhaser scene="/embed/js/phaser/fish/TownScene.js" />
</section>
</div>
</div>
</MainLayout>
7 changes: 7 additions & 0 deletions apps/kilobase/sql/user_cards/drop_username_column.sql
Original file line number Diff line number Diff line change
@@ -0,0 +1,7 @@
BEGIN;

DROP MATERIALIZED VIEW IF EXISTS public.user_cards_public;
ALTER TABLE public.user_cards
DROP COLUMN IF EXISTS username;

COMMIT;
128 changes: 21 additions & 107 deletions apps/kilobase/sql/user_cards/enable_user_cards.sql
Original file line number Diff line number Diff line change
Expand Up @@ -8,7 +8,6 @@ CREATE EXTENSION IF NOT EXISTS pg_jsonschema WITH SCHEMA extensions;
-- Create the table for public.user_cards with a username reference
CREATE TABLE IF NOT EXISTS public.user_cards (
id UUID PRIMARY KEY REFERENCES auth.users(id) ON DELETE CASCADE,
username TEXT REFERENCES public.user_profiles(username) ON DELETE CASCADE, -- Reference to username in user_profiles
bio TEXT,
socials JSONB, -- JSONB column to store social links (nullable)
style JSONB, -- JSONB column to store profile style information (nullable)
Expand Down Expand Up @@ -112,108 +111,22 @@ CREATE TRIGGER handle_user_cards_update

-- Create the function to handle new user_card creation and validation
CREATE OR REPLACE FUNCTION public.handle_new_user_card()
RETURNS TRIGGER AS $$
DECLARE
v_bio TEXT;
v_socials JSONB;
v_style JSONB;
v_username TEXT;
RETURNS TRIGGER AS $$
BEGIN
-- Assign variables from user metadata and user_profiles
v_bio := new.raw_user_meta_data->>'bio';
v_socials := new.raw_user_meta_data->>'socials'::jsonb;
v_style := new.raw_user_meta_data->>'style'::jsonb;
v_username := (SELECT username FROM public.user_profiles WHERE id = new.id);

-- Validate bio (if applicable)
IF v_bio IS NOT NULL AND
(char_length(v_bio) > 255 OR
NOT (v_bio ~ '^[a-zA-Z0-9.!? ]*$')) THEN
RAISE EXCEPTION 'invalid_bio';
END IF;

-- Validate the socials JSON structure if it is not null
IF v_socials IS NOT NULL AND
NOT extensions.jsonb_matches_schema(
'{
"type": "object",
"properties": {
"twitter": {
"type": "string",
"format": "uri",
"pattern": "^https://(www\\.)?twitter.com/[a-zA-Z0-9_]{1,15}/?$"
},
"github": {
"type": "string",
"format": "uri",
"pattern": "^https://(www\\.)?github.com/[a-zA-Z0-9_-]+/?$"
},
"linkedin": {
"type": "string",
"format": "uri",
"pattern": "^https://(www\\.)?linkedin.com/in/[a-zA-Z0-9_-]+/?$"
},
"website": {
"type": "string",
"format": "uri"
}
},
"additionalProperties": false,
"required": []
}',
v_socials
) THEN
RAISE EXCEPTION 'invalid_socials';
END IF;

-- Validate the style JSON structure if it is not null
IF v_style IS NOT NULL AND
NOT extensions.jsonb_matches_schema(
'{
"type": "object",
"properties": {
"colors": {
"type": "array",
"items": {
"type": "string",
"pattern": "^#[A-Fa-f0-9]{8}$"
},
"maxItems": 10
},
"cover": {
"type": "string",
"pattern": "^[a-zA-Z0-9_-]+$"
},
"background": {
"type": "string",
"pattern": "^[a-zA-Z0-9_-]+$"
}
},
"additionalProperties": false
}',
v_style
) THEN
RAISE EXCEPTION 'invalid_style';
END IF;

-- Insert into user_cards table
INSERT INTO public.user_cards (id, username, bio, socials, style)
VALUES (
new.id,
v_username,
v_bio,
v_socials,
v_style
);

RETURN new;
-- Simplified version: Just insert a row into user_cards with NULL values
INSERT INTO public.user_cards (id, bio, socials, style)
VALUES (NEW.id, NULL, NULL, NULL);

RETURN NEW;
END;
$$ LANGUAGE plpgsql SECURITY DEFINER;


-- Create the trigger to handle new user_card creation when a new user is created in public.user_profiles
DROP TRIGGER IF EXISTS on_user_profiles_created ON public.user_profiles;
CREATE TRIGGER on_user_profiles_created
AFTER INSERT ON public.user_profiles
DROP TRIGGER IF EXISTS on_auth_new_card_created ON auth.users;

CREATE TRIGGER on_auth_new_card_created
AFTER INSERT ON auth.users
FOR EACH ROW
EXECUTE PROCEDURE public.handle_new_user_card();

Expand Down Expand Up @@ -318,17 +231,18 @@ CREATE TRIGGER handle_user_card_update
FOR EACH ROW
EXECUTE PROCEDURE public.handle_user_card_update();

DROP MATERIALIZED VIEW IF EXISTS public.user_cards_public;
-- Create a materialized view for public access without UUID
CREATE MATERIALIZED VIEW IF NOT EXISTS public.user_cards_public AS
CREATE MATERIALIZED VIEW public.user_cards_public AS
SELECT
username,
bio,
socials,
style,
created_at,
updated_at
FROM public.user_cards;

up.username,
uc.bio,
uc.socials,
uc.style,
uc.created_at,
uc.updated_at
FROM public.user_cards uc
JOIN public.user_profiles up ON uc.id = up.id;
-- Create an index on the materialized view after it has been populated.
CREATE INDEX IF NOT EXISTS idx_user_cards_username ON public.user_cards_public(username);

Expand Down
Original file line number Diff line number Diff line change
@@ -1,10 +1,11 @@
BEGIN;
-- Insert into user_cards for existing users in user_profiles that do not have a user_card yet
INSERT INTO public.user_cards (id, username, bio, socials, style)
INSERT INTO public.user_cards (id, bio, socials, style)
SELECT
id,
username,
NULL, -- Default bio value, can be adjusted as needed
NULL, -- Default socials value, can be adjusted as needed
NULL -- Default style value, can be adjusted as needed
FROM public.user_profiles
WHERE id NOT IN (SELECT id FROM public.user_cards);
COMMIT;
7 changes: 7 additions & 0 deletions packages/kilonet/Kbve.Kilonet.csproj.meta

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

8 changes: 8 additions & 0 deletions packages/kilonet/kilonet-test.meta

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

Empty file.
1 change: 0 additions & 1 deletion packages/kilonet/kilonet-test/GlobalUsings.cs

This file was deleted.

15 changes: 0 additions & 15 deletions packages/kilonet/kilonet-test/UnitTest1.cs

This file was deleted.

8 changes: 8 additions & 0 deletions packages/kilonet/kilonet.meta

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

8 changes: 8 additions & 0 deletions packages/kilonet/kilonet/Events.meta

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

2 changes: 2 additions & 0 deletions packages/kilonet/kilonet/Events/EventFlag.cs.meta

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

2 changes: 2 additions & 0 deletions packages/kilonet/kilonet/Events/GlobalEvent.cs.meta

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

2 changes: 2 additions & 0 deletions packages/kilonet/kilonet/GameManager.cs
Original file line number Diff line number Diff line change
@@ -1,4 +1,6 @@
using UnityEngine;
using KBVE.Kilonet.States;
using KBVE.Kilonet.Events;
using Cysharp.Threading.Tasks;

namespace KBVE.Kilonet
Expand Down
2 changes: 2 additions & 0 deletions packages/kilonet/kilonet/GameManager.cs.meta

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

1 change: 0 additions & 1 deletion packages/kilonet/kilonet/GlobalUsings.cs

This file was deleted.

Loading

0 comments on commit 91855be

Please sign in to comment.