Merge pull request #13290 from VOREStation/upstream-merge-8660

[MIRROR] Adds some core behavior code, uses it to fix a small bug (ABLE TO BE MERGED)
This commit is contained in:
C.L
2022-09-24 21:21:24 -04:00
committed by CHOMPStation2
parent 6ed92a2bf9
commit 8e6652e1b0
17 changed files with 177 additions and 11 deletions

View File

@@ -0,0 +1,53 @@
/// The atom's base transform scale for width.
/atom/var/tf_scale_x
/// The atom's base transform scale for height.
/atom/var/tf_scale_y
/// The atom's base transform scale for rotation.
/atom/var/tf_rotation
/// The atom's base transform scale for horizontal offset.
/atom/var/tf_offset_x
/// The atom's base transform scale for vertical offset.
/atom/var/tf_offset_y
/// Clear the atom's tf_* variables and the current transform state.
/atom/proc/ClearTransform()
tf_scale_x = null
tf_scale_y = null
tf_rotation = null
tf_offset_x = null
tf_offset_y = null
transform = null
/// Sets the atom's tf_* variables and the current transform state, also applying others if supplied.
/atom/proc/SetTransform(
scale,
scale_x = tf_scale_x,
scale_y = tf_scale_y,
rotation = tf_rotation,
offset_x = tf_offset_x,
offset_y = tf_offset_y,
list/others
)
if (!isnull(scale))
tf_scale_x = scale
tf_scale_y = scale
else
tf_scale_x = scale_x
tf_scale_y = scale_y
tf_rotation = rotation
tf_offset_x = offset_x
tf_offset_y = offset_y
transform = matrix().Update(
scale_x = tf_scale_x,
scale_y = tf_scale_y,
rotation = tf_rotation,
offset_x = tf_offset_x,
offset_y = tf_offset_y,
others = others
)

View File

@@ -0,0 +1,23 @@
/**
* Abstract-ness is a meta-property of a class that is used to indicate
* that the class is intended to be used as a base class for others, and
* should not (or cannot) be instantiated.
* We have no such language concept in DM, and so we provide a datum member
* that can be used to hint at abstractness for circumstances where we would
* like that to be the case, such as base behavior providers.
*/
/// If set, a path at/above this one that expects not to be instantiated.
/datum/var/abstract_type
/// If true, this datum is an instance of an abstract type. Oops.
/datum/proc/IsAbstract()
SHOULD_NOT_OVERRIDE(TRUE)
return type == abstract_type
/// Passed a path or instance, returns whether it is abstract. Otherwise null.
/proc/is_abstract(datum/thing)
if (ispath(thing))
return thing == initial(thing.abstract_type)
if (istype(thing))
return thing.IsAbstract()

View File

@@ -0,0 +1,53 @@
/// The image's base transform scale for width.
/image/var/tf_scale_x
/// The image's base transform scale for height.
/image/var/tf_scale_y
/// The image's base transform scale for rotation.
/image/var/tf_rotation
/// The image's base transform scale for horizontal offset.
/image/var/tf_offset_x
/// The image's base transform scale for vertical offset.
/image/var/tf_offset_y
/// Clear the image's tf_* variables and the current transform state.
/image/proc/ClearTransform()
tf_scale_x = null
tf_scale_y = null
tf_rotation = null
tf_offset_x = null
tf_offset_y = null
transform = null
/// Sets the image's tf_* variables and the current transform state, also applying others if supplied.
/image/proc/SetTransform(
scale,
scale_x = tf_scale_x,
scale_y = tf_scale_y,
rotation = tf_rotation,
offset_x = tf_offset_x,
offset_y = tf_offset_y,
list/others
)
if (!isnull(scale))
tf_scale_x = scale
tf_scale_y = scale
else
tf_scale_x = scale_x
tf_scale_y = scale_y
tf_rotation = rotation
tf_offset_x = offset_x
tf_offset_y = offset_y
transform = matrix().Update(
scale_x = tf_scale_x,
scale_y = tf_scale_y,
rotation = tf_rotation,
offset_x = tf_offset_x,
offset_y = tf_offset_y,
others = others
)

View File

@@ -0,0 +1,27 @@
/// Clears the matrix's a-f variables to identity.
/matrix/proc/Clear()
a = 1
b = 0
c = 0
d = 0
e = 1
f = 0
return src
/// Runs Scale, Turn, and Translate if supplied parameters, then multiplies by others if set.
/matrix/proc/Update(scale_x, scale_y, rotation, offset_x, offset_y, list/others)
var/x_null = isnull(scale_x)
var/y_null = isnull(scale_y)
if (!x_null || !y_null)
Scale(x_null ? 1 : scale_x, y_null ? 1 : scale_y)
if (!isnull(rotation))
Turn(rotation)
if (offset_x || offset_y)
Translate(offset_x || 0, offset_y || 0)
if (islist(others))
for (var/other in others)
Multiply(other)
else if (others)
Multiply(others)
return src