Skip to content
Closed
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
2 changes: 1 addition & 1 deletion .github/workflows/Aristeas_BuildScripts.yml
Original file line number Diff line number Diff line change
Expand Up @@ -23,4 +23,4 @@ jobs:
# done
- id: build-mods
run: |
& "C:\Program Files\SCUniversalUpload\SC_NewUniversalUpload.exe" "build" --repo "${{ github.workspace }}" --changes "${{ steps.changed-files.outputs.all_changed_and_modified_files }}"
& "C:\Program Files\SCUniversalUpload\SC_NewUniversalUpload.exe" "build" --repo "${{ github.workspace }}"
35 changes: 35 additions & 0 deletions CONTRIBUTING.md
Original file line number Diff line number Diff line change
@@ -0,0 +1,35 @@
### Prerequsites:
- (extremely recommended) github Desktop, GitExtentions, or something similar
- knowing the layout of SE mod files
- enough space to download the entire git repo (~5gb)?

### Step 1:
- ``Fork`` this repository to a folder on your computer. Name it something like SCModRepository-Yourname. This is where your edits can be made, and is apparently how actual projects do it.

### Step 2:
- ``Make a branch`` for the changes you want to do on ``your local repository``. (i.e. SCModRepository-Yourname/BuffMyFavoriteGunPlease) Use your local repository's ``Main`` branch to keep in sync with starcore's ``Main`` branch, it makes edits much easier. You just click the button on github to sync it.

### Step 3:
- To test your changes ingame, Copy the mod you want to edit to your ``%Appdata%/SpaceEngineers/Mods`` folder.

### Step 4:
- Make your edits and throw it back in the repository folder. you can use the ``.bat file`` included in the repository to link your local Space Engineers mods with the ones in the repository.

### Step 5:
- Submit a pull request so that the branch can be merged into the SCModRepository/Main one.
- You can merge your PR yourself if you're confident, or ask for review. Once merged, the development version of the mod will automatically be updated.

Note - the `Main` branch is for the ModDev world, and `Stable` is for the primary combat and build worlds. `Stable` pushes are done in bulk after Test Tournaments.


***


## How does this work?
The repository contains a .github folder, Space Engineers mod folders, and a .gitignore file.
### .github folder:
- contains the instructions to the bot what to do after a "push", currently set to upload to the steam workshop after [SCUniversalUpload](https://github.com/StarCoreSE/SCModRepository/blob/main/.github/workflows/Aristeas%20NewUniversalUpload.yml) detects a change in a folder with a `modinfo_BRANCHNAME.sbmi` file.
### SE Mod folders:
- contains all the data that would load normally as an SE mod
### .gitignore file
- tells git what to exclude during a push (like .sln files in visual studio)
Original file line number Diff line number Diff line change
Expand Up @@ -762,9 +762,9 @@ internal class PointAdditions : MySessionComponentBase
["Caster_Reactor"] = 125,
["Heat_Heatsink"] = 10,
["Heat_FlatRadiator"] = 10,
["ActiveRadiator"] = 250,
["RadiatorPanel"] = 5,
["ExtendableRadiatorBase"] = 5,
["ActiveRadiator"] = 250,
["RadiatorPanel"] = 10,
["ExtendableRadiatorBase"] = 5,
#endregion
};

Expand Down
Original file line number Diff line number Diff line change
@@ -0,0 +1,119 @@
using Sandbox.ModAPI;
using System;
using System.Collections.Generic;
using VRage.Game.ModAPI;

namespace StealthSystem
{
internal class StealthAPI
{
/// Returns true if drive status was toggled successfully.
/// <param name="force">Ignore power requirements and overheat.</param>
public bool ToggleStealth(IMyTerminalBlock drive, bool force) => _toggleStealth?.Invoke(drive, force) ?? false;

/// Returns status of drive. 0 = Ready, 1 = Active, 2 = Cooldown, 3 = Not enough power, 4 = Offline
public int GetStatus(IMyTerminalBlock drive) => _getStatus?.Invoke(drive) ?? 4;

/// Returns remaining duration of stealth/cooldown.
public int GetDuration(IMyTerminalBlock drive) => _getDuration?.Invoke(drive) ?? 0;

/// Retuns active stealth drive on grid if one exists, otherwise returns null.
public IMyTerminalBlock GetMainDrive(IMyCubeGrid grid) => _getMainDrive?.Invoke(grid);

/// <param name="sinks">Collection to populate with heat sinks on grid.</param>
public void GetHeatSinks(IMyCubeGrid grid, ICollection<IMyTerminalBlock> sinks) => _getHeatSinks?.Invoke(grid, sinks);



private const long CHANNEL = 2172757427;
private bool _isRegistered;
private bool _apiInit;
private Action _readyCallback;

private Func<IMyTerminalBlock, bool, bool> _toggleStealth;
private Func<IMyTerminalBlock, int> _getStatus;
private Func<IMyTerminalBlock, int> _getDuration;
private Func<IMyCubeGrid, IMyTerminalBlock> _getMainDrive;
private Action<IMyCubeGrid, ICollection<IMyTerminalBlock>> _getHeatSinks;

public bool IsReady { get; private set; }


/// <summary>
/// Ask CoreSystems to send the API methods.
/// <para>Throws an exception if it gets called more than once per session without <see cref="Unload"/>.</para>
/// </summary>
/// <param name="readyCallback">Method to be called when CoreSystems replies.</param>
public void Load(Action readyCallback = null)
{
if (_isRegistered)
throw new Exception($"{GetType().Name}.Load() should not be called multiple times!");

_readyCallback = readyCallback;
_isRegistered = true;
MyAPIGateway.Utilities.RegisterMessageHandler(CHANNEL, HandleMessage);
MyAPIGateway.Utilities.SendModMessage(CHANNEL, "ApiEndpointRequest");
}

public void Unload()
{
MyAPIGateway.Utilities.UnregisterMessageHandler(CHANNEL, HandleMessage);

ApiAssign(null);

_isRegistered = false;
_apiInit = false;
IsReady = false;
}

private void HandleMessage(object obj)
{
if (_apiInit || obj is string
) // the sent "ApiEndpointRequest" will also be received here, explicitly ignoring that
return;

var dict = obj as IReadOnlyDictionary<string, Delegate>;

if (dict == null)
return;

ApiAssign(dict);

IsReady = true;
_readyCallback?.Invoke();
}

public void ApiAssign(IReadOnlyDictionary<string, Delegate> delegates)
{
_apiInit = (delegates != null);
/// base methods
AssignMethod(delegates, "ToggleStealth", ref _toggleStealth);
AssignMethod(delegates, "GetStatus", ref _getStatus);
AssignMethod(delegates, "GetDuration", ref _getDuration);
AssignMethod(delegates, "GetMainDrive", ref _getMainDrive);
AssignMethod(delegates, "GetHeatSinks", ref _getHeatSinks);
}

private void AssignMethod<T>(IReadOnlyDictionary<string, Delegate> delegates, string name, ref T field)
where T : class
{
if (delegates == null)
{
field = null;
return;
}

Delegate del;
if (!delegates.TryGetValue(name, out del))
throw new Exception($"{GetType().Name} :: Couldn't find {name} delegate of type {typeof(T)}");

field = del as T;

if (field == null)
throw new Exception(
$"{GetType().Name} :: Delegate {name} is not type {typeof(T)}, instead it's: {del.GetType()}");
}

}

}
Original file line number Diff line number Diff line change
Expand Up @@ -4,6 +4,7 @@
using StarCore.ShareTrack.HeartNetworking;
using StarCore.ShareTrack.ShipTracking;
using StarCore.ShareTrack.TrackerApi;
using StealthSystem;
using VRage.Game.Components;
using VRageMath;

Expand All @@ -20,6 +21,7 @@ internal class MasterSession : MySessionComponentBase
public static MasterSession I;
public static SharetrackConfig Config;

public StealthAPI StealthApi = new StealthAPI();
public HudAPIv2 TextHudApi;
public Action HudRegistered = () => { };

Expand All @@ -46,6 +48,8 @@ public override void LoadData()
_buildingBlockPoints = new BuildingBlockPoints();
TrackingManager.Init(); // Initialize TrackingManager, but don't start tracking yet

StealthApi.Load();

if (!MyAPIGateway.Utilities.IsDedicated)
// Initialize the sphere entities
// Initialize the text_api with the HUDRegistered callback
Expand Down
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
using System;
using System;
using System.Collections.Generic;
using System.Linq;
using System.Text;
Expand Down Expand Up @@ -351,6 +351,14 @@ public void UpdateHud()
camera.WorldMatrix.Forward);

var stealthed = ((uint)Grid.Flags & 0x1000000) > 0;

if (MasterSession.I.StealthApi?.IsReady ?? false)
{
var mainStealthDrive = MasterSession.I.StealthApi.GetMainDrive(Grid);
if (mainStealthDrive != null)
stealthed |= MasterSession.I.StealthApi.GetStatus(mainStealthDrive) == 1;
}

var visible = !(newOrigin.X > 1 || newOrigin.X < -1 || newOrigin.Y > 1 || newOrigin.Y < -1) &&
angle <= fov && !stealthed;

Expand Down Expand Up @@ -687,4 +695,4 @@ public float CurrentFieldPower
#endregion
#endregion
}
}
}
14 changes: 9 additions & 5 deletions README.md
Original file line number Diff line number Diff line change
Expand Up @@ -9,16 +9,18 @@

In StarCore, teams build their own ships and battle for the spot of champion in a StarCore Tournament. They normally take place on Saturdays and are streamed live by one of several streamers over on Twitch (See #content-announcements in the StarCore Discord for more information). It's time to join the arena!

***

## Contribution guide

### prerequsites:

### Prerequsites:
- (extremely recommended) github Desktop, GitExtentions, or something similar
- knowing the layout of SE mod files
- enough space to download the entire git repo (~5gb)?

### Step 1:
- ``Fork`` this repository to a folder on your computer. Name it something like SCModRepository-Yourname. This is where your edits can be made, and is apparently how actual projects do it. You can do this in GitHub desktop by git cloning the url, or through the github website, with the "fork" button which you can then git clone to a folder on your computer where you can make changes.
- ``Fork`` this repository to a folder on your computer. Name it something like SCModRepository-Yourname. This is where your edits can be made, and is apparently how actual projects do it.

### Step 2:
- ``Make a branch`` for the changes you want to do on ``your local repository``. (i.e. SCModRepository-Yourname/BuffMyFavoriteGunPlease) Use your local repository's ``Main`` branch to keep in sync with starcore's ``Main`` branch, it makes edits much easier. You just click the button on github to sync it.
Expand All @@ -30,17 +32,19 @@ In StarCore, teams build their own ships and battle for the spot of champion in
- Make your edits and throw it back in the repository folder. you can use the ``.bat file`` included in the repository to link your local Space Engineers mods with the ones in the repository.

### Step 5:
- Submit a pull request so that the branch can be merged into the SCModRepository/master one.

- Submit a pull request so that the branch can be merged into the SCModRepository/Main one.
- You can merge your PR yourself if you're confident, or ask for review. Once merged, the development version of the mod will automatically be updated.

Note - the `Main` branch is for the ModDev world, and `Stable` is for the primary combat and build worlds. `Stable` pushes are done in bulk after Test Tournaments.


***


## How does this work?
The repository contains a .github folder, Space Engineers mod folders, and a .gitignore file.
### .github folder:
- contains the instructions to the bot what to do after a "push", currently set to upload to the steam workshop after the respective .yml file detects a change in the folder its looking for
- contains the instructions to the bot what to do after a "push", currently set to upload to the steam workshop after [SCUniversalUpload](https://github.com/StarCoreSE/SCModRepository/blob/main/.github/workflows/Aristeas%20NewUniversalUpload.yml) detects a change in a folder with a `modinfo_BRANCHNAME.sbmi` file.
### SE Mod folders:
- contains all the data that would load normally as an SE mod
### .gitignore file
Expand Down
Original file line number Diff line number Diff line change
@@ -0,0 +1,16 @@
using ProtoBuf;
using VRage;
using VRageMath;

namespace CameraInfoApi.Data.Scripts.CameraInfoApi
{
[ProtoContract]
internal class CameraDataPacket
{
[ProtoMember(1)] public MatrixD Matrix;
[ProtoMember(2)] public float FieldOfView;
[ProtoMember(3)] public long GridId;

public MyTuple<MatrixD, float> Tuple => new MyTuple<MatrixD, float>(Matrix, FieldOfView);
}
}
Original file line number Diff line number Diff line change
@@ -0,0 +1,46 @@
using CameraInfoApi.Data.Scripts.CameraInfoApi;
using Sandbox.ModAPI;
using System;
using VRage.Game.Components;
using VRage.Game.ModAPI;
using VRageMath;

namespace CameraInfoApi
{
[MySessionComponentDescriptor(MyUpdateOrder.AfterSimulation)]
internal class ClientMain : MySessionComponentBase
{
private IMyCubeGrid prevGrid = null;
private int _ticks = 0;
public override void UpdateAfterSimulation()
{
if (MyAPIGateway.Utilities.IsDedicated)
return;

if (_ticks++ % 10 != 0)
return;

var clientGrid = (MyAPIGateway.Session.Player?.Controller?.ControlledEntity as IMyShipController)?.CubeGrid;
if (clientGrid == null)
{
if (prevGrid != null)
MyAPIGateway.Multiplayer.SendMessageToServer(3621, MyAPIGateway.Utilities.SerializeToBinary(new CameraDataPacket()
{
Matrix = MatrixD.Identity,
FieldOfView = -1,
GridId = prevGrid.EntityId,
}));
prevGrid = null;
return;
}

prevGrid = clientGrid;
MyAPIGateway.Multiplayer.SendMessageToServer(3621, MyAPIGateway.Utilities.SerializeToBinary(new CameraDataPacket()
{
Matrix = MyAPIGateway.Session.Camera.ViewMatrix,
FieldOfView = MyAPIGateway.Session.Camera.FieldOfViewAngle,
GridId = prevGrid.EntityId,
}));
}
}
}
Loading
Loading