File tree Expand file tree Collapse file tree 6 files changed +47
-6
lines changed
Uchu.StandardScripts/VentureExplorer Expand file tree Collapse file tree 6 files changed +47
-6
lines changed Original file line number Diff line number Diff line change @@ -9,6 +9,7 @@ namespace Uchu.StandardScripts.VentureExplorer
9
9
/// LUA Reference: l_ag_ship_player_shock_server.lua
10
10
/// </summary>
11
11
[ ZoneSpecific ( 1000 ) ]
12
+ [ ZoneSpecific ( 1001 ) ]
12
13
public class BrokenConsole : NativeScript
13
14
{
14
15
private const string ScriptName = "l_ag_ship_player_shock_server.lua" ;
Original file line number Diff line number Diff line change
1
+ using System . Threading . Tasks ;
2
+ using Uchu . World ;
3
+ using Uchu . World . Scripting . Native ;
4
+
5
+ namespace Uchu . StandardScripts . VentureExplorer
6
+ {
7
+ [ ZoneSpecific ( 1001 ) ]
8
+ public class CorruptedSentry : NativeScript
9
+ {
10
+ /// <summary>
11
+ /// Loads the script.
12
+ /// </summary>
13
+ public override Task LoadAsync ( )
14
+ {
15
+ foreach ( var obj in Zone . Objects )
16
+ {
17
+ InitializeCorruptedSentry ( obj ) ;
18
+ }
19
+ Listen ( Zone . OnObject , InitializeCorruptedSentry ) ;
20
+
21
+ return Task . CompletedTask ;
22
+ }
23
+
24
+ /// <summary>
25
+ /// Initializes the faction and enemies of the
26
+ /// corrupted sentry.
27
+ /// </summary>
28
+ /// <param name="obj">Corrupted sentry game object to initialize.</param>
29
+ private void InitializeCorruptedSentry ( Object obj )
30
+ {
31
+ if ( ! ( obj is GameObject gameObject ) ) return ;
32
+ if ( gameObject . Lot != 8433 ) return ;
33
+ if ( ! gameObject . TryGetComponent < DestroyableComponent > ( out var destroyableComponent ) ) return ;
34
+ destroyableComponent . Factions = new [ ] { 4 } ;
35
+ destroyableComponent . Enemies = new [ ] { 1 } ;
36
+ }
37
+ }
38
+ }
Original file line number Diff line number Diff line change @@ -324,6 +324,7 @@ private void CollectObjectStats()
324
324
) ;
325
325
326
326
if ( stats == default ) return ;
327
+ HasStats = true ;
327
328
328
329
var rawHealth = stats . Life ?? 0 ;
329
330
var rawArmor = ( int ) ( stats . Armor ?? 0 ) ;
@@ -341,6 +342,7 @@ private void CollectObjectStats()
341
342
private void CollectPlayerStats ( )
342
343
{
343
344
if ( ! ( GameObject is Player ) ) return ;
345
+ HasStats = true ;
344
346
345
347
using var ctx = new UchuContext ( ) ;
346
348
Original file line number Diff line number Diff line change @@ -164,7 +164,6 @@ public async Task LoadAsync(IRakConnection connection)
164
164
AddComponent < PossessableOccupantComponent > ( ) ;
165
165
166
166
controllablePhysics . HasPosition = true ;
167
- stats . HasStats = true ;
168
167
169
168
// Server Components
170
169
var inventoryManager = AddComponent < InventoryManagerComponent > ( ) ;
Original file line number Diff line number Diff line change 3
3
4
4
namespace Uchu . World . Scripting . Native
5
5
{
6
- [ AttributeUsage ( AttributeTargets . Class ) ]
6
+ [ AttributeUsage ( AttributeTargets . Class , AllowMultiple = true ) ]
7
7
public class ZoneSpecificAttribute : Attribute
8
8
{
9
9
public readonly ZoneId ZoneId ;
Original file line number Diff line number Diff line change 1
1
using System ;
2
2
using System . Collections . Generic ;
3
3
using System . IO ;
4
+ using System . Linq ;
4
5
using System . Reflection ;
5
6
using System . Threading . Tasks ;
6
7
using Uchu . Core ;
8
+ using Uchu . World . Scripting . Native ;
7
9
8
10
namespace Uchu . World . Scripting . Native
9
11
{
@@ -32,11 +34,10 @@ internal void ReadAssembly()
32
34
{
33
35
if ( type . BaseType != typeof ( NativeScript ) ) return ;
34
36
35
- var zoneSpecific = type . GetCustomAttribute < ZoneSpecificAttribute > ( ) ;
36
-
37
- if ( zoneSpecific != null )
37
+ var zoneSpecific = type . GetCustomAttributes < ZoneSpecificAttribute > ( ) . ToArray ( ) ;
38
+ if ( zoneSpecific . Length > 0 )
38
39
{
39
- if ( zoneSpecific . ZoneId != Zone . ZoneId ) continue ;
40
+ if ( zoneSpecific . FirstOrDefault ( zoneSpecificEntry => zoneSpecificEntry . ZoneId == Zone . ZoneId ) == default ) continue ;
40
41
}
41
42
42
43
var instance = ( NativeScript ) Activator . CreateInstance ( type ) ;
You can’t perform that action at this time.
0 commit comments