Skip to content
Projects
Groups
Snippets
Help
This project
Loading...
Sign in / Register
Toggle navigation
godot
Project
Overview
Details
Activity
Cycle Analytics
Repository
Repository
Files
Commits
Branches
Tags
Contributors
Graph
Compare
Charts
Issues
0
Issues
0
List
Board
Labels
Milestones
Merge Requests
0
Merge Requests
0
CI / CD
CI / CD
Pipelines
Jobs
Schedules
Charts
Wiki
Wiki
Snippets
Snippets
Members
Members
Collapse sidebar
Close sidebar
Activity
Graph
Charts
Create a new issue
Jobs
Commits
Issue Boards
Open sidebar
community
godot
Commits
ce678088
Commit
ce678088
authored
Feb 19, 2019
by
Ignacio Etcheverry
Browse files
Options
Browse Files
Download
Email Patches
Plain Diff
C#: Add random functions to GD class
parent
325efb60
Hide whitespace changes
Inline
Side-by-side
Showing
3 changed files
with
87 additions
and
10 deletions
+87
-10
GD.cs
modules/mono/glue/Managed/Files/GD.cs
+44
-4
gd_glue.cpp
modules/mono/glue/gd_glue.cpp
+30
-3
gd_glue.h
modules/mono/glue/gd_glue.h
+13
-3
No files found.
modules/mono/glue/Managed/Files/GD.cs
View file @
ce678088
...
@@ -50,7 +50,7 @@ namespace Godot
...
@@ -50,7 +50,7 @@ namespace Godot
return
godot_icall_GD_hash
(
var
);
return
godot_icall_GD_hash
(
var
);
}
}
public
static
Object
InstanceFromId
(
int
instanceId
)
public
static
Object
InstanceFromId
(
ulong
instanceId
)
{
{
return
godot_icall_GD_instance_from_id
(
instanceId
);
return
godot_icall_GD_instance_from_id
(
instanceId
);
}
}
...
@@ -110,6 +110,31 @@ namespace Godot
...
@@ -110,6 +110,31 @@ namespace Godot
godot_icall_GD_printt
(
what
);
godot_icall_GD_printt
(
what
);
}
}
public
static
double
Randf
()
{
return
godot_icall_GD_randf
();
}
public
static
uint
Randi
()
{
return
godot_icall_GD_randi
();
}
public
static
void
Randomize
()
{
godot_icall_GD_randomize
();
}
public
static
double
rand_range
(
double
from
,
double
to
)
{
return
godot_icall_GD_rand_range
(
from
,
to
);
}
public
static
uint
RandSeed
(
ulong
seed
,
out
ulong
newSeed
)
{
return
godot_icall_GD_rand_seed
(
seed
,
out
newSeed
);
}
public
static
int
[]
Range
(
int
length
)
public
static
int
[]
Range
(
int
length
)
{
{
var
ret
=
new
int
[
length
];
var
ret
=
new
int
[
length
];
...
@@ -174,7 +199,7 @@ namespace Godot
...
@@ -174,7 +199,7 @@ namespace Godot
return
ret
;
return
ret
;
}
}
public
static
void
Seed
(
int
seed
)
public
static
void
Seed
(
ulong
seed
)
{
{
godot_icall_GD_seed
(
seed
);
godot_icall_GD_seed
(
seed
);
}
}
...
@@ -214,7 +239,7 @@ namespace Godot
...
@@ -214,7 +239,7 @@ namespace Godot
internal
extern
static
int
godot_icall_GD_hash
(
object
var
);
internal
extern
static
int
godot_icall_GD_hash
(
object
var
);
[
MethodImpl
(
MethodImplOptions
.
InternalCall
)]
[
MethodImpl
(
MethodImplOptions
.
InternalCall
)]
internal
extern
static
Object
godot_icall_GD_instance_from_id
(
int
instance_id
);
internal
extern
static
Object
godot_icall_GD_instance_from_id
(
ulong
instance_id
);
[
MethodImpl
(
MethodImplOptions
.
InternalCall
)]
[
MethodImpl
(
MethodImplOptions
.
InternalCall
)]
internal
extern
static
void
godot_icall_GD_print
(
object
[]
what
);
internal
extern
static
void
godot_icall_GD_print
(
object
[]
what
);
...
@@ -232,7 +257,22 @@ namespace Godot
...
@@ -232,7 +257,22 @@ namespace Godot
internal
extern
static
void
godot_icall_GD_printt
(
object
[]
what
);
internal
extern
static
void
godot_icall_GD_printt
(
object
[]
what
);
[
MethodImpl
(
MethodImplOptions
.
InternalCall
)]
[
MethodImpl
(
MethodImplOptions
.
InternalCall
)]
internal
extern
static
void
godot_icall_GD_seed
(
int
seed
);
internal
extern
static
double
godot_icall_GD_randf
();
[
MethodImpl
(
MethodImplOptions
.
InternalCall
)]
internal
extern
static
uint
godot_icall_GD_randi
();
[
MethodImpl
(
MethodImplOptions
.
InternalCall
)]
internal
extern
static
void
godot_icall_GD_randomize
();
[
MethodImpl
(
MethodImplOptions
.
InternalCall
)]
internal
extern
static
double
godot_icall_GD_rand_range
(
double
from
,
double
to
);
[
MethodImpl
(
MethodImplOptions
.
InternalCall
)]
internal
extern
static
uint
godot_icall_GD_rand_seed
(
ulong
seed
,
out
ulong
newSeed
);
[
MethodImpl
(
MethodImplOptions
.
InternalCall
)]
internal
extern
static
void
godot_icall_GD_seed
(
ulong
seed
);
[
MethodImpl
(
MethodImplOptions
.
InternalCall
)]
[
MethodImpl
(
MethodImplOptions
.
InternalCall
)]
internal
extern
static
string
godot_icall_GD_str
(
object
[]
what
);
internal
extern
static
string
godot_icall_GD_str
(
object
[]
what
);
...
...
modules/mono/glue/gd_glue.cpp
View file @
ce678088
...
@@ -52,7 +52,7 @@ MonoObject *godot_icall_GD_bytes2var(MonoArray *p_bytes) {
...
@@ -52,7 +52,7 @@ MonoObject *godot_icall_GD_bytes2var(MonoArray *p_bytes) {
return
GDMonoMarshal
::
variant_to_mono_object
(
ret
);
return
GDMonoMarshal
::
variant_to_mono_object
(
ret
);
}
}
MonoObject
*
godot_icall_GD_convert
(
MonoObject
*
p_what
,
int
p_type
)
{
MonoObject
*
godot_icall_GD_convert
(
MonoObject
*
p_what
,
int
32_t
p_type
)
{
Variant
what
=
GDMonoMarshal
::
mono_object_to_variant
(
p_what
);
Variant
what
=
GDMonoMarshal
::
mono_object_to_variant
(
p_what
);
const
Variant
*
args
[
1
]
=
{
&
what
};
const
Variant
*
args
[
1
]
=
{
&
what
};
Variant
::
CallError
ce
;
Variant
::
CallError
ce
;
...
@@ -65,7 +65,7 @@ int godot_icall_GD_hash(MonoObject *p_var) {
...
@@ -65,7 +65,7 @@ int godot_icall_GD_hash(MonoObject *p_var) {
return
GDMonoMarshal
::
mono_object_to_variant
(
p_var
).
hash
();
return
GDMonoMarshal
::
mono_object_to_variant
(
p_var
).
hash
();
}
}
MonoObject
*
godot_icall_GD_instance_from_id
(
in
t
p_instance_id
)
{
MonoObject
*
godot_icall_GD_instance_from_id
(
uint64_
t
p_instance_id
)
{
return
GDMonoUtils
::
unmanaged_get_managed
(
ObjectDB
::
get_instance
(
p_instance_id
));
return
GDMonoUtils
::
unmanaged_get_managed
(
ObjectDB
::
get_instance
(
p_instance_id
));
}
}
...
@@ -115,7 +115,29 @@ void godot_icall_GD_printt(MonoArray *p_what) {
...
@@ -115,7 +115,29 @@ void godot_icall_GD_printt(MonoArray *p_what) {
print_line
(
str
);
print_line
(
str
);
}
}
void
godot_icall_GD_seed
(
int
p_seed
)
{
double
godot_icall_GD_randf
()
{
return
Math
::
randf
();
}
uint32_t
godot_icall_GD_randi
()
{
return
Math
::
rand
();
}
void
godot_icall_GD_randomize
()
{
Math
::
randomize
();
}
double
godot_icall_GD_rand_range
(
double
from
,
double
to
)
{
return
Math
::
random
(
from
,
to
);
}
uint32_t
godot_icall_GD_rand_seed
(
uint64_t
seed
,
uint64_t
*
newSeed
)
{
int
ret
=
Math
::
rand_from_seed
(
&
seed
);
*
newSeed
=
seed
;
return
ret
;
}
void
godot_icall_GD_seed
(
uint64_t
p_seed
)
{
Math
::
seed
(
p_seed
);
Math
::
seed
(
p_seed
);
}
}
...
@@ -201,6 +223,11 @@ void godot_register_gd_icalls() {
...
@@ -201,6 +223,11 @@ void godot_register_gd_icalls() {
mono_add_internal_call
(
"Godot.GD::godot_icall_GD_printraw"
,
(
void
*
)
godot_icall_GD_printraw
);
mono_add_internal_call
(
"Godot.GD::godot_icall_GD_printraw"
,
(
void
*
)
godot_icall_GD_printraw
);
mono_add_internal_call
(
"Godot.GD::godot_icall_GD_prints"
,
(
void
*
)
godot_icall_GD_prints
);
mono_add_internal_call
(
"Godot.GD::godot_icall_GD_prints"
,
(
void
*
)
godot_icall_GD_prints
);
mono_add_internal_call
(
"Godot.GD::godot_icall_GD_printt"
,
(
void
*
)
godot_icall_GD_printt
);
mono_add_internal_call
(
"Godot.GD::godot_icall_GD_printt"
,
(
void
*
)
godot_icall_GD_printt
);
mono_add_internal_call
(
"Godot.GD::godot_icall_GD_randf"
,
(
void
*
)
godot_icall_GD_randf
);
mono_add_internal_call
(
"Godot.GD::godot_icall_GD_randi"
,
(
void
*
)
godot_icall_GD_randi
);
mono_add_internal_call
(
"Godot.GD::godot_icall_GD_randomize"
,
(
void
*
)
godot_icall_GD_randomize
);
mono_add_internal_call
(
"Godot.GD::godot_icall_GD_rand_range"
,
(
void
*
)
godot_icall_GD_rand_range
);
mono_add_internal_call
(
"Godot.GD::godot_icall_GD_rand_seed"
,
(
void
*
)
godot_icall_GD_rand_seed
);
mono_add_internal_call
(
"Godot.GD::godot_icall_GD_seed"
,
(
void
*
)
godot_icall_GD_seed
);
mono_add_internal_call
(
"Godot.GD::godot_icall_GD_seed"
,
(
void
*
)
godot_icall_GD_seed
);
mono_add_internal_call
(
"Godot.GD::godot_icall_GD_str"
,
(
void
*
)
godot_icall_GD_str
);
mono_add_internal_call
(
"Godot.GD::godot_icall_GD_str"
,
(
void
*
)
godot_icall_GD_str
);
mono_add_internal_call
(
"Godot.GD::godot_icall_GD_str2var"
,
(
void
*
)
godot_icall_GD_str2var
);
mono_add_internal_call
(
"Godot.GD::godot_icall_GD_str2var"
,
(
void
*
)
godot_icall_GD_str2var
);
...
...
modules/mono/glue/gd_glue.h
View file @
ce678088
...
@@ -37,11 +37,11 @@
...
@@ -37,11 +37,11 @@
MonoObject
*
godot_icall_GD_bytes2var
(
MonoArray
*
p_bytes
);
MonoObject
*
godot_icall_GD_bytes2var
(
MonoArray
*
p_bytes
);
MonoObject
*
godot_icall_GD_convert
(
MonoObject
*
p_what
,
int
p_type
);
MonoObject
*
godot_icall_GD_convert
(
MonoObject
*
p_what
,
int
32_t
p_type
);
int
godot_icall_GD_hash
(
MonoObject
*
p_var
);
int
godot_icall_GD_hash
(
MonoObject
*
p_var
);
MonoObject
*
godot_icall_GD_instance_from_id
(
in
t
p_instance_id
);
MonoObject
*
godot_icall_GD_instance_from_id
(
uint64_
t
p_instance_id
);
void
godot_icall_GD_print
(
MonoArray
*
p_what
);
void
godot_icall_GD_print
(
MonoArray
*
p_what
);
...
@@ -53,7 +53,17 @@ void godot_icall_GD_prints(MonoArray *p_what);
...
@@ -53,7 +53,17 @@ void godot_icall_GD_prints(MonoArray *p_what);
void
godot_icall_GD_printt
(
MonoArray
*
p_what
);
void
godot_icall_GD_printt
(
MonoArray
*
p_what
);
void
godot_icall_GD_seed
(
int
p_seed
);
double
godot_icall_GD_randf
();
uint32_t
godot_icall_GD_randi
();
void
godot_icall_GD_randomize
();
double
godot_icall_GD_rand_range
(
double
from
,
double
to
);
uint32_t
godot_icall_GD_rand_seed
(
uint64_t
seed
,
uint64_t
*
newSeed
);
void
godot_icall_GD_seed
(
uint64_t
p_seed
);
MonoString
*
godot_icall_GD_str
(
MonoArray
*
p_what
);
MonoString
*
godot_icall_GD_str
(
MonoArray
*
p_what
);
...
...
Write
Preview
Markdown
is supported
0%
Try again
or
attach a new file
Attach a file
Cancel
You are about to add
0
people
to the discussion. Proceed with caution.
Finish editing this message first!
Cancel
Please
register
or
sign in
to comment